전역 보안 설정에 정의되지 않은 OAuth Scope 사용

OpenAPI 2.0의 전역 보안 요구사항에 정의되지 않은 OAuth2 스코프가 포함되어 있습니다.

설명

Swagger 2.0의 전역 security에서 요구하는 OAuth2 스코프를 해당 securityDefinitions 스킴의 scopes와 대조하세요. 별도 security가 없는 작업은 이 요구사항을 상속합니다.

잠재적 영향

전역 스코프 이름이 틀리면 여러 작업의 클라이언트가 발급받을 수 없는 권한을 요청할 수 있습니다.

해결 방법

오타는 수정하고 불필요한 스코프만 제거하세요. 실제로 필요한 스코프라면 인가 서버에서 발급하는 이름을 정의하고 해당 권한이 필요한 작업에서 확인하세요.

예시

예시의 전역 요구사항은 정의된 read:api를 유지하고 정의되지 않은 error:api를 제거합니다.

변경 전

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

변경 후

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

참조