설명
OpenAPI 3.0의 전역 security에서 요구하는 OAuth2 스코프는 components.securitySchemes 아래 해당 흐름의 scopes와 대조하세요. 별도 요구사항이 없는 작업에 이 기본값이 적용됩니다.
잠재적 영향
클라이언트가 인가 서버에서 발급하지 않는 권한을 요청하면 API 호출에 필요한 토큰을 받지 못할 수 있습니다.
해결 방법
오타는 고치고 필요한 권한은 인가 서버의 설정에 맞춰 정의하세요. OpenID Connect의 스코프는 제공자에서 확인하세요. 전역 설정을 상속하는 작업으로 권한을 검증하세요.
예시
예시의 authorizationCode 흐름에는 read:api만 정의되어 있습니다. 두 번째 예시는 전역 목록에서 error:api만 제거합니다.
변경 전
json
{
"openapi": "3.0.0",
"security": [
{
"oAuth2AuthCode": [
"read:api",
"error:api"
]
}
],
"components": {
"securitySchemes": {
"oAuth2AuthCode": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://api.example.com/oauth/authorize",
"tokenUrl": "https://api.example.com/oauth/token",
"scopes": {
"read:api": "read your apis"
}
}
}
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"security": [
{
"oAuth2AuthCode": [
"read:api"
]
}
],
"components": {
"securitySchemes": {
"oAuth2AuthCode": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://api.example.com/oauth/authorize",
"tokenUrl": "https://api.example.com/oauth/token",
"scopes": {
"read:api": "read your apis"
}
}
}
}
}
}
}