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

Reset password, state layer. #7740

Merged
merged 2 commits into from Aug 15, 2017
Merged

Conversation

anastasiamac
Copy link
Contributor

Description of change

This is part of the functionality to provide controller admins with ability to reset user passwords/re-issue login tokens.

QA steps

This is only one the layers, there is no full-stack funcationaliy yet. All unit tests pass.

Documentation changes

n/a
This is an internal addition atm.

Bug reference

Initial part for https://bugs.launchpad.net/juju/+bug/1657187

state/user.go Outdated
@@ -543,6 +540,61 @@ func (u *User) ensureNotDeleted() error {
return nil
}

// ResetPassword cleans up password related field.
Copy link
Contributor

Choose a reason for hiding this comment

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

ResetPassword clears the user's password (if there is one), and generates a new secret key for the user.
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

return nil, errors.Trace(err)
}
if u.IsDisabled() {
return nil, fmt.Errorf("user deactivated")
Copy link
Contributor

Choose a reason for hiding this comment

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

cannot reset password for disabled user?
or maybe add a DeferredAnnotate at the top of the function instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not convinced that this needs further clarification. The overall error that will come from here will be cannot reset password for user "bob": user deactivated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, I missed the fact that there's additional context below.

if err := u.st.db().Run(buildTxn); err != nil {
return nil, errors.Annotatef(err, "cannot reset password for user %q", u.Name())
}
u.doc.SecretKey = key
Copy link
Contributor

Choose a reason for hiding this comment

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

u.doc.PasswordHash = ""
u.doc.PasswordSalt = ""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! done :D

state/user.go Outdated
return key, nil
}

// generateSecretKey generates a random, 32-byte secret key. This can be used
Copy link
Contributor

Choose a reason for hiding this comment

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

can you you please delete the bit about the CA cert? we're not using it for that. not sure why it was in there before, probably copy pasta

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


key, err := u.ResetPassword()
c.Assert(err, jc.ErrorIsNil)
c.Assert(u.SecretKey(), gc.DeepEquals, key)
Copy link
Contributor

Choose a reason for hiding this comment

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

also check that PasswordValid("anything") fails here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added check.

@anastasiamac
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Aug 15, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit a801c19 into juju:develop Aug 15, 2017
@anastasiamac anastasiamac deleted the reset-pwd-state branch August 15, 2017 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants