Skip to content

Commit

Permalink
feat: rm bot protection against GSIB respondents
Browse files Browse the repository at this point in the history
  • Loading branch information
LinHuiqing committed Jul 25, 2023
1 parent 3177870 commit 2c1fcb9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/src/features/public-form/PublicFormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ export const PublicFormProvider = ({
}
}, [submissionData])

// Only load catpcha if enabled on form and the user is not on GSIB
const {
data: { captchaPublicKey, turnstileSiteKey, useFetchForSubmissions } = {},
} = useEnv(/* enabled= */ !!data?.form.hasCaptcha)
} = useEnv(/* enabled= */ !!data?.form.hasCaptcha && !data?.isIntranetUser)

// Feature flag to control turnstile captcha rollout
// defaults to false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ const submitEmailModeForm: ControllerHandler<
}),
)
.andThen((form) => {
// Check the captcha
if (form.hasCaptcha) {
// Check if respondent is a GSIB user
const isIntranetUser = FormService.checkIsIntranetFormAccess(
getRequestIp(req),
form,
)
// Check the captcha, provided user is not on GSIB
if (!isIntranetUser && form.hasCaptcha) {
switch (req.query.captchaType) {
case CaptchaTypes.Turnstile: {
return TurnstileService.verifyTurnstileResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ const submitEncryptModeForm: ControllerHandler<
})
}
}
// Check captcha
if (form.hasCaptcha) {
// Check if respondent is a GSIB user
const isIntranetUser = FormService.checkIsIntranetFormAccess(
getRequestIp(req),
form,
)
// Check captcha, provided user is not on GSIB
if (!isIntranetUser && form.hasCaptcha) {
switch (req.query.captchaType) {
case CaptchaTypes.Turnstile: {
const turnstileResult = await TurnstileService.verifyTurnstileResponse(
Expand Down

0 comments on commit 2c1fcb9

Please sign in to comment.