Skip to content

Commit

Permalink
Lift the SCM identity restriction for org owned accounts (#19606)
Browse files Browse the repository at this point in the history
The restriction of SCM identities doesn't apply to organization owned accounts which were
created through OIDC SSO, because this identity is not used to create/find the account of a user.

Hint: with this restriction lifted, the subsequent call to `#updateUserOnLogin` would always add/update
the SCM identity for the given `currentUser` if it's owned by an organization.
  • Loading branch information
AlexTugarev authored Apr 9, 2024
1 parent 17942b8 commit faebc73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/server/src/auth/generic-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ export abstract class GenericAuthProvider implements AuthProvider {

// we need to check current provider authorizations first...
try {
await this.userAuthentication.asserNoTwinAccount(
await this.userAuthentication.assertNoTwinAccount(
currentGitpodUser,
this.host,
this.authProviderId,
Expand Down
12 changes: 11 additions & 1 deletion components/server/src/user/user-authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,17 @@ export class UserAuthentication {
await this.userDb.storeUser(user);
}

async asserNoTwinAccount(currentUser: User, authHost: string, authProviderId: string, candidate: Identity) {
async assertNoTwinAccount(currentUser: User, authHost: string, authProviderId: string, candidate: Identity) {
if (User.isOrganizationOwned(currentUser)) {
/**
* The restriction of SCM identities doesn't apply to organization owned accounts which were
* created through OIDC SSO because this identity is not used to create/find the account of a user.
*
* Hint: with this restriction lifted, the subsequent call to `#updateUserOnLogin` would always add/update
* the SCM identity for the given `currentUser` if it's owned by an organization.
*/
return;
}
if (currentUser.identities.some((i) => Identity.equals(i, candidate))) {
return; // same user => OK
}
Expand Down

0 comments on commit faebc73

Please sign in to comment.