Skip to content

Commit 848973d

Browse files
authored
Merge pull request OAI#818 from OAI/dm/securityreview
Security definition documentation updates
2 parents b8b3cfe + 5107b5f commit 848973d

File tree

1 file changed

+111
-34
lines changed

1 file changed

+111
-34
lines changed

versions/3.0.md

Lines changed: 111 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Field Name | Type | Description
185185
<a name="oasHosts"></a>servers | [[Server Object](#serverObject)] | An optional array of Server Objects which provide connectivity information to a target server.
186186
<a name="oasPaths"></a>paths | [Paths Object](#pathsObject) | **Required.** The available paths and operations for the API.
187187
<a name="oasComponents"></a>components | [Components Object](#componentsObject) | An element to hold various schemas for the specification.
188-
<a name="oasSecurity"></a>security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition.
188+
<a name="oasSecurity"></a>security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition.
189189
<a name="oasTags"></a>tags | [[Tag Object](#tagObject)] | A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.
190190
<a name="oasExternalDocs"></a>externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation.
191191

@@ -584,7 +584,7 @@ Field Name | Type | Description
584584
<a name="operationResponses"></a>responses | [Responses Object](#responsesObject) | **Required.** The list of possible responses as they are returned from executing this operation.
585585
<a name="operationCallbacks"></a>callback responses | [Callback Responses Object](#callbackObject) | The list of possible callback responses as they are returned from executing this operation.
586586
<a name="operationDeprecated"></a>deprecated | `boolean` | Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is `false`.
587-
<a name="operationSecurity"></a>security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security schemes are applied for this operation. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). This definition overrides any declared top-level [`security`](#oasSecurity). To remove a top-level security declaration, an empty array can be used.
587+
<a name="operationSecurity"></a>security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. This definition overrides any declared top-level [`security`](#oasSecurity). To remove a top-level security declaration, an empty array can be used.
588588
<a name="operationItemServer"></a>servers | [Server Object](#serverObject) | An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value.
589589

590590
This object can be extended with [Specification Extensions](#specificationExtensions).
@@ -3025,11 +3025,14 @@ Field Pattern | Type | Description
30253025
},
30263026
"petstore_auth": {
30273027
"type": "oauth2",
3028-
"authorizationUrl": "http://swagger.io/api/oauth/dialog",
3029-
"flow": "implicit",
3030-
"scopes": {
3031-
"write:pets": "modify pets in your account",
3032-
"read:pets": "read your pets"
3028+
"flow": {
3029+
"implicit": {
3030+
"authorizationUrl": "http://swagger.io/api/oauth/dialog",
3031+
"scopes": {
3032+
"write:pets": "modify pets in your account",
3033+
"read:pets": "read your pets"
3034+
}
3035+
}
30333036
}
30343037
}
30353038
}
@@ -3042,17 +3045,18 @@ api_key:
30423045
in: header
30433046
petstore_auth:
30443047
type: oauth2
3045-
authorizationUrl: http://swagger.io/api/oauth/dialog
3046-
flow: implicit
3047-
scopes:
3048-
write:pets: modify pets in your account
3049-
read:pets: read your pets
3048+
flow:
3049+
implicit:
3050+
authorizationUrl: http://swagger.io/api/oauth/dialog
3051+
scopes:
3052+
write:pets: modify pets in your account
3053+
read:pets: read your pets
30503054
```
30513055

30523056
#### <a name="securitySchemeObject"></a>Security Scheme Object
30533057

30543058
Allows the definition of a security scheme that can be used by the operations.
3055-
Supported schemes are basic authentication, an API key (either as a header or as a query parameter) and OAuth2's common flows (implicit, password, application and access code).
3059+
Supported schemes are HTTP authentication, an API key (either as a header or as a query parameter) and OAuth2's common flows (implicit, password, application and access code).
30563060

30573061
##### Fixed Fields
30583062
Field Name | Type | Validity | Description
@@ -3061,13 +3065,10 @@ Field Name | Type | Validity | Description
30613065
<a name="securitySchemeDescription"></a>description | `string` | Any | A short description for security scheme.
30623066
<a name="securitySchemeName"></a>name | `string` | `apiKey` | **Required.** The name of the header or query parameter to be used.
30633067
<a name="securitySchemeIn"></a>in | `string` | `apiKey` | **Required** The ___location of the API key. Valid values are `"query"` or `"header"`.
3064-
<a name="securitySchemeScheme"></a>scheme | `string` | `http` | **Required.** The name of the HTTP Authorization scheme to be used in the Authorization header as per RFC 7234.
3065-
<a name="securitySchemeBearerFormat"></a>bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token should be formatted.
3066-
<a name="securitySchemeOpenIdConnectUrl"></a>openIdConnectUrl | `string` | `openIdConnect` | **Required.** OpenId Connect URL to discover OAuth2 configuration values.
3067-
<a name="securitySchemeFlow"></a>flow | `string` | `oauth2` | **Required.** The flow used by the OAuth2 security scheme. Valid values are `"implicit"`, `"password"`, `"application"` or `"accessCode"`.
3068-
<a name="securitySchemeAuthorizationUrl"></a>authorizationUrl | `string` | `oauth2` (`"implicit"`, `"accessCode"`) | **Required.** The authorization URL to be used for this flow. This SHOULD be in the form of a URL.
3069-
<a name="securitySchemeTokenUrl"></a>tokenUrl | `string` | `oauth2` (`"password"`, `"application"`, `"accessCode"`) | **Required.** The token URL to be used for this flow. This SHOULD be in the form of a URL.
3070-
<a name="securitySchemeScopes"></a>scopes | [Scopes Object](#scopesObject) | `oauth2` | **Required.** The available scopes for the OAuth2 security scheme.
3068+
<a name="securitySchemeScheme"></a>scheme | `string` | `http` | **Required.** The name of the HTTP Authorization scheme to be used in the [Authorization header as defined in RFC 7235](https://tools.ietf.org/html/rfc7235#section-4.2).
3069+
<a name="securitySchemeBearerFormat"></a>bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes.
3070+
<a name="securitySchemeFlow"></a>flow | [OAuth Flows Object](#oauthFlowsObject) | `oauth2` | **Required.** An object containing configuration information for the flow types supported.
3071+
<a name="securitySchemeOpenIdConnectUrl"></a>openIdConnectUrl | `string` | `openIdConnect` | **Required.** OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL.
30713072

30723073
This object can be extended with [Specification Extensions](#specificationExtensions).
30733074

@@ -3077,7 +3078,7 @@ This object can be extended with [Specification Extensions](#specificationExtens
30773078

30783079
```json
30793080
{
3080-
"type": "scheme",
3081+
"type": "http",
30813082
"scheme" : "basic"
30823083
}
30833084
```
@@ -3124,22 +3125,95 @@ bearerFormat: JWT
31243125
```json
31253126
{
31263127
"type": "oauth2",
3127-
"authorizationUrl": "http://swagger.io/api/oauth/dialog",
3128-
"flow": "implicit",
3129-
"scopes": {
3130-
"write:pets": "modify pets in your account",
3131-
"read:pets": "read your pets"
3128+
"flow": {
3129+
"implicit": {
3130+
"authorizationUrl": "https://swagger.io/api/oauth/dialog",
3131+
"scopes": {
3132+
"write:pets": "modify pets in your account",
3133+
"read:pets": "read your pets"
3134+
}
3135+
}
31323136
}
31333137
}
31343138
```
31353139

31363140
```yaml
31373141
type: oauth2
3138-
authorizationUrl: http://swagger.io/api/oauth/dialog
3139-
flow: implicit
3140-
scopes:
3141-
write:pets: modify pets in your account
3142-
read:pets: read your pets
3142+
flow:
3143+
implicit:
3144+
authorizationUrl: https://swagger.io/api/oauth/dialog
3145+
scopes:
3146+
write:pets: modify pets in your account
3147+
read:pets: read your pets
3148+
```
3149+
3150+
#### <a name="oauthFlowsObject"></a>OAuth Flows Object
3151+
3152+
Allows configuration of the supported OAuth Flows.
3153+
3154+
##### Fixed Fields
3155+
Field Name | Type | Description
3156+
---|:---:|---|---
3157+
<a name="oauthFlowImplicit"></a>implicit| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Implicit flow
3158+
<a name="oauthFlowPassword"></a>password| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Resource Owner Password flow
3159+
<a name="oauthFlowClientCredentials"></a>clientCredentials| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenApi 2.0.
3160+
<a name="oauthFlowAuthorizationCode"></a>authorizationCode| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenApi 2.0.
3161+
3162+
This object can be extended with [Specification Extensions](#specificationExtensions).
3163+
3164+
#### <a name="oauthFlowObject"></a>OAuth Flow Object
3165+
3166+
Configuration details for a supported OAuth Flow
3167+
3168+
##### Fixed Fields
3169+
Field Name | Type | Validity | Description
3170+
---|:---:|---|---
3171+
<a name="securitySchemeAuthorizationUrl"></a>authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **Required.** The authorization URL to be used for this flow. This MUST be in the form of a URL.
3172+
<a name="securitySchemeTokenUrl"></a>tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`) | **Required.** The token URL to be used for this flow. This MUST be in the form of a URL.
3173+
<a name="securitySchemeRefreshUrl"></a>refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL.
3174+
<a name="securitySchemeScopes"></a>scopes | [Scopes Object](#scopesObject) | `oauth2` | **Required.** The available scopes for the OAuth2 security scheme.
3175+
3176+
This object can be extended with [Specification Extensions](#specificationExtensions).
3177+
3178+
##### OAuth Flow Object Examples
3179+
3180+
```JSON
3181+
{
3182+
"type": "oauth2",
3183+
"flow": {
3184+
"implicit": {
3185+
"authorizationUrl": "https://swagger.io/api/oauth/dialog",
3186+
"scopes": {
3187+
"write:pets": "modify pets in your account",
3188+
"read:pets": "read your pets"
3189+
}
3190+
},
3191+
"authorizationCode": {
3192+
"authorizationUrl": "https://swagger.io/api/oauth/dialog",
3193+
"tokenUrl": "https://swagger.io/api/oauth/token",
3194+
"scopes": {
3195+
"write:pets": "modify pets in your account",
3196+
"read:pets": "read your pets"
3197+
}
3198+
}
3199+
}
3200+
}
3201+
```
3202+
3203+
```YAML
3204+
type: oauth2
3205+
flow:
3206+
implicit:
3207+
authorizationUrl: https://swagger.io/api/oauth/dialog
3208+
scopes:
3209+
write:pets: modify pets in your account
3210+
read:pets: read your pets
3211+
authorizationCode:
3212+
authorizationUrl: https://swagger.io/api/oauth/dialog
3213+
tokenUrl: https://swagger.io/api/oauth/token
3214+
scopes:
3215+
write:pets: modify pets in your account
3216+
read:pets: read your pets
31433217
```
31443218

31453219
#### <a name="scopesObject"></a>Scopes Object
@@ -3171,15 +3245,18 @@ read:pets: read your pets
31713245
#### <a name="securityRequirementObject"></a>Security Requirement Object
31723246

31733247
Lists the required security schemes to execute this operation.
3174-
The object can have multiple security schemes declared in it which are all required (that is, there is a logical AND between the schemes).
3175-
31763248
The name used for each property MUST correspond to a security scheme declared in the [Security Definitions](#securityDefinitionsObject).
31773249

3250+
Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized.
3251+
This enables support for scenarios where there multiple query parameters or HTTP headers are required to convey security information.
3252+
3253+
When a list of Security Requirement Objects is defined on the [Open API object](#oasObject) or [Operation Object](#operationObject), only one of Security Requirement Objects in the list needs to be satisfied to authorize.
3254+
31783255
##### Patterned Fields
31793256

31803257
Field Pattern | Type | Description
31813258
---|:---:|---
3182-
<a name="securityRequirementsName"></a>{name} | [`string`] | Each name must correspond to a security scheme which is declared in the [Security Definitions](#securityDefinitions). If the security scheme is of type `"oauth2"`, then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty.
3259+
<a name="securityRequirementsName"></a>{name} | [`string`] | Each name must correspond to a security scheme which is declared in the [Security Definitions](#securityDefinitions). If the security scheme is of type `"oauth2"` or `"openIdConnect"`, then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty.
31833260

31843261
##### Security Requirement Object Examples
31853262

0 commit comments

Comments
 (0)