You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm dealing with a case where I get both a opaque bearer token (Authorization header) and a tenant ID (custom HTTP header) and have to check if the opaque bearer (access) token is valid with the help of the tenant ID.
This means that I (kind of) depend on the tenant ID presence and validity (apiKey auth) being checked before the bearer token is checked, so that I can pass some data from the apiKey security handler to the bearer handler through the context.Context.
I've noticed that the order in the security property in the OpenAPI specification doesn't matter, what matters is the security scheme name - the Go code generation template seems to depend on that for the order of the checks 🙁 I.e. bearerAuth will be checked before tenantID because b comes before t in the alphabet, but if I prefix tenantID with an a (i.e. atenantID) it'll be checked before the bearerAuth.
Another option for my use case is that I leave an empty HandleTenantID implementation and do everything in the HandleBearerAuth method - pull the custom HTTP header out of the request myself instead of ogen doing that for me 🤔 The tenantID security definition is kept only for documentation purposes in this case since the code generated from it is never used. Another option is that I define the tenantID header per endpoint where bearerAuth is used 🤷
Is there perhaps a better way to declare in which order the security checks should happen or would it be possible to adjust the templates in such a way that if security handlers are listed in groups an additional method would be generated for the SecurityHandler interface which would get both values? I.e.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm dealing with a case where I get both a opaque bearer token (Authorization header) and a tenant ID (custom HTTP header) and have to check if the opaque bearer (access) token is valid with the help of the tenant ID.
This means that I (kind of) depend on the tenant ID presence and validity (apiKey auth) being checked before the bearer token is checked, so that I can pass some data from the apiKey security handler to the bearer handler through the
context.Context.I've noticed that the order in the security property in the OpenAPI specification doesn't matter, what matters is the security scheme name - the Go code generation template seems to depend on that for the order of the checks 🙁 I.e.
bearerAuthwill be checked beforetenantIDbecausebcomes beforetin the alphabet, but if I prefixtenantIDwith ana(i.e.atenantID) it'll be checked before thebearerAuth.Another option for my use case is that I leave an empty
HandleTenantIDimplementation and do everything in theHandleBearerAuthmethod - pull the custom HTTP header out of the request myself instead of ogen doing that for me 🤔 ThetenantIDsecurity definition is kept only for documentation purposes in this case since the code generated from it is never used. Another option is that I define the tenantID header per endpoint where bearerAuth is used 🤷Is there perhaps a better way to declare in which order the security checks should happen or would it be possible to adjust the templates in such a way that if security handlers are listed in groups an additional method would be generated for the
SecurityHandlerinterface which would get both values? I.e.Thanks!
Resources:
Beta Was this translation helpful? Give feedback.
All reactions