Skip to content
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
8 changes: 8 additions & 0 deletions components/server/src/auth/generic-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { SignInJWT } from "./jwt";
import { UserService } from "../user/user-service";
import { reportLoginCompleted } from "../prometheus-metrics";
import { TrustedValue } from "@gitpod/gitpod-protocol/lib/util/scrubbing";
import { isUserSignupBlockedBySunset } from "../util/featureflags";

/**
* This is a generic implementation of OAuth2-based AuthProvider.
Expand Down Expand Up @@ -431,6 +432,13 @@ export abstract class GenericAuthProvider implements AuthProvider {
};

if (VerifyResult.WithIdentity.is(flowContext)) {
// Check if signup is blocked by Classic PAYG sunset
if (await isUserSignupBlockedBySunset("anonymous", this.config.isDedicatedInstallation)) {
log.info(context, `(${strategyName}) Signup blocked by Classic PAYG sunset`, logPayload);
response.redirect(302, "https://app.ona.com/login");
return;
}

log.info(context, `(${strategyName}) Creating new user and completing login.`, logPayload);
// There is no current session, we need to create a new user because this
// identity does not yet exist.
Expand Down
16 changes: 16 additions & 0 deletions components/server/src/util/featureflags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,19 @@ export async function isUserLoginBlockedBySunset(user: User, isDedicatedInstalla
// Installation-owned users (no organizationId) are blocked
return true;
}

export async function isUserSignupBlockedBySunset(userId: string, isDedicatedInstallation: boolean): Promise<boolean> {
// Dedicated installations are never blocked
if (isDedicatedInstallation) {
return false;
}

const config = await getClassicPaygSunsetConfig(userId);

if (!config.enabled) {
return false;
}

// New users don't have roles/permissions or organizations yet, so we block all signups
return true;
}
Loading