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

Ignore duplicate groups returned by the Microsoft Graph API #387

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

adombeck
Copy link
Contributor

@adombeck adombeck commented Feb 12, 2025

It's not clear in which case the Graph API returns multiple groups with the same name (or the same group twice), but we've seen it happen in ubuntu/authd#789.

Closes ubuntu/authd#789
UDENG-6030

@adombeck
Copy link
Contributor Author

adombeck commented Feb 12, 2025

AFAICT, we don't have any tests which test the GetUserInfo implementation of the msentraid provider (and the getGroups function called by it). I created a Jira issue and added it to the next pulse: https://warthogs.atlassian.net/browse/UDENG-6033

@adombeck adombeck marked this pull request as ready for review February 12, 2025 16:24
@adombeck adombeck requested a review from a team as a code owner February 12, 2025 16:24
@@ -186,35 +186,75 @@ func (p Provider) getGroups(token *oauth2.Token, msgraphHost string) ([]info.Gro
}

var groups []info.Group
var msGroupNames []string
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't be better to use a set for this e.g. a map[string]struct{}? And maybe use unicode.SimpleFold to add both cases there?

Copy link
Contributor Author

@adombeck adombeck Feb 13, 2025

Choose a reason for hiding this comment

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

To be able to include the unfolded group names in the log message, we need to store it unfolded. We could use a map[string]string for that, mapping the folded name to the unfolded one, but tbh I'm not sure the performance benefit is worth the effort

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't be better to use a set for this e.g. a map[string]struct{}?

Or do you want to store the unfolded name in that map? Then we would still need to iterate over it so there is no performance benefit

@adombeck adombeck requested a review from 3v1n0 February 13, 2025 17:44
@adombeck
Copy link
Contributor Author

@3v1n0 ping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants