Skip to content

Conversation

@blam23
Copy link

@blam23 blam23 commented Sep 8, 2021

isTokenExpired was not properly calling the JWT parser, and as a result an error was always returned and this led the function to always return false.

New command info added that prints out the currently auth'd user's data. Also logs the User ID when calling authenticate.

Examples:

$ prvd info
Current User:
 ID:          fe6341f0-2234-4a6a-be84-41deee38c46b
 Name:        Lucas Rodriguez
 First Name:  Lucas
 Last Name:   Rodriguez
 Email:       lucas@provide.services
$ prvd authenticate
Email: <email>
Password: <pass>
2021/09/08 14:00:16 Authentication successful.
2021/09/08 14:00:16 User ID: fe6341f0-2234-4a6a-be84-41deee38c46b

Add 'id' command to show user-id, as well as log it during authentication.
@blam23
Copy link
Author

blam23 commented Sep 8, 2021

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
Copy link
Author

@blam23 blam23 Sep 8, 2021

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.

@zk-bits
Copy link
Contributor

zk-bits commented Sep 8, 2021

Could we change the prvd command from prvd id to prvd users id

@blam23
Copy link
Author

blam23 commented Sep 8, 2021

Could we change the prvd command from prvd id to prvd users id

Not sure users makes the most sense - we're getting the ID for whoever is logged in, not doing any sort of user management?

@blam23
Copy link
Author

blam23 commented Sep 8, 2021

I'm not entirely sure it's right to be under users as I would imagine that's for user management (nothing to do with auth imo) but I've created commit 1fea400 that turns it to prvd users id and provides a prompt option if you do prvd users:

$ prvd users
Use the arrow keys to navigate: ↓ ↑ → ←
? What would you like to do:
  ▸ Create
    Authenticate
    Show current authorized user's ID
$ prvd users id
fe6341f0-2234-4a6a-be84-41deee38c46b

@zk-bits
Copy link
Contributor

zk-bits commented Sep 8, 2021

I'm not entirely sure it's right to be under users as I would imagine that's for user management (nothing to do with auth imo) but I've created commit 1fea400 that turns it to prvd users id and provides a prompt option if you do prvd users:

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?

@blam23 blam23 changed the title Fix expired tokens not refreshing & add id command to show user_id Fix expired tokens not refreshing & add info command to show user info Sep 8, 2021
@blam23
Copy link
Author

blam23 commented Sep 8, 2021

As per discussion and PRVD-48, I've modified this to be prvd info which shows data about the user.

@blam23 blam23 closed this Sep 8, 2021
@blam23 blam23 reopened this Sep 8, 2021
return &user, nil
}

return nil, fmt.Errorf("please authenticate to retrieve your user info")
Copy link
Contributor

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?

Copy link
Author

@blam23 blam23 Oct 12, 2021

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.

Copy link
Contributor

@zk-bits zk-bits left a 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.

@zk-bits
Copy link
Contributor

zk-bits commented Oct 11, 2021

Please squash all commits into one before merging.

@blam23
Copy link
Author

blam23 commented Oct 12, 2021

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 zk-bits self-requested a review October 12, 2021 13:36
Copy link
Contributor

@zk-bits zk-bits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants