-
Notifications
You must be signed in to change notification settings - Fork 377
WIP #3487
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
base: main
Are you sure you want to change the base?
WIP #3487
Conversation
Uses a better name than decodePayload. Adds some test cases, and a function doc. The function logic remains the same.
Explain the type of time in the function name to make it a bit clearer. The exp field is in UTC, so we return UTC. Generally all server side code should be using UTC rather than converting to a local time zone. Add some documentation and tests with edge cases.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: illume The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces an auth package to encapsulate base64 JSON decoding and token expiry extraction logic formerly located in headlamp.go, and replaces the inline implementations in headlamp.go with calls to the new functions.
- Adds auth-related functionality in backend/pkg/auth (DecodeBase64JSON and GetExpiryUnixTimeUTC)
- Introduces comprehensive tests in backend/pkg/auth/auth_test.go
- Refactors headlamp.go to use the new auth package utilities
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
backend/pkg/auth/auth.go | New auth package with functions for decoding base64 JSON and extracting token expiry |
backend/pkg/auth/auth_test.go | Unit tests for the new auth package functions |
backend/cmd/headlamp.go | Refactored to remove duplicate code by using the new auth package functions |
Comments suppressed due to low confidence (1)
backend/pkg/auth/auth.go:46
- [nitpick] Consider rephrasing the function documentation for 'GetExpiryUnixTimeUTC' for improved clarity. For example, use: 'Extracts the expiry Unix time, in UTC, from the token payload's "exp" field.'
func GetExpiryUnixTimeUTC(tokenPayload map[string]interface{}) (time.Time, error) {
WIP