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

auth: Make username from email deduplication dotcom only #62747

Merged

Conversation

eseliger
Copy link
Member

@eseliger eseliger commented May 16, 2024

#60339 introduced a new behavior that would always add a random suffix to usernames that are derived from email addresses.
The reason behind it seems to be that on dotcom, emails are from various domains and there are a lot of duplicates usually, and a lot of names that trigger our suspiciousness detection, like me@sourcegraph.com or me@sgdev.org.

For customer instances, this is not a real risk, and because of historic reasons, we depend on the username to be exactly what was given by the auth provider, so that bitbucket server permission syncing can work.
So this change for customer instances caused #62676.

To simplify the fix for this and make sure it can land in the next patch release, I opted for making this dotcom specific for now, as that's the least invasive change we can make.

Closes #62676

Test plan:

Created a new SAML application in Okta dev and lined that to my local instance.
A new user for erik@sourcegraph.com on main was called erik-acbdef after signup.
On this branch, with everything reset to fresh, a new user for erik@sourcegraph.com is called erik.
This should fix the bitbucket perms syncing issue.

@cla-bot cla-bot bot added the cla-signed label May 16, 2024
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @eseliger and the rest of your teammates on Graphite Graphite

@github-actions github-actions bot added team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all labels May 16, 2024
@eseliger eseliger force-pushed the es/05-17-authmakeusernamefromemaildeduplicationdotcomonly branch from a62aefd to 12fb2ad Compare May 16, 2024 23:32
@eseliger eseliger added backport/customer-critical Patch to critical bugs that negatively impact customer happiness backport 5.4.0 label used to backport PRs to the 5.4.0 release branch labels May 16, 2024 — with Graphite App
@eseliger eseliger marked this pull request as ready for review May 16, 2024 23:35
@eseliger eseliger requested review from bobheadxi, chrsmith, kalanchan, unknwon and a team May 16, 2024 23:35
Copy link
Member

@bobheadxi bobheadxi left a comment

Choose a reason for hiding this comment

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

Test cases LGTM

@bobheadxi
Copy link
Member

bobheadxi commented May 17, 2024

because of historic reasons, we depend on the username to be exactly what was given by the auth provider, so that bitbucket server permission syncing can work.

Is this the case for any of the other permissions sources? Should we document the dependency in the docstring of NormalizeUsername? Should this even be a // 🚨 SECURITY: -worthy docstring, as it has implications on permissions enforcement?

(Security team has an alert set up on changes to code attached to // 🚨 SECURITY: docstirngs IIRC, so that might be good visibility to changes to this function)

@eseliger eseliger force-pushed the es/05-17-authmakeusernamefromemaildeduplicationdotcomonly branch from 12fb2ad to 1a8feb6 Compare May 17, 2024 00:21
@eseliger
Copy link
Member Author

Is this the case for any of the other permissions sources? Should we document the dependency in the docstring of NormalizeUsername? Should this even be a // 🚨 SECURITY: -worthy docstring, as it has implications on permissions enforcement?

I think so, bitbucket server is the only one I'm aware of that has this restriction. They didn't have oauth support in the past, but they added it 1.5y ago - it's somewhere on our roadmap to finally switch to that and get rid of this hack with matching usernames.

If this is security worthy: Maybe? I can add a quick sentence about bitbucket but not sure if this should trigger an alert for the security team.

@eseliger
Copy link
Member Author

Added that comment

@eseliger eseliger force-pushed the es/05-17-authmakeusernamefromemaildeduplicationdotcomonly branch from 4a1f219 to 22830f2 Compare May 17, 2024 00:48
#60339 introduced a new behavior that would always add a random suffix to usernames that are derived from email addresses.
The reason behind it seems to be that on dotcom, emails are from various domains and there are a lot of duplicates usually, and a lot of names that trigger our suspiciousness detection, like me@sourcegraph.com or me@sgdev.org.

For customer instances, this is not a real risk, and because of historic reasons, we depend on the username to be exactly what was given by the auth provider, so that bitbucket server permission syncing can work.
So this change for customer instances caused #62676.

To simplify the fix for this and make sure it can land in the next patch release, I opted for making this dotcom specific for now, as that's the least invasive change we can make.

Test plan:

Created a new SAML application in Okta dev and lined that to my local instance.
A new user for `erik@sourcegraph.com` on main was called `erik-acbdef` after signup.
On this branch, with everything reset to fresh, a new user for `erik@sourcegraph.com` is called `erik`.
This should fix the bitbucket perms syncing issue.
@eseliger eseliger force-pushed the es/05-17-authmakeusernamefromemaildeduplicationdotcomonly branch from 22830f2 to 73af069 Compare May 17, 2024 12:46
@eseliger
Copy link
Member Author

I will merge this to make sure we get it in for Mondays patch release in time, but happy to follow up on further comments.

@eseliger eseliger merged commit 663a74a into main May 17, 2024
11 of 12 checks passed
@eseliger eseliger deleted the es/05-17-authmakeusernamefromemaildeduplicationdotcomonly branch May 17, 2024 12:56
sourcegraph-release-bot pushed a commit that referenced this pull request May 17, 2024
#60339 introduced a new behavior that would always add a random suffix to usernames that are derived from email addresses.
The reason behind it seems to be that on dotcom, emails are from various domains and there are a lot of duplicates usually, and a lot of names that trigger our suspiciousness detection, like me@sourcegraph.com or me@sgdev.org.

For customer instances, this is not a real risk, and because of historic reasons, we depend on the username to be exactly what was given by the auth provider, so that bitbucket server permission syncing can work.
So this change for customer instances caused #62676.

To simplify the fix for this and make sure it can land in the next patch release, I opted for making this dotcom specific for now, as that's the least invasive change we can make.

Test plan:

Created a new SAML application in Okta dev and lined that to my local instance.
A new user for `erik@sourcegraph.com` on main was called `erik-acbdef` after signup.
On this branch, with everything reset to fresh, a new user for `erik@sourcegraph.com` is called `erik`.
This should fix the bitbucket perms syncing issue.

(cherry picked from commit 663a74a)
jdpleiness pushed a commit that referenced this pull request May 17, 2024
…only (#62760)

auth: Make username from email deduplication dotcom only (#62747)

#60339 introduced a new behavior that would always add a random suffix to usernames that are derived from email addresses.
The reason behind it seems to be that on dotcom, emails are from various domains and there are a lot of duplicates usually, and a lot of names that trigger our suspiciousness detection, like me@sourcegraph.com or me@sgdev.org.

For customer instances, this is not a real risk, and because of historic reasons, we depend on the username to be exactly what was given by the auth provider, so that bitbucket server permission syncing can work.
So this change for customer instances caused #62676.

To simplify the fix for this and make sure it can land in the next patch release, I opted for making this dotcom specific for now, as that's the least invasive change we can make.

Test plan:

Created a new SAML application in Okta dev and lined that to my local instance.
A new user for `erik@sourcegraph.com` on main was called `erik-acbdef` after signup.
On this branch, with everything reset to fresh, a new user for `erik@sourcegraph.com` is called `erik`.
This should fix the bitbucket perms syncing issue.

(cherry picked from commit 663a74a)

Co-authored-by: Erik Seliger <erikseliger@me.com>
Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/customer-critical Patch to critical bugs that negatively impact customer happiness backport 5.4.0 label used to backport PRs to the 5.4.0 release branch cla-signed team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Username normalization breaks repo permissions
4 participants