Skip to content

feat: remove HCAPTCHA #152

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 7 commits into from
Jan 29, 2025
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
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use official node image as the base image
FROM --platform=$BUILDPLATFORM node:16 as build
FROM --platform=$BUILDPLATFORM node:16-slim AS build

# Set the working directory
WORKDIR /usr/local/app
Expand All @@ -8,7 +8,9 @@ WORKDIR /usr/local/app
COPY package.json package-lock.json ./

# Install all the dependencies
RUN npm install
RUN --mount=type=cache,target=/usr/local/app/.npm \
npm set cache /usr/local/app/.npm && \
npm install

# Add the source code to app
COPY . .
Expand Down
9 changes: 7 additions & 2 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
image: {{ .Values.controller.image }}

env:

- name: JOB_MANAGER_API_HOSTNAME
valueFrom:
configMapKeyRef:
Expand All @@ -32,7 +32,7 @@ spec:
configMapKeyRef:
name: {{ .Release.Name }}-config
key: basePath

- name: OAUTH_SIGNIN_URL
valueFrom:
configMapKeyRef:
Expand All @@ -51,6 +51,11 @@ spec:
name: {{ .Release.Name }}-config
key: userInfoUrl

- name: ENABLE_HCAPTCHA
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-config
key: enableHCAPTCHA

ports:
- containerPort: 80
Expand Down
3 changes: 2 additions & 1 deletion chart/values.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ ingress:

config:
hostname: "http://jobmgr.proxy.localhost"
basePath: "api/v1"
basePath: ""
signInUrl: "https://oauth2.proxy.localhost/oauth2/start?rd=https%3A%2F%2Fclean.proxy.localhost%2Fconfiguration"
signOutUrl: "https://oauth2.proxy.localhost/oauth2/sign_out?rd=https%3A%2F%2Fclean.proxy.localhost%2Fconfiguration"
userInfoUrl: "https://oauth2.proxy.localhost/oauth2/userinfo"
enableHCAPTCHA: "false"

controller:
image: moleculemaker/clean-frontend:staging
1 change: 1 addition & 0 deletions chart/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config:
signInUrl: "https://auth.platform.moleculemaker.org/oauth2/start?rd=https%3A%2F%2Fclean.platform.moleculemaker.org%2Fconfiguration"
signOutUrl: "https://auth.platform.moleculemaker.org/oauth2/sign_out?rd=https%3A%2F%2Fclean.platform.moleculemaker.org%2Fconfiguration"
userInfoUrl: "https://auth.platform.moleculemaker.org/oauth2/userinfo"
enableHCAPTCHA: "false"

extraDeploy:
- apiVersion: traefik.io/v1alpha1
Expand Down
5 changes: 3 additions & 2 deletions chart/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ controller:
image: moleculemaker/clean-frontend:staging

config:
hostname: "https://jobmgr.staging.mmli1.ncsa.illinois.edu"
basePath: "api/v1"
hostname: "https://mmli.fastapi.staging.mmli1.ncsa.illinois.edu"
basePath: ""
signInUrl: "https://mmli1.ncsa.illinois.edu/oauth2/start?rd=https%3A%2F%2Fclean.frontend.staging.mmli1.ncsa.illinois.edu%2Fconfiguration"
signOutUrl: "https://mmli1.ncsa.illinois.edu/oauth2/sign_out?rd=https%3A%2F%2Fclean.frontend.staging.mmli1.ncsa.illinois.edu%2Fconfiguration"
userInfoUrl: "https://mmli1.ncsa.illinois.edu/oauth2/userinfo"
enableHCAPTCHA: "false"
3 changes: 2 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ ingress:

config:
hostname: "http://jobmgr.proxy.localhost"
basePath: "api/v1"
basePath: ""
signInUrl: "https://oauth2.proxy.localhost/oauth2/start?rd=https%3A%2F%2Fclean.proxy.localhost%2Fconfiguration"
signOutUrl: "https://oauth2.proxy.localhost/oauth2/sign_out?rd=https%3A%2F%2Fclean.proxy.localhost%2Fconfiguration"
userInfoUrl: "https://oauth2.proxy.localhost/oauth2/userinfo"
enableHCAPTCHA: "false"

controller:
image: moleculemaker/clean-frontend
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
clean-frontend:
image: moleculemaker/clean-frontend:staging
Expand Down
38 changes: 26 additions & 12 deletions src/app/components/clean/configuration/configuration.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { switchMap } from 'rxjs/operators';
import { PostResponse, PostSeqData, SingleSeqData, ExampleData, PostEmailData } from '../../../models';
import { ResultsComponent } from '../results/results.component';
import { NgHcaptchaService } from "ng-hcaptcha";
import { EnvironmentService } from "../../../services/environment.service";
import { UserInfoService } from "../../../services/userinfo.service";

