OpenAPI 3.0의 잘못된 OAuth2 토큰 URL

OAuth2 흐름의 tokenUrl은 제공자의 정확한 HTTPS 토큰 발급 주소여야 합니다.

설명

OpenAPI 3.0의 authorizationCode 같은 OAuth2 흐름은 tokenUrl로 토큰을 요청합니다. implicit 흐름은 토큰 엔드포인트를 사용하지 않습니다.

잠재적 영향

클라이언트가 잘못된 서버로 요청을 보내면 토큰 발급이 실패하거나 인증 정보가 노출될 수 있습니다.

해결 방법

components.securitySchemes에서 해당 흐름의 tokenUrl에 공급자의 공식 HTTPS 토큰 엔드포인트를 입력하세요. URL에는 # 프래그먼트를 넣지 마세요. 클라이언트가 이 서버에 연결하고 인증서를 검증하는지 확인하세요.

예시

예시는 authorizationCode 흐름의 토큰 주소를 수정합니다. 로그인 주소인 authorizationUrl은 그대로 사용합니다.

변경 전

yaml
openapi: 3.0.0
components:
  securitySchemes:
    petstore_auth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://api.my.company.com/oauth/authorize
          tokenUrl: http://example.com#@evil.com/
          scopes:
            read:api: read your apis

변경 후

yaml
openapi: 3.0.0
components:
  securitySchemes:
    petstore_auth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://api.my.company.com/oauth/authorize
          tokenUrl: https://api.my.company.com/oauth/token
          scopes:
            read:api: read your apis

참조