JWT, KeyAuth, CSRF multivalue extractors #2060
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Authentication
header with valueBearer xxxx
but your intracture has upstream proxy that adds Basic authentication also. Now even if you fill basic auth in browser and your application sends requests with JWT token you would be in trouble as previously JWT middleware knows only to extract firstAuthentication
header value - which could be JWT token but could be also Basic Auth. This change allows extractor to return all those header values and run JWT token checks or validation for Keyauth on them.NoErrorContinuesExecution
to JWT and KeyAuth middleware to allow continuing executionnext(c)
when error handler decides to swallow the error (returns nil). Usecase: This is useful in cases when portion of your site/api is publicly accessible and has extra features for authorized users. In that case you can use ErrorHandlerWithContext to set default public JWT token value to request and continue with handler chain. Note: this is similar to Allow JWT middleware to gracefully fail #2048p.s. there are ugly error handling parts just to preserve similar/same errors that those middlewares previously returned. Unfortunately all these 3 are quite inconsistent how they do error handling - JWT has 2 generic types. Keyauth has specific error values.