설명
OpenAPI 3.0에서 작업의 security는 전역 요구사항을 대체합니다. 필요한 OAuth2 스코프를 components.securitySchemes 아래 해당 흐름의 scopes 및 인가 서버의 설정과 맞추세요.
잠재적 영향
작업의 권한이 잘못 문서화되면 클라이언트가 다른 스코프를 요청하거나 정상 요청이 거부될 수 있습니다.
해결 방법
빠진 권한이 실제로 필요하면 스코프를 정의하고 작업의 요구사항에 유지하세요. 권한이 있는 테스트 토큰과 없는 토큰으로 해당 작업의 결과를 확인하세요. OpenID Connect라면 스코프를 제공자와 대조하세요.
예시
GET /의 두 번째 예시는 read:api를 유지하고 정의되지 않은 error:api를 제거합니다.
변경 전
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"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",
"paths": {
"/": {
"get": {
"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"
}
}
}
}
}
}
}