@Component({
Expand Down Expand Up @@ -69,6 +70,7 @@ export class ConfigurationComponent {
private trackingService: TrackingService,
private hcaptchaService: NgHcaptchaService,
private userInfoService: UserInfoService,
private env: EnvironmentService,
private ngZone: NgZone
) { }

Expand Down Expand Up @@ -127,19 +129,31 @@ export class ConfigurationComponent {
.subscribe( data => {
this.router.navigate(['/results', data.jobId, '149']);
});
} else if (this.userInfoService.userInfo) {
// User is logged in, send token cookie with request
this._sequenceService.getResponse(this.realSendData).subscribe((data) => {
this.router.navigate(['/results', data.job_id, String(this.seqNum)]);
});
} else {
// User not logged in, send through hcaptcha
this.hcaptchaService.verify().pipe(
switchMap((data) => {
this.realSendData.captcha_token = data;
return this._sequenceService.getResponse(this.realSendData);
})
).subscribe({
// By default, just submit the job (skip HCAPTCHA)
let submission = this._sequenceService.getResponse(this.realSendData);
if (this.userInfoService.userInfo) {
// User is logged in (sends token cookie with request)
// Skip HCAPTCHA
// TODO: Anything else we need to do in this case?
} else {
// User is not logged in
// Check if we should prompt HCAPTCHA
if (this.env.getEnvConfig().enableHCAPTCHA) {
// Verify HCAPTCHA, then submit job
submission = this.hcaptchaService.verify().pipe(
switchMap((data) => {
return this._sequenceService.getResponse({
...this.realSendData,
captcha_token: data
});
})
)
}
}

// Submit user request (either with HCAPTCHA or without)
submission.subscribe({
next: (data) => {
this.router.navigate(['/results', data.job_id, String(this.seqNum)]);
},
Expand Down
1 change: 1 addition & 0 deletions src/app/models/envvars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface EnvVars {
signOutUrl: string;

userInfoUrl: string;
enableHCAPTCHA: boolean;
}
9 changes: 5 additions & 4 deletions src/assets/config/envvars.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"hostname": "http://mmli.fastapi.localhost",
"hostname": "https://mmli.fastapi.staging.mmli1.ncsa.illinois.edu",
"basePath": "",

"signInUrl": "http://oauth2.proxy.localhost/oauth2/start?rd=http%3A%2F%2Fclean.frontend.proxy.localhost%2Fconfiguration",
"signOutUrl": "http://oauth2.proxy.localhost/oauth2/sign_out?rd=http%3A%2F%2Fclean.frontend.proxy.localhost%2Fconfiguration",
"userInfoUrl": "http://oauth2.proxy.localhost/oauth2/userinfo"
"signInUrl": "https://mmli1.ncsa.illinois.edu/oauth2/start?rd=http%3A%2F%2Flocalhost:4200%2Fconfiguration",
"signOutUrl": "https://mmli1.ncsa.illinois.edu/oauth2/sign_out?rd=http%3A%2F%2Flocalhost:4200%2Fconfiguration",
"userInfoUrl": "https://mmli1.ncsa.illinois.edu/oauth2/userinfo",
"enableHCAPTCHA": false
}
9 changes: 9 additions & 0 deletions src/assets/config/envvars.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hostname": "http://mmli.fastapi.localhost",
"basePath": "",

"signInUrl": "http://oauth2.proxy.localhost/oauth2/start?rd=http%3A%2F%2Fclean.frontend.proxy.localhost%2Fconfiguration",
"signOutUrl": "http://oauth2.proxy.localhost/oauth2/sign_out?rd=http%3A%2F%2Fclean.frontend.proxy.localhost%2Fconfiguration",
"userInfoUrl": "http://oauth2.proxy.localhost/oauth2/userinfo",
"enableHCAPTCHA": false
}
9 changes: 9 additions & 0 deletions src/assets/config/envvars.staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hostname": "https://mmli.fastapi.staging.mmli1.ncsa.illinois.edu",
"basePath": "",

"signInUrl": "https://mmli1.ncsa.illinois.edu/oauth2/start?rd=http%3A%2F%2Fclean.frontend.proxy.localhost%2Fconfiguration",
"signOutUrl": "https://mmli1.ncsa.illinois.edu/oauth2/sign_out?rd=http%3A%2F%2Fclean.frontend.proxy.localhost%2Fconfiguration",
"userInfoUrl": "https://mmli1.ncsa.illinois.edu/oauth2/userinfo",
"enableHCAPTCHA": false
}
3 changes: 2 additions & 1 deletion src/assets/config/envvars.tpl.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

"signInUrl": "${OAUTH_SIGNIN_URL}",
"signOutUrl": "${OAUTH_SIGNOUT_URL}",
"userInfoUrl": "${OAUTH_USERINFO_URL}"
"userInfoUrl": "${OAUTH_USERINFO_URL}",
"enableHCAPTCHA": ${ENABLE_HCAPTCHA}
}

Loading