elements icon indicating copy to clipboard operation
elements copied to clipboard

Multiple values for authentication

Open GeitV opened this issue 3 years ago • 5 comments

Multiple Authentication parameters

As a web user, I'd like to do "Try It!" with authorization token and user ID, but it's not currently possible (I've checked even code of this project, and seems like this is not possibility, yet).

We are currently moving from using Postman to Stoplight. While moving, we got an issue, where we want to send Authorization: Bearer token and header X-ACCOUNT-ID: 123, as one user can have multiple accounts in our system.

Luckily, this is part of OpenAPI spec (multiple parameters by no leading dash between security parameters). However, this is not working in elements.

The ID is used as part of the authentication, so it's not really something we'd like to mark as parameter for each and every endpoint we have.

Example for this in OpenAPI

components:
  securitySchemes:
    jwtToken:
      type: http
      scheme: bearer
    accountId:
      type: apiKey
      in: header
      name: X-ACCOUNT-ID
security:
  - jwtToken: []
    accountId: []   # <-- no leading dash (-)

GeitV avatar Feb 10 '22 09:02 GeitV

Having the same issue here! This is a very common use case. Most apis require an ApiToken for any endpoint and a second BearerToken or similar for any auth endpoints.

canvasplay avatar Mar 09 '22 07:03 canvasplay

Stoplight elements currently incorrectly interprets the OpenAPI specification regarding the security requirement objects.

Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information.

Specifically a security like this:

security:
- apiKey: []
  accessToken: []

must be interpreted as apiKey and accessToken while

security:
- apiKey: []
- accessToken: []

means apiKey or accessToken.

Currently both types are simply flattened into a single array of choices.

m-gericke avatar May 31 '22 14:05 m-gericke

same issue https://github.com/stoplightio/elements/issues/1794

manycoding avatar Apr 27 '23 19:04 manycoding

Having the same issue!

TheMrKiko avatar Aug 11 '23 14:08 TheMrKiko

At the end, we are moving away to another product with proper support.

manycoding avatar Aug 18 '23 17:08 manycoding