Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

auth: Make username from email deduplication dotcom only#62747

Merged
eseliger merged 1 commit into
mainfrom
es/05-17-authmakeusernamefromemaildeduplicationdotcomonly
May 17, 2024
Merged

auth: Make username from email deduplication dotcom only#62747
eseliger merged 1 commit into
mainfrom
es/05-17-authmakeusernamefromemaildeduplicationdotcomonly

Conversation

@eseliger

@eseliger eseliger commented May 16, 2024

Copy link
Copy Markdown
Member

https://github.com/sourcegraph/sourcegraph/pull/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 https://github.com/sourcegraph/sourcegraph/issues/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 https://github.com/sourcegraph/sourcegraph/issues/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
Copy Markdown
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 a team, bobheadxi, chrsmith, kalanchan and unknwon May 16, 2024 23:35
Comment thread internal/auth/userpasswd/handlers.go Outdated

@bobheadxi bobheadxi left a comment

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.

Test cases LGTM

@bobheadxi

bobheadxi commented May 17, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
https://github.com/sourcegraph/sourcegraph/pull/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 https://github.com/sourcegraph/sourcegraph/issues/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
Copy Markdown
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
@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
https://github.com/sourcegraph/sourcegraph/pull/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 https://github.com/sourcegraph/sourcegraph/issues/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)

https://github.com/sourcegraph/sourcegraph/pull/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 https://github.com/sourcegraph/sourcegraph/issues/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>

@unknwon unknwon left a comment

Copy link
Copy Markdown
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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