Skip to content

Commit 1bf86ee

Browse files
committed
cleanup old redirect logic
1 parent 001903f commit 1bf86ee

File tree

2 files changed

+0
-31
lines changed

2 files changed

+0
-31
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,6 @@ export abstract class GenericAuthProvider implements AuthProvider {
302302
return;
303303
}
304304

305-
if (!this.loginCompletionHandler.isBaseDomain(request)) {
306-
// For auth requests that are not targetting the base domain, we redirect to the base domain, so they come with our cookie.
307-
log.info(`(${strategyName}) Auth request on subdomain, redirecting to base domain`, { clientInfo });
308-
const target = new URL(request.url, this.config.hostUrl.url.toString()).toString();
309-
response.redirect(target);
310-
return;
311-
}
312-
313305
if (isAlreadyLoggedIn) {
314306
if (!authFlow) {
315307
log.warn(

components/server/src/auth/login-completion-handler.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,6 @@ export class LoginCompletionHandler {
8686
);
8787
}
8888

89-
if (!this.isBaseDomain(request)) {
90-
// (GitHub edge case) If we got redirected here onto a sub-domain (e.g. api.gitpod.io), we need to redirect to the base domain in order to Set-Cookie properly.
91-
const secret = crypto
92-
.createHash("sha256")
93-
.update(user.id + this.config.session.secret)
94-
.digest("hex");
95-
const expirationDate = new Date(Date.now() + 1000 * 60); // 1 minutes
96-
const token = await this.otsServer.serveToken({}, secret, expirationDate);
97-
98-
reportLoginCompleted("succeeded_via_ots", "git");
99-
log.info(
100-
logContext,
101-
`User will be logged in via OTS on the base domain. (Indirect) redirect to: ${returnTo}`,
102-
);
103-
const baseDomainRedirect = this.config.hostUrl.asLoginWithOTS(user.id, token.token, returnTo).toString();
104-
response.redirect(baseDomainRedirect);
105-
return;
106-
}
107-
10889
// (default case) If we got redirected here onto the base domain of the Gitpod installation, we can just issue the cookie right away.
10990
const cookie = await this.session.createJWTSessionCookie(user.id);
11091
response.cookie(cookie.name, cookie.value, cookie.opts);
@@ -116,10 +97,6 @@ export class LoginCompletionHandler {
11697
response.redirect(returnTo);
11798
}
11899

119-
public isBaseDomain(req: express.Request): boolean {
120-
return req.hostname === this.config.hostUrl.url.hostname;
121-
}
122-
123100
public async updateAuthProviderAsVerified(hostname: string, user: User) {
124101
const hostCtx = this.hostContextProvider.get(hostname);
125102
log.info("Updating auth provider as verified", { hostname });

0 commit comments

Comments
 (0)