Add support for authenticating requests using tokens in the Authorization header#93
Open
acvigue wants to merge 5 commits intolukaszraczylo:mainfrom
Open
Add support for authenticating requests using tokens in the Authorization header#93acvigue wants to merge 5 commits intolukaszraczylo:mainfrom
acvigue wants to merge 5 commits intolukaszraczylo:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces support for authenticating requests using bearer tokens in the
Authorizationheader, allowing for stateless session synthesis without relying on cookies. It adds a new method to create in-memory session data from validated access tokens and includes comprehensive unit tests to verify correct behavior and error handling. The changes improve flexibility and security for downstream components that expect session-backed data.Bearer token authentication and session synthesis:
ServeHTTPinmiddleware.goto detect bearer tokens in theAuthorizationheader, verify them, and synthesize a session for downstream processing. If the token is invalid or missing, an error response is sent. ([middleware.goR83-R111](https://github.com/lukaszraczylo/traefikoidc/pull/93/files#diff-02f50901140d6057da6310a106670552aa766a093efbc2200fb34c099b762131R83-R111))CreateSessionFromAccessTokeninsession.go, which constructs a synthetic, in-memorySessionDataobject from a validated JWT access token. This method parses claims, ensures essential fields (like email) are present, and initializes session state without cookie persistence. ([session.goR862-R1033](https://github.com/lukaszraczylo/traefikoidc/pull/93/files#diff-3d4a6b7d54b5107bc5694b7a06383f9ec4c68f9abe43ba0942f5d970f3a8ccacR862-R1033))Testing and validation:
session_test.goto verify session creation from valid access tokens, including checks for authentication, email extraction, token storage, and session cleanliness. ([session_test.goR209-R283](https://github.com/lukaszraczylo/traefikoidc/pull/93/files#diff-f27c62978dcbd8717b591269e831e3cc0eec4fbdb8fbf53f66435cd8450c4557R209-R283))[session_test.goR209-R283](https://github.com/lukaszraczylo/traefikoidc/pull/93/files#diff-f27c62978dcbd8717b591269e831e3cc0eec4fbdb8fbf53f66435cd8450c4557R209-R283))