설명
OpenAPI 3.0에서 in: query로 정의한 API 키는 요청 URL에 포함되어 로그에 남을 수 있습니다.
잠재적 영향
노출된 키로는 해당 키에 허용된 API 작업을 호출할 수 있습니다.
해결 방법
API 키를 유지한다면 서버와 클라이언트가 HTTPS 헤더로 키를 주고받도록 바꾸고 명세에 in: header를 지정하세요. 로그에서 키를 가리고 이미 노출된 키는 폐기한 뒤 재발급하세요.
예시
사용자 권한을 위임해야 할 때는 예시처럼 OAuth2를 적용할 수 있습니다. 전역 oauthAuth: []는 특정 스코프를 요구하지 않습니다. 필요한 스코프는 명세와 서버에 함께 지정하세요.
변경 전
json
{
"openapi": "3.0.0",
"security": [
{
"apiKeyAuth": []
}
],
"components": {
"securitySchemes": {
"apiKeyAuth": {
"type": "apiKey",
"name": "X-API-Key",
"in": "query"
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"security": [
{
"oauthAuth": []
}
],
"components": {
"securitySchemes": {
"oauthAuth": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/api/oauth/dialog",
"tokenUrl": "https://example.com/api/oauth/token",
"scopes": {
"read:pets": "read your pets"
}
}
}
}
}
}
}