auth: Make username from email deduplication dotcom only#62747
Conversation
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a62aefd to
12fb2ad
Compare
Is this the case for any of the other permissions sources? Should we document the dependency in the docstring of (Security team has an alert set up on changes to code attached to |
12fb2ad to
1a8feb6
Compare
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. |
|
Added that comment |
4a1f219 to
22830f2
Compare
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.
22830f2 to
73af069
Compare
|
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. |
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)
…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>

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.comon main was callederik-acbdefafter signup.On this branch, with everything reset to fresh, a new user for
erik@sourcegraph.comis callederik.This should fix the bitbucket perms syncing issue.