Description
Match each OAuth2 scope in global Swagger 2.0 security to the scheme’s scopes in securityDefinitions. Operations without their own security inherit that requirement.
Potential impact
A typo in a global scope can cause clients for multiple operations to request a permission the provider cannot issue.
Remediation
Correct the name or remove an unused scope. If the permission is required, define the name the authorization server issues and verify it on an operation that needs it.
Examples
The example keeps the declared read:api scope and removes the undefined error:api from the global requirement.
Before
yaml
swagger: "2.0"
securityDefinitions:
oAuth2AuthCode:
type: oauth2
flow: accessCode
authorizationUrl: https://api.example.com/oauth/authorize
tokenUrl: https://api.example.com/oauth/token
scopes:
read:api: read your apis
security:
- oAuth2AuthCode:
- read:api
- error:api
After
yaml
swagger: "2.0"
securityDefinitions:
oAuth2AuthCode:
type: oauth2
flow: accessCode
authorizationUrl: https://api.example.com/oauth/authorize
tokenUrl: https://api.example.com/oauth/token
scopes:
read:api: read your apis
security:
- oAuth2AuthCode:
- read:api