feat: Add scopes support to apiKey securityScheme #5251
joekir
started this conversation in
Enhancements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Currently, the apiKey security scheme does not support scopes/permissions, unlike OAuth2. This means that when an API uses API key authentication with granular permissions, there is no native way to document these in the spec and developers must resort to documenting permissions in the description field of each operation.
Current Behaviour
API key security schemes only support an empty array in the security requirement object:
Desired Behaviour
Allow scopes to be defined on apiKey security schemes, similar to oauth2:
Use Case
Many APIs use API keys with granular permission models. Without native scope support, tooling such as documentation generators, SDK generators and API gateways cannot automatically understand or enforce permissions, leading to:
Alternatives Considered
Documenting permissions in the description field - works but is not machine-readable
Switching to OAuth2 - not always feasible for simpler APIs that use API keys, or misleading if the API is not OAuth2 and just leveraging this feature
Beta Was this translation helpful? Give feedback.
All reactions