-
Notifications
You must be signed in to change notification settings - Fork 9
Fix expired tokens not refreshing & add info command to show user info
#12
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: dev
Are you sure you want to change the base?
Conversation
Add 'id' command to show user-id, as well as log it during authentication.
|
I can split this into two different PRs if you want, one for the fix and one for the feature - not sure how you like to manage changes :) |
| // return nil, fmt.Errorf(msg) | ||
| // } | ||
|
|
||
| return nil, nil |
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.
Having the interface returned here be nil causes the jwt.Parse method to always fail - if we want to parse the token without verifying we need to use ParseUnverified.
|
Could we change the |
Not sure |
|
I'm not entirely sure it's right to be under |
I can stand behind this to be honest, I think as it stands authenticate can be reached with out users, so it is a bit redundant to also have it inside of users. If we remove it from the user category, I think it would be okay to have id as a stand alone too. Maybe rename the command to user_id or potentially, current_user? |
id command to show user_idinfo command to show user info
|
As per discussion and PRVD-48, I've modified this to be |
| return &user, nil | ||
| } | ||
|
|
||
| return nil, fmt.Errorf("please authenticate to retrieve your user info") |
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.
should we prompt for authentication instead of error-ing out?
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.
Nothing else does - this should be consistent. We can change design in a new PR for all of the auth failures if desired, but this isn't the place to do that.
zk-bits
left a comment
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.
One minor comment, on design, lgtm otherwise.
|
Please squash all commits into one before merging. |
This is easily fixed by doing a "squash and merge" in GitHub - this will keep the commit history in this PR for future reference while the main branch only gets the one squashed commit. |
zk-bits
left a comment
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.
lgtm
isTokenExpiredwas not properly calling the JWT parser, and as a result an error was always returned and this led the function to always returnfalse.New command
infoadded that prints out the currently auth'd user's data. Also logs the User ID when callingauthenticate.Examples: