Skip to content
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

Issue39 auth save token #41

Merged
merged 5 commits into from
May 14, 2020
Merged

Issue39 auth save token #41

merged 5 commits into from
May 14, 2020

Conversation

coleshaw
Copy link
Collaborator

#39

Note that this is on top of your graft-repair-hmac branch, and not on top of master.

Adds a token attribute to the User class, and passes that data in during the Auth process (plus for TestAuth).

@coleshaw coleshaw requested a review from graft May 13, 2020 19:41
@graft graft changed the base branch from graft-repair-hmac to master May 13, 2020 22:32
lib/etna/auth.rb Outdated
@@ -77,6 +77,7 @@ def approve_user(request)

begin
payload, header = application.sign.jwt_decode(token)
payload['token'] = token
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure the payload will never contain the parameter 'token' in the future? Can we instead pass the token as an optional second argument to Etna::User.new?

@@ -37,6 +37,12 @@ class Server < Etna::Server; end
expect(user).to be_a(Etna::User)
expect(user.is_admin?('labors')).to be_truthy
expect(user.can_edit?('constellations')).to be_falsy
expect(user.token).to eq(Base64.strict_encode64({
email: 'janus@two-faces.org',
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be replaced with the same hash as above in a variable.

expect(u.token).to eq('xyz123randomtoken')
end

it 'returns basic user info without token param' do
Copy link
Contributor

Choose a reason for hiding this comment

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

This first test is barely necessary, two of these is too much methinks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't super confident I had the syntax right for the optional part, so wanted an objective validation :-)

@graft
Copy link
Contributor

graft commented May 14, 2020

Seems fine to merge this.

@coleshaw coleshaw merged commit ec271a9 into master May 14, 2020
@coleshaw coleshaw deleted the issue39-Auth-save-token branch May 14, 2020 11:43
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.

2 participants