Skip to content
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

Add phone verification #11346

Merged
merged 0 commits into from
Aug 22, 2022
Merged

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Jul 13, 2022

Description

Adds phone number verification to make abusing Gitpod harder

Related Issue(s)

Fixes #11339

How to test

Release Notes

Documentation

Werft options:

  • /werft with-preview

@roboquat
Copy link
Contributor

@svenefftinge: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-sefftinge-add-phone-verification-11339.1 because the annotations in the pull request description changed
(with .werft/ from main)

@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch 2 times, most recently from 6d50167 to b1626e3 Compare July 14, 2022 08:42
if (!user.additionalData) {
user.additionalData = {};
}
if (!user.additionalData?.profile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this cascade could be wrapped in a User.updateProfile(partial: Partial<User.Profile>) method.


volumes = append(volumes,
corev1.Volume{
Name: "stripe-config",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy-n-paste: twilio-config

@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch from b1626e3 to 783f480 Compare July 14, 2022 17:25
@roboquat roboquat added size/XL and removed size/L labels Jul 14, 2022
@stale
Copy link

stale bot commented Jul 30, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale This issue/PR is stale and will be closed soon label Jul 30, 2022
@svenefftinge svenefftinge removed the meta: stale This issue/PR is stale and will be closed soon label Aug 8, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch from 783f480 to 8d2c434 Compare August 9, 2022 07:09
@roboquat roboquat added size/XXL and removed size/XL labels Aug 9, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch 2 times, most recently from 59c58c3 to cb6fefd Compare August 9, 2022 08:38
@gitguardian
Copy link

gitguardian bot commented Aug 9, 2022

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch 2 times, most recently from c214fa3 to e6664fc Compare August 16, 2022 07:21
@roboquat roboquat added size/XL and removed size/XXL labels Aug 16, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch 2 times, most recently from f157d5d to 887c0a2 Compare August 19, 2022 13:22
@svenefftinge svenefftinge requested review from a team August 19, 2022 14:27
@github-actions github-actions bot added team: delivery Issue belongs to the self-hosted team team: webapp Issue belongs to the WebApp team labels Aug 19, 2022
if (!this.config.twilioConfig) {
return false;
}
// if (!!user.additionalData?.lastVerificationTime) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have disabled this code, so it is easier to test multiple times. After a first review I would enable the code again to test the functionality.

// // we only want to ask new users, so if a user has ever started workspaces before, we trust them.
// // there might be a few false positives because all workspaces might have been deleted.
// const workspaces = await this.workspaceDB.findWorkspacesByUser(user.id);
// return workspaces.length !== 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geropl I think it makes sense to check for usage instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jep, that could work as an indicator, with a threshold > what we see from abusers.

@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch from 806714c to 7f2ab4d Compare August 19, 2022 14:44
@lucasvaltl
Copy link
Contributor

I'm assuming this is only "turned on" in SaaS?

@geropl
Copy link
Member

geropl commented Aug 22, 2022

/hold Due to this comment.

@svenefftinge While (un-)commenting this part of the code is not harmful we (WebApp) decided after a recent incident that we hide all "dev commits" behind Feature Flags: either the whole feature, or the "dev" part.

@geropl
Copy link
Member

geropl commented Aug 22, 2022

Starting to review now.

@svenefftinge
Copy link
Member Author

Thanks for the hold. FWIW the logic for "trusted" if going to get a bit more complex as we don't want to ask every new user. I'll try to judge trustworthiness also based on age of GitHub/GitLab account. The rest is ready for review.

@svenefftinge
Copy link
Member Author

svenefftinge commented Aug 22, 2022

/werft run

👍 started the job as gitpod-build-sefftinge-add-phone-verification-11339.14
(with .werft/ from main)

@geropl
Copy link
Member

geropl commented Aug 22, 2022

FWIW the logic for "trusted" if going to get a bit more complex as we don't want to ask every new user.

Jep! I guess that's also something we need/want to fine-tune as we go.

@svenefftinge
Copy link
Member Author

I'm spinning up a preview env and will update the env var on the server deployment, so trillio works.

@@ -6,7 +6,7 @@

const inspect: (object: any) => string = require("util").inspect; // undefined in frontend

let plainLogging: boolean = false; // set to true during development to get non JSON output
let plainLogging: boolean = true; // set to true during development to get non JSON output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be part of the "dev commit". Ideally, we should not need this, at all.

☁️ I think we had a de-jsonifier in the past. Could we use that together with yarn telepresence to avoid the need for this code change? Or maybe set an env var, or similar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll remove it as well, of course.

@@ -85,6 +85,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
getLoggedInUser(): Promise<User>;
getTerms(): Promise<Terms>;
updateLoggedInUser(user: Partial<User>): Promise<User>;
needsVerification(): Promise<boolean>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the method needsVerification()? I don't see it being used in the frontend (anymore). Feels like a leftover from an ealier version?


async mayStartWorkspace(
user: User,
date: Date = new Date(),
runningInstances: Promise<WorkspaceInstance[]>,
): Promise<MayStartWorkspaceResult> {
try {
const verification = await this.verificationService.needsVerification(user);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

public async sendPhoneNumberVerificationToken(ctx: TraceContext, phoneNumber: string): Promise<void> {
this.checkUser("sendPhoneNumberVerificationToken");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole concern feels like it should be part of the EE code-base, and this methods should be empty stubs (like

throw new ResponseError(ErrorCodes.EE_FEATURE, `Admin support is implemented in Gitpod's Enterprise Edition`);
).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reasoning you believe it should be EE? I have no concerns about making this open-source as I don't see how it could be something we want to monetize.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly because I thought it would not be that interesting. But have no hard feelings here!

💡 Then the binding should move to the other container: #11346 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should align on a general strategy / view so this is easier to decide for everyone. My take is to put as much as possible into the open-source version, so we have as little concerns as possible in the EE layer which makes code harder to grasp.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My take is to put as much as possible into the open-source version

That has been our strategy so far, yes, and I agree that it applies to phone verification as well. Put it into the "billing" basket at first, but it's unrelated. 💯 . Sorry for creating confusion here. 🧘

import { UserDB, WorkspaceDB } from "@gitpod/gitpod-db/lib";

@injectable()
export class VerificationService {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this class is part of the community edition, but only bound in the EE container.

As mentioned in GitpodServerImpl, I think it should move to the EE side entirely.

@@ -86,6 +87,7 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
bind(BitbucketAppSupport).toSelf().inSingletonScope();
bind(GitHubEnterpriseApp).toSelf().inSingletonScope();
bind(BitbucketServerApp).toSelf().inSingletonScope();
bind(VerificationService).toSelf().inSingletonScope();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was it's only bound for the EE edition. See other comments maybe adjust.

@@ -240,6 +253,22 @@ export namespace ConfigFile {
log.error("Could not load Stripe config", error);
}
}
let twilioConfig: Config["twilioConfig"];
log.info("loading twilio config");
if (!!env.TWILIO_CONFIG) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the fallback with the env var? If it's for dev purposes, I think the same can be achieved with pushing and manipulating a Secret.

☁️ We invested a bit of effort last year to move to a central config file which is far easier to reason about (not part of config file? Does not influence the config).

@svenefftinge
Copy link
Member Author

svenefftinge commented Aug 22, 2022

I have updated the server deployment, but noticed that there are still styling issues with the phone input. Strangely they are not there when running in dev mode 🙄

@geropl
Copy link
Member

geropl commented Aug 22, 2022

I have updated the server deployment, but noticed that there are still styling issues with the phone input.

Reminds me of last week, where a werft job "missed" to pick-up the "with-preview" config: build was green, but was still looking at old code.

Update: last job worked, though.

@svenefftinge svenefftinge merged commit 135bc0f into main Aug 22, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/add-phone-verification-11339 branch from 7f2ab4d to 135bc0f Compare August 22, 2022 08:43
@svenefftinge svenefftinge deleted the sefftinge/add-phone-verification-11339 branch August 22, 2022 08:43
@svenefftinge svenefftinge mentioned this pull request Aug 22, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold do-not-merge/release-note-label-needed size/XXL team: delivery Issue belongs to the self-hosted team team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Phone Verification for new Users
5 participants