Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarity on how to handle optional security #3426

Closed
RobbeSneyders opened this issue Oct 31, 2023 · 2 comments
Closed

Clarity on how to handle optional security #3426

RobbeSneyders opened this issue Oct 31, 2023 · 2 comments

Comments

@RobbeSneyders
Copy link

We're wondering how to handle the following specification in connexion.

security:
- api_key: []
- {}
components:
  securitySchemes:
    api_key:
      type: apiKey
      name: X-Auth
      in: header
      x-apikeyInfoFunc: app.apikey_auth

If the user sends an invalid API key, should this request be accepted because security is optional, or rejected because the request is invalid according to the api_key security scheme?

When reading the specification to the letter, these schemes should be applied in an OR fashion, so the request should be accepted. However, from the user side, it probably makes more sense to alert them of the invalid API key and reject the request.

Related: #1698

@darrelmiller
Copy link
Member

I don't believe OpenAPI has an opinion on the right response here. I would agree with you that a caller that sends an api key is likely to be intending it to be a valid key and would expect an error if it isn't valid. However, I don't think OpenAPI should make this choice for the API provider.

@RobbeSneyders
Copy link
Author

Ok thanks for the response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants