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

Compare groups case-insensitively at login time #3240

Merged
merged 2 commits into from
Aug 25, 2017

Conversation

jefferai
Copy link
Member

Okta groups case-insensitive but preserving.

@jefferai jefferai added this to the 0.8.2 milestone Aug 25, 2017
@jefferai
Copy link
Member Author

All test changes pass (and fail on the previous code).

@@ -84,6 +84,11 @@ func (b *backend) Login(req *logical.Request, username string, password string)
var allGroups []string
// Import the custom added groups from okta backend
user, err := b.User(req.Storage, username)
if err != nil {
if b.Logger().IsDebug() {
Copy link
Member

Choose a reason for hiding this comment

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

Sort of unrelated, but why do we need to check the logger's level? Does it not respect the level set with SetLevel() so that logger.Debug() doesn't print if the logger is set at a higher level?

case-insensitive. New groups will be written in lowercase.
return nil, "", err
}
for _, groupName := range entries {
if strings.ToLower(groupName) == strings.ToLower(n) {
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just look at group/+ strings.ToLower(n) and avoid looking at all the entries?

Copy link
Member Author

Choose a reason for hiding this comment

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

That will only get us one possible capitalization. So if you have written "GroupFoo" before and now try to write "Groupfoo", you won't find it. With the current logic, you will.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it!

Copy link
Member

@vishalnayak vishalnayak left a comment

Choose a reason for hiding this comment

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

LGTM!

@jefferai jefferai merged commit 3416363 into master Aug 25, 2017
@jefferai jefferai deleted the okta-groups-case-insensitive branch August 25, 2017 18:48
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.

3 participants