From 1ef2ffa3d5f948357ec9b8bc72f2b6862d7bd43f Mon Sep 17 00:00:00 2001 From: Liubin Jiang Date: Fri, 11 Feb 2022 09:58:33 -0800 Subject: [PATCH 1/3] Defined reCAPTCHA config. - Added reCAPTCHA protection states. - Added reCAPTCHA action rule. - Added reCAPTCHA key config. No tests needed for this change. --- src/auth/recaptcha-config.ts | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/auth/recaptcha-config.ts diff --git a/src/auth/recaptcha-config.ts b/src/auth/recaptcha-config.ts new file mode 100644 index 0000000000..ba5ae6e770 --- /dev/null +++ b/src/auth/recaptcha-config.ts @@ -0,0 +1,80 @@ +/*! + * Copyright 2020 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Enforcement state of reCAPTCHA protection. +* - 'OFF': Unenforced. +* - 'AUDIT': Assessment is created but result is not used to enforce. +* - 'ENFORCE': Assessment is created and result is used to enforce. +*/ +export type RecaptchaProviderEnforcementState = 'OFF' | 'AUDIT' | 'ENFORCE'; + +/** +* The actions for reCAPTCHA-protected requests. +* - 'BLOCK': The reCAPTCHA-protected request will be blocked. +*/ +export type RecaptchaAction = 'BLOCK'; + +/** +* The config for a reCAPTCHA action rule. +*/ +export interface RecaptchaManagedRule { + /** + * The action will be enforced if the reCAPTCHA score of a request is larger than endScore. + */ + endScore: number; + /** + * The action for reCAPTCHA-protected requests. + */ + action?: RecaptchaAction; +} + +/** + * The key's platform type: only web supported now.. + */ +export type RecaptchaKeyClientType = 'WEB'; + +/** + * The reCAPTCHA key config. + */ +export interface RecaptchaKey { + /** + * The key's client platform type. + */ + type?: RecaptchaKeyClientType; + + /** + * The reCAPTCHA site key. + */ + key: string; +} + +export interface RecaptchaConfig { + /** + * The enforcement state of email password provider. + */ + emailPasswordEnforcementState?: RecaptchaProviderEnforcementState; + + /** + * The reCAPTCHA managed rules. + */ + managedRules: RecaptchaManagedRule[]; + + /** + * The reCAPTCHA keys. + */ + recaptchaKeys?: RecaptchaKey[]; +} \ No newline at end of file From 831a9ba1e3d35cc50e204b24beecff2a016b20f9 Mon Sep 17 00:00:00 2001 From: Liubin Jiang Date: Fri, 11 Feb 2022 15:18:46 -0800 Subject: [PATCH 2/3] Define reCAPTCHA config in auth-config. Added reCAPTCHA protection states. Added reCAPTCHA action rule. Added reCAPTCHA key config. --- src/auth/auth-config.ts | 65 +++++++++++++++++++++++++++++ src/auth/recaptcha-config.ts | 80 ------------------------------------ 2 files changed, 65 insertions(+), 80 deletions(-) delete mode 100644 src/auth/recaptcha-config.ts diff --git a/src/auth/auth-config.ts b/src/auth/auth-config.ts index ce45713f97..add0e80313 100644 --- a/src/auth/auth-config.ts +++ b/src/auth/auth-config.ts @@ -1451,3 +1451,68 @@ export class OIDCConfig implements OIDCAuthProviderConfig { }; } } + +/** +* Enforcement state of reCAPTCHA protection. +* - 'OFF': Unenforced. +* - 'AUDIT': Assessment is created but result is not used to enforce. +* - 'ENFORCE': Assessment is created and result is used to enforce. +*/ +export type RecaptchaProviderEnforcementState = 'OFF' | 'AUDIT' | 'ENFORCE'; + +/** +* The actions for reCAPTCHA-protected requests. +* - 'BLOCK': The reCAPTCHA-protected request will be blocked. +*/ +export type RecaptchaAction = 'BLOCK'; + +/** +* The config for a reCAPTCHA action rule. +*/ +export interface RecaptchaManagedRule { + /** + * The action will be enforced if the reCAPTCHA score of a request is larger than endScore. + */ + endScore: number; + /** + * The action for reCAPTCHA-protected requests. + */ + action?: RecaptchaAction; +} + +/** + * The key's platform type: only web supported now.. + */ +export type RecaptchaKeyClientType = 'WEB'; + +/** + * The reCAPTCHA key config. + */ +export interface RecaptchaKey { + /** + * The key's client platform type. + */ + type?: RecaptchaKeyClientType; + + /** + * The reCAPTCHA site key. + */ + key: string; +} + +export interface RecaptchaConfig { + /** + * The enforcement state of email password provider. + */ + emailPasswordEnforcementState?: RecaptchaProviderEnforcementState; + + /** + * The reCAPTCHA managed rules. + */ + managedRules: RecaptchaManagedRule[]; + + /** + * The reCAPTCHA keys. + */ + recaptchaKeys?: RecaptchaKey[]; +} diff --git a/src/auth/recaptcha-config.ts b/src/auth/recaptcha-config.ts deleted file mode 100644 index ba5ae6e770..0000000000 --- a/src/auth/recaptcha-config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/*! - * Copyright 2020 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* Enforcement state of reCAPTCHA protection. -* - 'OFF': Unenforced. -* - 'AUDIT': Assessment is created but result is not used to enforce. -* - 'ENFORCE': Assessment is created and result is used to enforce. -*/ -export type RecaptchaProviderEnforcementState = 'OFF' | 'AUDIT' | 'ENFORCE'; - -/** -* The actions for reCAPTCHA-protected requests. -* - 'BLOCK': The reCAPTCHA-protected request will be blocked. -*/ -export type RecaptchaAction = 'BLOCK'; - -/** -* The config for a reCAPTCHA action rule. -*/ -export interface RecaptchaManagedRule { - /** - * The action will be enforced if the reCAPTCHA score of a request is larger than endScore. - */ - endScore: number; - /** - * The action for reCAPTCHA-protected requests. - */ - action?: RecaptchaAction; -} - -/** - * The key's platform type: only web supported now.. - */ -export type RecaptchaKeyClientType = 'WEB'; - -/** - * The reCAPTCHA key config. - */ -export interface RecaptchaKey { - /** - * The key's client platform type. - */ - type?: RecaptchaKeyClientType; - - /** - * The reCAPTCHA site key. - */ - key: string; -} - -export interface RecaptchaConfig { - /** - * The enforcement state of email password provider. - */ - emailPasswordEnforcementState?: RecaptchaProviderEnforcementState; - - /** - * The reCAPTCHA managed rules. - */ - managedRules: RecaptchaManagedRule[]; - - /** - * The reCAPTCHA keys. - */ - recaptchaKeys?: RecaptchaKey[]; -} \ No newline at end of file From 1aca4cff22eebd878364f7caf11a6da9d2473588 Mon Sep 17 00:00:00 2001 From: Liubin Jiang Date: Mon, 14 Feb 2022 13:07:33 -0800 Subject: [PATCH 3/3] Fixed typo in auth-config.js comments --- src/auth/auth-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/auth-config.ts b/src/auth/auth-config.ts index add0e80313..a640cc3534 100644 --- a/src/auth/auth-config.ts +++ b/src/auth/auth-config.ts @@ -1481,7 +1481,7 @@ export interface RecaptchaManagedRule { } /** - * The key's platform type: only web supported now.. + * The key's platform type: only web supported now. */ export type RecaptchaKeyClientType = 'WEB';