Skip to content

Commit 517f3ae

Browse files
Merge pull request #8331 from sagemathinc/fix-sso-separator
sso/auth: fix silly mistake in e879895
2 parents 3f8fe31 + b70fac3 commit 517f3ae

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

src/packages/server/auth/sso/types.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,17 @@ export interface StrategyConf {
6868
};
6969
auth_opts?: AuthenticateOptions;
7070
// return type has to partially fit with passport_login
71-
login_info: {
72-
id: string | LoginInfoDerivator<string>; // id is required!
73-
first_name?: string | LoginInfoDerivator<string>;
74-
last_name?: string | LoginInfoDerivator<string>;
75-
full_name?: string | LoginInfoDerivator<string>;
76-
emails?: string | LoginInfoDerivator<string[]>;
77-
};
71+
login_info: LoginInfo;
7872
userinfoURL?: string; // OAuth2, to get a profile
7973
update_on_login?: boolean; // if true, update the user's profile on login
8074
cookie_ttl_s?: number; // how long the remember_me cookied lasts (default is a month or so)
8175
}
76+
77+
export type LoginInfo = Readonly<{
78+
id: string | LoginInfoDerivator<string>; // id is required!
79+
first_name?: string | LoginInfoDerivator<string>;
80+
last_name?: string | LoginInfoDerivator<string>;
81+
full_name?: string | LoginInfoDerivator<string>;
82+
emails?: string | LoginInfoDerivator<string[]>;
83+
_sep?: string;
84+
}>;

src/packages/server/hub/auth.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { addUserProfileCallback } from "@cocalc/server/auth/sso/oauth2-user-prof
5757
import { PassportLogin } from "@cocalc/server/auth/sso/passport-login";
5858
import {
5959
InitPassport,
60+
LoginInfo,
6061
PassportManagerOpts,
6162
StrategyConf,
6263
StrategyInstanceOpts,
@@ -144,7 +145,7 @@ interface HandleReturnOpts {
144145
type: PassportTypes;
145146
update_on_login: boolean;
146147
cookie_ttl_s: number | undefined;
147-
login_info;
148+
login_info: LoginInfo;
148149
}
149150

150151
export class PassportManager {
@@ -656,9 +657,11 @@ export class PassportManager {
656657
site_url: this.site_url,
657658
};
658659

659-
const dotInstance = this.getDot(login_info);
660+
const dotInstance =
661+
typeof login_info._sep === "string" ? new dot(login_info._sep) : dot;
660662

661663
for (const k in login_info) {
664+
if (k === "_sep") continue; // used above, not useful here
662665
const v = login_info[k];
663666
const param: string | string[] =
664667
typeof v == "function"
@@ -690,18 +693,6 @@ export class PassportManager {
690693
};
691694
}
692695

693-
private getDot(login_info): DotObject.Dot {
694-
// if login_info contains a key "_delimiter", take it from that object and remove it
695-
// then instantiate dot with that delimiter and use it to pick the values
696-
if (typeof login_info._sep === "string") {
697-
const sep = login_info._sep;
698-
delete login_info._sep;
699-
return new dot(sep);
700-
} else {
701-
return dot;
702-
}
703-
}
704-
705696
// right now, we only set this for OAauth2 (SAML knows what to do on its own)
706697
// This does not encode any information for now.
707698
private setState(

0 commit comments

Comments
 (0)