-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: use case-insensitive comparison for GitHub orgs to fix RBAC #2499 #4641
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -699,8 +699,8 @@ type org struct { | |
| // which inserts a bearer token as part of the request. | ||
| func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client, orgName string) ([]string, error) { | ||
| apiURL, groups := c.apiURL+"/user/teams", []string{} | ||
| warnedCaseMismatch := false | ||
| for { | ||
| // https://developer.github.com/v3/orgs/teams/#list-user-teams | ||
| var ( | ||
| teams []team | ||
| err error | ||
|
|
@@ -710,7 +710,17 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client, | |
| } | ||
|
|
||
| for _, t := range teams { | ||
| if t.Org.Login == orgName { | ||
| // GitHub org names are case-insensitive; the API returns canonical (lowercase) form. | ||
| // https://docs.github.com/en/rest/teams/teams?apiVersion=2026-03-10#list-teams-for-the-authenticated-user | ||
| if strings.EqualFold(t.Org.Login, orgName) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add tests for this edge-case?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nabokihms Added. Please let me know if you have any feedback on it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning is required if there is a case mismatch.
The warning will solve both.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. Let me know if you have any feedback on the wording. |
||
| if !warnedCaseMismatch && t.Org.Login != orgName { | ||
| c.logger.Warn( | ||
| "org name in config differs in case from GitHub canonical form; use lowercase in config to keep group claims consistent", | ||
| "org", orgName, | ||
| "canonical", t.Org.Login, | ||
| ) | ||
| warnedCaseMismatch = true | ||
| } | ||
| groups = append(groups, c.teamGroupClaims(t)...) | ||
| } | ||
| } | ||
|
|
||
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.
Seems good to me, but let's add the comment on why the comparison here is case-insensitive.
Also, it's kind of a breaking change for people who, for some reason, used an org with an upper case in their configs. Users from these orgs can log in now, but they could not before this change.
Uh oh!
There was an error while loading. Please reload this page.
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.
@nabokihms Added a comment and updated the link as well to go straight to the relevant API call.
RE: breaking change.
Potentially. I would think if you didn't want an org to have access you would have removed the org entirely rather than relying on the current case mismatch as security.
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.
@nabokihms thoughts?
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.
Nit: let's make the comment a bit more specific:
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.
Done. @nabokihms