설명
OpenAPI 2.0에서 accessCode처럼 토큰 엔드포인트를 사용하는 OAuth2 흐름은 tokenUrl로 토큰을 요청합니다. implicit 흐름에는 이 엔드포인트가 없습니다.
잠재적 영향
잘못된 주소는 토큰 발급 실패로 이어집니다. HTTP를 사용하거나 다른 서버에 요청을 보내면 인증 정보나 토큰이 노출될 수 있습니다.
해결 방법
securityDefinitions에서 해당 흐름의 tokenUrl을 공급자의 공식 HTTPS 토큰 엔드포인트로 설정하세요. # 프래그먼트는 제외하고, 클라이언트가 해당 서버에 연결해 인증서를 검증하는지 확인하세요.
예시
예시에서는 accessCode의 tokenUrl만 바꿉니다. 사용자 로그인 주소는 authorizationUrl에 둡니다.
변경 전
yaml
swagger: "2.0"
securityDefinitions:
petstore_auth:
type: oauth2
flow: accessCode
authorizationUrl: https://api.my.company.com/oauth/authorize
tokenUrl: http://example.com#@evil.com/
scopes:
write:pets: modify pets
read:pets: read pets
변경 후
yaml
swagger: "2.0"
securityDefinitions:
petstore_auth:
type: oauth2
flow: accessCode
authorizationUrl: https://api.my.company.com/oauth/authorize
tokenUrl: https://api.my.company.com/oauth/token
scopes:
write:pets: modify pets
read:pets: read pets