-
-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: added content for securing operations #2172
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
158f16e
added securing-operations
BhaswatiRoy c2e2fa9
Update pages/docs/concepts/asyncapi-document/_section.md
BhaswatiRoy fa01502
Update pages/docs/concepts/asyncapi-document/_section.md
BhaswatiRoy cd1f009
Update pages/docs/concepts/asyncapi-document/securing-operations.md
BhaswatiRoy d33fcff
Update pages/docs/concepts/asyncapi-document/securing-operations.md
BhaswatiRoy 70de11f
Update pages/docs/concepts/asyncapi-document/securing-operations.md
BhaswatiRoy 31efa94
Update pages/docs/concepts/asyncapi-document/securing-operations.md
BhaswatiRoy 2efe7b5
Update pages/docs/concepts/asyncapi-document/securing-operations.md
BhaswatiRoy 3f067e3
Update pages/docs/concepts/asyncapi-document/securing-operations.md
BhaswatiRoy 77b8e96
added description on both ways to add security to operations
BhaswatiRoy ad97189
shortened header as per suggestions
BhaswatiRoy 9635743
replaced v2 examples with v3 ones
BhaswatiRoy 5593586
added objects under security in v3
BhaswatiRoy 13ae5ac
removed enforce/override statement
BhaswatiRoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: AsyncAPI Document | ||
weight: 50 | ||
--- |
81 changes: 81 additions & 0 deletions
81
pages/docs/concepts/asyncapi-document/securing-operations.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
title: 'Securing Operations' | ||
weight: 120 | ||
--- | ||
|
||
The concept of server security implies that the security measures defined at the server level apply to all operations within all channels by default. | ||
|
||
## Security Features | ||
|
||
The security requirements specified at the server level are enforced consistently across the entire Asyncapi document. There may be situations where certain operations within specific channels require different security measures than the default server-level settings. | ||
|
||
- To accommodate such scenarios, the AsyncAPI document allows you to use the `security` property at the `operation` level. This means users can define security requirements at both the global level and the operation (endpoint) level. | ||
|
||
```yaml | ||
channels: | ||
AUTHORIZATION_REVOCATION: | ||
address: AUTHORIZATION_REVOCATION | ||
messages: | ||
subscribe.message: | ||
$ref: '#/components/messages/message' | ||
|
||
security: | ||
- apiKey: [] | ||
``` | ||
|
||
- One more way is when users don't use the `server` feature from AsyncAPI, and only include `channels` and `operations`. In this case, the user needs to specify the security of the operation within the `operations`. | ||
|
||
```yaml | ||
channels: | ||
AUTHORIZATION_REVOCATION: | ||
address: AUTHORIZATION_REVOCATION | ||
messages: | ||
subscribe.message: | ||
$ref: '#/components/messages/message' | ||
operations: | ||
AUTHORIZATION_REVOCATION.subscribe: | ||
action: send | ||
channel: | ||
$ref: '#/channels/AUTHORIZATION_REVOCATION' | ||
security: | ||
- type: oauth2 | ||
description: The oauth security descriptions | ||
flows: | ||
clientCredentials: | ||
tokenUrl: 'https://example.com/api/oauth/dialog' | ||
availableScopes: | ||
'subscribe:auth_revocations': Scope required for authorization revocation topic | ||
scopes: | ||
- 'subscribe:auth_revocations' | ||
``` | ||
|
||
The `security` field comprises of 2 parts - | ||
|
||
- Security scheme object = This portion mentions the security schemes associated with the given operation. One of the security scheme objects must be satisfied to authorize an operation. | ||
|
||
- Reference object = This portion references a definition by linking to somewhere else in the document using the `$ref:` keyword. | ||
|
||
## Specifying Security Requirement | ||
|
||
To specify different security requirements for a specific operation, you can include the `security` property within the operation's definition. | ||
The security property is an array where you can define one or more security requirement objects. | ||
|
||
For example, let's say you have an AsyncAPI document with a channel called users and two operations within that channel: `createUser` and `getUser`. | ||
The server-level security is set to use API key authentication for all operations within all channels. | ||
|
||
The following example explains how to include security requirement for operations definition | ||
|
||
```yaml | ||
BhaswatiRoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
title: User sign up | ||
summary: Action to sign a user up. | ||
description: A longer description | ||
channel: | ||
$ref: '#/channels/userSignup' | ||
action: send | ||
security: | ||
- OAuth2: [] | ||
``` | ||
|
||
In the above example, the `security` property is added under the `getUser` operation, indicating that the OAuth2 security requirement should be applied to that specific operation within the user's channel. The empty array [] signifies that no additional configuration is needed for the OAuth2 security mechanism. | ||
|
||
Utilizing the security property at the operation level allows you to deviate from the server-level security settings and define unique security requirements for individual operations within your AsyncAPI document. The capability ensures that you can adequately secure your API operations, even if they require different security measures. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot enforce as it is not about overriding,
it is like providing alternative for what is already in the server. Of course you can do a server without security, then have different operations and channels on the same server, each operation with different security - still, it is not overriding/enforcing if you know what I mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unable to understand how to improve the content as per your suggestions.
could you please attach some examples or maybe give me a bit more info about the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the line that stated about enforcing/overriding, though not sure if I still was able to resolved the suggestion.