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

OIDC: Use 'sub' claim to identify the user #759 #772

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/server/lib/Authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,14 @@ export async function addRequestUser(
// A user record will be created automatically for emails we've never seen before.
if (profile && !mreq.userId) {
const userOptions: UserOptions = {};
if (profile?.loginMethod === 'Email + Password') {
if (profile.loginMethod === 'Email + Password') {
// Link the session authSubject, if present, to the user. This has no effect
// if the user already has an authSubject set in the db.
userOptions.authSubject = sessionUser.authSubject;
}
if (profile.connectId) {
await dbManager.ensureExternalUser(profile);
}
const user = await dbManager.getUserByLoginWithRetry(profile.email, {profile, userOptions});
if (user) {
mreq.user = user;
Expand Down
4 changes: 3 additions & 1 deletion app/server/lib/OIDCConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ export class OIDCConfig {
private _makeUserProfileFromUserInfo(userInfo: UserinfoResponse): Partial<UserProfile> {
return {
email: String(userInfo[ this._emailPropertyKey ]),
name: this._extractName(userInfo)
name: this._extractName(userInfo),
connectId: userInfo.sub,
loginMethod: 'External',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I assumed the loginMethod: 'External' is meant to be used for such case.

I can also add this property for UserProfiles created SAMLConfig.ts if that's relevant.

};
}

Expand Down