Skip to content

[server] Remove OSS check (WEB-91) #17133

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 5 commits into from
Apr 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
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,6 @@ export class SubscriptionService {
});
}

/**
* Subscribes the given user to the "Professional Open Source" plan if they are not already
* @param user
* @param now
*/
async checkAndSubscribeToOssSubscription(user: User, now: Date): Promise<void> {
const userId = user.id;

// don't override but keep an existing, not-yet cancelled Prof. OSS subscription
const subs = await this.getNotYetCancelledSubscriptions(user, now.toISOString());
const uncancelledOssSub = subs.find(
(s) => s.planId === Plans.FREE_OPEN_SOURCE.chargebeeId && !s.cancellationDate,
);
if (uncancelledOssSub) {
log.debug({ userId: userId }, "already has professional OSS subscription");
return;
}

const subscription = await this.subscribe(userId, Plans.FREE_OPEN_SOURCE, undefined, now.toISOString());
log.debug({ userId: userId }, "create new OSS subscription", { subscription });
return;
}

async addCredit(userId: string, amount: number, date: string, expiryDate?: string): Promise<AccountEntry> {
const entry = <AccountEntry>{
userId,
Expand Down
3 changes: 0 additions & 3 deletions components/gitpod-db/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ import { ProjectDB } from "./project-db";
import { ProjectDBImpl } from "./typeorm/project-db-impl";
import { PersonalAccessTokenDB } from "./personal-access-token-db";
import { EntityManager } from "typeorm";
import { OssAllowListDB } from "./oss-allowlist-db";
import { OssAllowListDBImpl } from "./typeorm/oss-allowlist-db-impl";
import { TypeORMInstallationAdminImpl } from "./typeorm/installation-admin-db-impl";
import { InstallationAdminDB } from "./installation-admin-db";
import { TeamSubscription2DB } from "./team-subscription-2-db";
Expand Down Expand Up @@ -164,7 +162,6 @@ export const dbContainerModule = new ContainerModule((bind, unbind, isBound, reb
bind(EmailDomainFilterDB).to(EmailDomainFilterDBImpl).inSingletonScope();
bind(EduEmailDomainDB).to(EduEmailDomainDBImpl).inSingletonScope();
bind(LicenseDB).to(LicenseDBImpl).inSingletonScope();
bind(OssAllowListDB).to(OssAllowListDBImpl).inSingletonScope();
bind(UserToTeamMigrationService).toSelf().inSingletonScope();
bind(WorkspaceOrganizationIdMigration).toSelf().inSingletonScope();
bind(Synchronizer).toSelf().inSingletonScope();
Expand Down
12 changes: 0 additions & 12 deletions components/gitpod-db/src/oss-allowlist-db.ts

This file was deleted.

6 changes: 0 additions & 6 deletions components/gitpod-db/src/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ export class GitpodTableDescriptionProvider implements TableDescriptionProvider
deletionColumn: "deleted",
timeColumn: "_lastModified",
},
{
name: "d_b_oss_allow_list",
primaryKeys: ["identity"],
deletionColumn: "deleted",
timeColumn: "_lastModified",
},
{
name: "d_b_project_env_var",
primaryKeys: ["id", "projectId"],
Expand Down
24 changes: 0 additions & 24 deletions components/gitpod-db/src/typeorm/entity/db-oss-allowlist.ts

This file was deleted.

40 changes: 0 additions & 40 deletions components/gitpod-db/src/typeorm/oss-allowlist-db-impl.ts

This file was deleted.

17 changes: 0 additions & 17 deletions components/server/ee/src/user/user-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import { UserService, CheckSignUpParams, CheckTermsParams } from "../../../src/u
import { User } from "@gitpod/gitpod-protocol";
import { inject } from "inversify";
import { SubscriptionService } from "@gitpod/gitpod-payment-endpoint/lib/accounting";
import { OssAllowListDB } from "@gitpod/gitpod-db/lib/oss-allowlist-db";
import { HostContextProvider } from "../../../src/auth/host-context-provider";
import { Config } from "../../../src/config";

export class UserServiceEE extends UserService {
@inject(SubscriptionService) protected readonly subscriptionService: SubscriptionService;
@inject(OssAllowListDB) protected readonly OssAllowListDb: OssAllowListDB;
@inject(HostContextProvider) protected readonly hostContextProvider: HostContextProvider;
@inject(Config) protected readonly config: Config;

Expand All @@ -39,19 +37,4 @@ export class UserServiceEE extends UserService {

return true;
}

async checkAutomaticOssEligibility(user: User): Promise<boolean> {
const idsWithHost = user.identities
.map((id) => {
const hostContext = this.hostContextProvider.findByAuthProviderId(id.authProviderId);
if (!hostContext) {
return undefined;
}
const info = hostContext.authProvider.info;
return `${info.host}/${id.authName}`;
})
.filter((i) => !!i) as string[];

return this.OssAllowListDb.hasAny(idsWithHost);
}
}
14 changes: 0 additions & 14 deletions components/server/src/auth/login-completion-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ export class LoginCompletionHandler {
);
}

// Check for and automatically subscribe to Professional OpenSource subscription
/** no await */ this.checkForAndSubscribeToProfessionalOss(user).catch((err) => {
/** ignore */
});

response.redirect(returnTo);
}

Expand All @@ -115,15 +110,6 @@ export class LoginCompletionHandler {
}
}
}

protected async checkForAndSubscribeToProfessionalOss(user: User) {
const eligible = await this.userService.checkAutomaticOssEligibility(user);
log.debug({ userId: user.id }, "user eligible for OSS subscription?", { eligible });
if (!eligible) {
return;
}
await this.subscriptionService.checkAndSubscribeToOssSubscription(user, new Date());
}
}
export namespace LoginCompletionHandler {
export interface CompleteParams {
Expand Down
5 changes: 0 additions & 5 deletions components/server/src/user/user-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,6 @@ export class UserService {
// return !!accepted && (accepted.termsRevision === terms.revision);
}

async checkAutomaticOssEligibility(user: User): Promise<boolean> {
// EE implementation
return false;
}

async isBlocked(params: CheckIsBlockedParams): Promise<boolean> {
if (params.user && params.user.blocked) {
return true;
Expand Down