Skip to content

Commit 5db8573

Browse files
committed
[server/auth] check for matching auth ID
1 parent fa8c626 commit 5db8573

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/server/src/auth/generic-auth-provider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,14 @@ export class GenericAuthProvider implements AuthProvider {
427427
if (currentGitpodUser) {
428428
// user is already logged in
429429

430+
// check for matching auth ID
431+
const currentIdentity = currentGitpodUser.identities.find(i => i.authProviderId === this.authProviderId);
432+
if (currentIdentity && currentIdentity.authId !== candidate.authId) {
433+
log.warn(`User is trying to connect with another provider identity.`, { ...defaultLogPayload, authUser, candidate, currentGitpodUser: User.censor(currentGitpodUser), clientInfo });
434+
done(AuthException.create("authId-mismatch", "Auth ID does not match with existing provider identity.", {}), undefined);
435+
return;
436+
}
437+
430438
// we need to check current provider authorizations first...
431439
try {
432440
await this.userService.asserNoTwinAccount(currentGitpodUser, this.host, this.authProviderId, candidate);

0 commit comments

Comments
 (0)