-
Notifications
You must be signed in to change notification settings - Fork 493
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
[IAMRISK-3011] Auth0 V2 Captcha failOpen support #1382
Changes from 6 commits
3f00aea
b2385fb
a1cd75c
47263c8
97d1868
11a0e4c
4fb1707
bdce971
81af629
68d17de
f816bbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,23 @@ function injectCaptchaScript(element, opts, callback, setValue) { | |
window.arkose = arkose; | ||
callback(arkose); | ||
}; | ||
} else if (opts.provider === AUTH0_V2_CAPTCHA_PROVIDER) { | ||
var a0RetryCount = 0; | ||
attributes['error-callback'] = function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is correct. Are you trying to retry the script loading? That should be done through the attribute 'onerror' like Arkose example above. Also let's try to combine the code since it's identical to Arkose. https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement#examples |
||
if (a0RetryCount < MAX_RETRY) { | ||
removeScript(scriptSrc); | ||
loadScript(scriptSrc, attributes); | ||
a0RetryCount++; | ||
return; | ||
} | ||
removeScript(scriptSrc); | ||
// similar implementation to ARKOSE_PROVIDER failOpen | ||
setValue('BYPASS_CAPTCHA'); | ||
}; | ||
window[callbackName] = function () { | ||
delete window[callbackName] | ||
callback(); | ||
}; | ||
} else { | ||
window[callbackName] = function () { | ||
delete window[callbackName]; | ||
|
@@ -309,9 +326,23 @@ function handleCaptchaProvider(element, options, challenge) { | |
}, | ||
sitekey: challenge.siteKey | ||
}; | ||
|
||
if (challenge.provider === AUTH0_V2_CAPTCHA_PROVIDER) { | ||
var a0RetryCount = 0; | ||
renderParams.language = options.lang; | ||
renderParams.theme = 'light'; | ||
renderParams.retry = 'never'; | ||
renderParams['error-callback'] = function () { | ||
if (a0RetryCount < MAX_RETRY) { | ||
setValue(); | ||
globalForCaptchaProvider(challenge.provider).reset(widgetId); | ||
a0RetryCount++; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's try to use the retryCount variable. |
||
} else { | ||
// similar implementation to ARKOSE_PROVIDER failOpen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: no need for comment, let's remove |
||
setValue('BYPASS_CAPTCHA'); | ||
} | ||
return true; | ||
}; | ||
} | ||
widgetId = global.render(captchaDiv, renderParams); | ||
element.setAttribute('data-wid', widgetId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't have a separate variable for Auth0 V2, we can use the retryCount variable since when this script runs there will always be one provider so the counter will only represent the retries for that provider.