Skip to content

fix: use case-insensitive comparison for GitHub orgs to fix RBAC #2499#4641

Open
venkatamutyala wants to merge 2 commits intodexidp:masterfrom
venkatamutyala:fix/case-insensitive-comparison
Open

fix: use case-insensitive comparison for GitHub orgs to fix RBAC #2499#4641
venkatamutyala wants to merge 2 commits intodexidp:masterfrom
venkatamutyala:fix/case-insensitive-comparison

Conversation

@venkatamutyala
Copy link
Copy Markdown

@venkatamutyala venkatamutyala commented Mar 13, 2026

Overview

Previously, configuring orgs: [{name: "MyOrg"}] when the actual org was myorg would silently return empty groups, causing users to be denied access despite being valid org members

What this PR does / why we need it

adds case-insensitive comparison for GitHub organization names

Closes #2499

Special notes for your reviewer

For testing, I did a docker build, updated my dex install to use this custom image, i changed my github org to have mixed casing and then tested the login via dex github connector and had no issues.

Copy link
Copy Markdown
Member

@nabokihms nabokihms left a comment

Choose a reason for hiding this comment

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

I have one comment and a question. The original issue was about the org name, but this PR fixes team names, not the org name. Am I missing something?


for _, t := range teams {
if t.Org.Login == orgName {
if strings.EqualFold(t.Org.Login, orgName) {
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Author

@venkatamutyala venkatamutyala Mar 13, 2026

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@nabokihms thoughts?

Copy link
Copy Markdown
Member

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:

// GitHub org names are case-insensitive; the API returns canonical (lowercase) form.
// [link-to-the-API-doc]

Signed-off-by: Venkat <venkata@venkatamutyala.com>
@venkatamutyala venkatamutyala force-pushed the fix/case-insensitive-comparison branch from f55c0d0 to 90afcad Compare March 13, 2026 21:20
@venkatamutyala
Copy link
Copy Markdown
Author

I have one comment and a question. The original issue was about the org name, but this PR fixes team names, not the org name. Am I missing something?

@nabokihms I think the function is a little misleading. It's fetching the users teams across all orgs and then filters them by org name. It's the comparison on org name where it's silently failing because it's case sensitive. I updated the link to the API call as well in my most recent commit

@nabokihms nabokihms added the release-note/bug-fix Release note: Bug Fixes label Mar 30, 2026
Copy link
Copy Markdown
Member

@nabokihms nabokihms left a comment

Choose a reason for hiding this comment

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

Some suggestions


for _, t := range teams {
if t.Org.Login == orgName {
if strings.EqualFold(t.Org.Login, orgName) {
Copy link
Copy Markdown
Member

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:

// GitHub org names are case-insensitive; the API returns canonical (lowercase) form.
// [link-to-the-API-doc]

for _, t := range teams {
if t.Org.Login == orgName {
// case-insensitive check to avoid silent failures when config casing is different than GitHub
if strings.EqualFold(t.Org.Login, orgName) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you also add tests for this edge-case?

for _, t := range teams {
if t.Org.Login == orgName {
// case-insensitive check to avoid silent failures when config casing is different than GitHub
if strings.EqualFold(t.Org.Login, orgName) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The warning is required if there is a case mismatch.

  1. In the final groups, the ID token org name will be in lowercase, so we need to warn users that it was converted to lowercase
  2. we need to suggest using lowercase orgs in the config

The warning will solve both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Org definition using incorrect case can silently fail to pull github groups.

2 participants