-
-
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: adding document for servers' security #2231
Merged
asyncapi-bot
merged 8 commits into
asyncapi:next-major-spec
from
TRohit20:server-security-#1715
Nov 16, 2023
+115
−0
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d4ac709
initial draft for securing servers
TRohit20 981586e
fix: update code example and diagram
TRohit20 0e2c4d6
Update diagram to component level
TRohit20 f514198
Fix indentation for docs rendering
TRohit20 34f8c62
Cross link to adding security on `operation` level
TRohit20 f175921
Merge branch 'next-major-spec' into server-security-#1715
TRohit20 4265bba
Update server-security.md
derberg 9c5a07d
Delete duplicate _section.md
quetzalliwrites 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 | ||
--- |
113 changes: 113 additions & 0 deletions
113
pages/docs/concepts/asyncapi-document/server-security.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,113 @@ | ||||||
--- | ||||||
title: Server Security | ||||||
weight: 200 | ||||||
--- | ||||||
|
||||||
Server security refers to the measures and practices implemented to protect servers from unauthorized access, data breaches, and other security threats. Server security involves implementing various security mechanisms to ensure the confidentiality, integrity, and availability of server resources. | ||||||
|
||||||
In the context of AsyncAPI, securing servers ensures secure exchange of messages between clients and servers. While also protecting sensitive data, preventing unauthorized access, and maintaining the overall security of the API or server. | ||||||
|
||||||
You can secure a server by using the `security` property where you define or declare which security schemes can be used with the server in context. Each `server` in the AsyncAPI document can have one or more security schemes declared. A security scheme defines a security requirement that must be satisfied to authorize an operation such as a API key or username and password. | ||||||
|
||||||
Here is a example of adding security to your server: | ||||||
```yml | ||||||
asyncapi: '3.0.0' | ||||||
TRohit20 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
info: | ||||||
title: My AsyncAPI | ||||||
version: '1.0.0' | ||||||
servers: | ||||||
production: | ||||||
url: api.example.com | ||||||
protocol: amqp | ||||||
security: | ||||||
- saslScram: [] | ||||||
- certs: [] | ||||||
components: | ||||||
securitySchemes: | ||||||
saslScram: | ||||||
type: scramSha256 | ||||||
description: Provide your username and password for SASL/SCRAM authentication | ||||||
certs: | ||||||
type: X509 | ||||||
description: Download the certificate files from service provider | ||||||
``` | ||||||
|
||||||
Here is a illustration of securing servers: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
```mermaid | ||||||
graph LR | ||||||
A[asyncapi: '3.0.0'] --> B[info] | ||||||
TRohit20 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
A --> C[servers] | ||||||
A --> D[components] | ||||||
D --> I | ||||||
D --> J | ||||||
|
||||||
B --> E[title, version] | ||||||
|
||||||
C -->F[production] | ||||||
F --> G[url, protocol, security] | ||||||
G -->|Security Schemes| H[saslScram, certs] | ||||||
I[type, description] | ||||||
J[type, description] | ||||||
``` | ||||||
|
||||||
Here are some of the security schemes that AsyncAPI supports: | ||||||
- User/Password | ||||||
```yml | ||||||
type: userPassword | ||||||
``` | ||||||
|
||||||
- API key (either as a user or as a password) | ||||||
```yml | ||||||
type: apiKey | ||||||
in: user | ||||||
``` | ||||||
|
||||||
- X.509 certificate | ||||||
```yml | ||||||
type: X509 | ||||||
``` | ||||||
|
||||||
- End-to-end encryption (either symmetric or asymmetric) | ||||||
```yml | ||||||
type: symmetricEncryption | ||||||
``` | ||||||
|
||||||
- HTTP authentication | ||||||
```yml | ||||||
type: http | ||||||
scheme: basic | ||||||
``` | ||||||
|
||||||
- HTTP API key | ||||||
```yml | ||||||
type: httpApiKey | ||||||
name: api_key | ||||||
in: header | ||||||
``` | ||||||
|
||||||
- JWT Bearer | ||||||
```yml | ||||||
type: http | ||||||
scheme: bearer | ||||||
bearerFormat: JWT | ||||||
``` | ||||||
|
||||||
- Implicit oauth2 | ||||||
```yml | ||||||
type: oauth2 | ||||||
flows: | ||||||
implicit: | ||||||
authorizationUrl: https://example.com/api/oauth/dialog | ||||||
availableScopes: | ||||||
write:pets: modify pets in your account | ||||||
read:pets: read your pets | ||||||
scopes: | ||||||
- 'write:pets' | ||||||
``` | ||||||
|
||||||
- SASL (Simple Authentication and Security Layer) as defined in RFC4422 | ||||||
```yml | ||||||
type: scramSha512 | ||||||
``` | ||||||
|
||||||
Although, the `security` property is not mandatory to be implemented, it is a good practise to always secure your server(s) in production. Similarly, having multiple security schemes declared does not necessarily mean that the server is more secure, it really depends on other factors such as the protocol used, use case, business perspective and more. |
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.