-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix apikey authorization #441
base: master
Are you sure you want to change the base?
Conversation
Hi, thanks for working on this. Please be mindful that the current support is for openapi2/swagger. The openapi3 support that we have atm is simply a conversion from 2. Therefore the only supported types are: Currently we'd use jwt as an apiKey, example: #[derive(Apiv2Security, Deserialize)]
#[openapi(
apiKey,
alias = "JWT",
in = "header",
name = "Authorization",
description = "Use format 'Bearer TOKEN'"
)]
pub struct BearerToken; So, I think we can adapt your changes by adding your purposed changes by adding another field to the openapi2 SecuritySchema that is not serializable (as we don't want it to be present if we're generating openapi2 spec), but that allows us to convert to openapi3. And maybe for those types of things we'd have an |
04a5510
to
33cd55f
Compare
I needed to use an Authorization of type
apiKey
inheader
.But the code that handled that was unreachable due to some conditions to build bearer auth in priority.
According to OAS3 (https://swagger.io/docs/specification/authentication/bearer-authentication/) :
basicAuth should use associations :
type: http
andscheme: basic
.bearerAuth should use associations :
type: http
, thescheme: bearer
and if neededbearerFormat: JWT
.ApiKeyAuth should use associations :
type: apiKey
,in: header
andname: X-API-KEY
.cookieAuth should use associations :
type: apiKey
,in: cookie
andname: JSESSIONID
.I adapted the code so we could use all those authentication and fixed the comment standing there :
// how to determine when it should be JWT?
.I completed the documentation page and added a test.
Bearer auth
apiKey auth