Skip to content

[server] FIx missing User.fullName attribute for SSO users – EXP-365 #18445

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

Merged
merged 2 commits into from
Aug 7, 2023
Merged
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
11 changes: 10 additions & 1 deletion components/server/src/iam/iam-oidc-create-session-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export interface OIDCCreateSessionPayload {
Expiry: string; // "2023-01-10T12:00:00Z",
IssuedAt: string; // "2023-01-01T12:00:00Z",
};
/**
* https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
*/
claims: {
aud: string;
email: string;
Expand All @@ -80,10 +83,16 @@ export interface OIDCCreateSessionPayload {
hd?: string; // accepted domain, e.g. "gitpod.io"
iss: string; // "https://accounts.google.com"
locale: string; // e.g. "de"
/**
* End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
*/
name: string;
picture: string; // URL of avatar
/**
* Subject - Identifier for the End-User at the Issuer.
*/
sub: string; // "1234567890"
};
organizationId: string; // TODO(gpl) Remove once we implemented either SKIM, or a proper UserService
organizationId: string;
oidcClientConfigId: string;
}
3 changes: 3 additions & 0 deletions components/server/src/iam/iam-session-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class TestIamSessionApp {
createUser: (params) => {
return { id: "id-new-user" } as any;
},
updateUser: (userId, update) => {
return {} as any;
},
};
protected userAuthenticationMock: Partial<UserAuthentication> = {
findUserForLogin: async (params) => {
Expand Down
5 changes: 5 additions & 0 deletions components/server/src/iam/iam-session-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export class IamSessionApp {
primaryEmail: recent.primaryEmail,
lastSigninTime: new Date().toISOString(),
});
await this.userService.updateUser(user.id, {
id: user.id,
fullName: payload.claims.name,
});
}
}

Expand All @@ -141,6 +145,7 @@ export class IamSessionApp {
organizationId,
identity: { ...this.mapOIDCProfileToIdentity(payload), lastSigninTime: new Date().toISOString() },
userUpdate: (user) => {
user.fullName = claims.name;
user.name = claims.name;
user.avatarUrl = claims.picture;
},
Expand Down