File tree Expand file tree Collapse file tree 4 files changed +28
-8
lines changed
clerk-js/src/core/resources Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @clerk/clerk-js " : patch
3+ " @clerk/types " : patch
4+ ---
5+
6+ Bypass captcha for providers dynamically provided in environment
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type {
44 DisplayConfigJSON ,
55 DisplayConfigResource ,
66 DisplayThemeJSON ,
7+ OAuthStrategy ,
78 PreferredSignInStrategy ,
89} from '@clerk/types' ;
910
@@ -24,6 +25,7 @@ export class DisplayConfig extends BaseResource implements DisplayConfigResource
2425 captchaWidgetType : CaptchaWidgetType = null ;
2526 captchaProvider : CaptchaProvider = 'turnstile' ;
2627 captchaPublicKeyInvisible : string | null = null ;
28+ captchaOauthBypass : OAuthStrategy [ ] = [ ] ;
2729 homeUrl ! : string ;
2830 instanceEnvironmentType ! : string ;
2931 faviconImageUrl ! : string ;
@@ -74,6 +76,9 @@ export class DisplayConfig extends BaseResource implements DisplayConfigResource
7476 this . captchaWidgetType = data . captcha_widget_type ;
7577 this . captchaProvider = data . captcha_provider ;
7678 this . captchaPublicKeyInvisible = data . captcha_public_key_invisible ;
79+ // These are the OAuth strategies we used to bypass the captcha for by default
80+ // before the introduction of the captcha_oauth_bypass field
81+ this . captchaOauthBypass = data . captcha_oauth_bypass || [ 'oauth_google' , 'oauth_microsoft' , 'oauth_apple' ] ;
7782 this . supportEmail = data . support_email || '' ;
7883 this . clerkJSVersion = data . clerk_js_version ;
7984 this . organizationProfileUrl = data . organization_profile_url ;
Original file line number Diff line number Diff line change @@ -324,18 +324,19 @@ export class SignUp extends BaseResource implements SignUpResource {
324324 * We delegate bot detection to the following providers, instead of relying on turnstile exclusively
325325 */
326326 protected shouldBypassCaptchaForAttempt ( params : SignUpCreateParams ) {
327- if (
328- params . strategy === 'oauth_google' ||
329- params . strategy === 'oauth_microsoft' ||
330- params . strategy === 'oauth_apple'
331- ) {
327+ if ( ! params . strategy ) {
328+ return false ;
329+ }
330+
331+ const captchaOauthBypass = SignUp . clerk . __unstable__environment ! . displayConfig . captchaOauthBypass ;
332+
333+ if ( captchaOauthBypass . some ( strategy => strategy === params . strategy ) ) {
332334 return true ;
333335 }
336+
334337 if (
335338 params . transfer &&
336- ( SignUp . clerk . client ?. signIn . firstFactorVerification . strategy === 'oauth_google' ||
337- SignUp . clerk . client ?. signIn . firstFactorVerification . strategy === 'oauth_microsoft' ||
338- SignUp . clerk . client ?. signIn . firstFactorVerification . strategy === 'oauth_apple' )
339+ captchaOauthBypass . some ( strategy => strategy === SignUp . clerk . client ! . signIn . firstFactorVerification . strategy )
339340 ) {
340341 return true ;
341342 }
Original file line number Diff line number Diff line change 11import type { DisplayThemeJSON } from './json' ;
22import type { ClerkResource } from './resource' ;
3+ import type { OAuthStrategy } from './strategies' ;
34
45export type PreferredSignInStrategy = 'password' | 'otp' ;
56export type CaptchaWidgetType = 'smart' | 'invisible' | null ;
@@ -19,6 +20,7 @@ export interface DisplayConfigJSON {
1920 captcha_widget_type : CaptchaWidgetType ;
2021 captcha_public_key_invisible : string | null ;
2122 captcha_provider : CaptchaProvider ;
23+ captcha_oauth_bypass : OAuthStrategy [ ] | null ;
2224 home_url : string ;
2325 instance_environment_type : string ;
2426 logo_image_url : string ;
@@ -52,6 +54,12 @@ export interface DisplayConfigResource extends ClerkResource {
5254 captchaWidgetType : CaptchaWidgetType ;
5355 captchaProvider : CaptchaProvider ;
5456 captchaPublicKeyInvisible : string | null ;
57+ /**
58+ * An array of OAuth strategies for which we will bypass the captcha.
59+ * We trust that the provider will verify that the user is not a bot on their end.
60+ * This can also be used to bypass the captcha for a specific OAuth provider on a per-instance basis.
61+ */
62+ captchaOauthBypass : OAuthStrategy [ ] ;
5563 homeUrl : string ;
5664 instanceEnvironmentType : string ;
5765 logoImageUrl : string ;
You can’t perform that action at this time.
0 commit comments