-
Notifications
You must be signed in to change notification settings - Fork 507
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
Ensure user store uses lowercased username for document id. #10369
Ensure user store uses lowercased username for document id. #10369
Conversation
state/user.go
Outdated
@@ -37,12 +37,14 @@ func userIDFromGlobalKey(key string) string { | |||
} | |||
|
|||
func (st *State) checkUserExists(name string) (bool, error) { | |||
nameToLower := strings.ToLower(name) |
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.
Personal preference.. but I don't like variables that sound like they're about actions in the future, when they're about the past. imo we're representing a nameLowerCase
rather than a nameToLower
.
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.
Yeah agreed, there was already code see addUser which named it this way. So I was going for consistency. I don't mind changing them all.
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.
It looks like the variables in those private methods were created 4 years ago. We probably won't hurt anyone's feelings by changing them now.
Maybe add to PR?
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.
General question only - do we know if our documentation specifies that user names are case insensitive?
Not sure. The user name validation allows upper case explicitly in it's regex and the add user logic already supports this (hence why the mongo ids are lowercased) |
5005ffd
to
9170356
Compare
|
Description of change
Not all user store operations correctly formatted the mongo document id.
This fixes the behaviour in all affected user state functions and add tests to ensure this behaviour works.
Previously
juju register
with a secret token failed because the update password didn't behave correctly when a username contained uppercase.QA steps
Adding a user and registering that user should succeed when the username contains uppercase.
Documentation changes
N/A
Bug reference
https://bugs.launchpad.net/juju/+bug/1833449