-
Notifications
You must be signed in to change notification settings - Fork 136
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
Only require captcha if threshold rate is exceeded #2638
Conversation
This PR enables the dynamic captcha feature: I.e. if the captcha is configured to be dynamic _and_ the configured threshold has been exceeded, then require a captcha to be solved. Otherwise skip the captcha entirely.
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.
A few comments, already approving.
@@ -38,17 +52,40 @@ pub async fn identity_registration_start() -> Result<IdRegNextStepResult, IdRegS | |||
return Err(IdRegStartError::InvalidCaller); | |||
} | |||
|
|||
let (captcha_png_base64, flow_state) = captcha_flow_state(time()).await; | |||
let flow_state = match captcha_required() { | |||
true => captcha_flow_state(time()).await.1, |
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.
Does it make sense to create a let now = time();
variable? Or there is no need?
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.
Ah, yes. Thanks.
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.
Why did you created the new identity_register
directory? Are there any best practices on how to split this? WHy not v2_api/dynamic_captcha_register
?
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.
I did it because the dynamic captcha is a subset of the whole identity registration tests. But I can also flatten the structure if you prefer.
// Double the rate of registrations to one per second | ||
// The 20% threshold rate should allow 5 registrations before the captcha kicks in | ||
let flow_principal = test_principal(0); | ||
for _ in 0..5 { |
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.
Why don't you use create_identity_with_authn_method
here?
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.
Because the create_identity_with_authn_method
helper works with or without captcha. And I need to assert here that the captcha is not required.
|
||
// Double the rate of registrations to one per second | ||
// The 20% threshold rate should allow 5 registrations before the captcha kicks in | ||
let flow_principal = test_principal(0); |
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.
It doesn't matter that the principal for the registration is the same?
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.
If all previous flows are completed, then it does not matter (because flows are cleaned up on finish
). But you're right, it's cleaner to use different ones.
This PR enables the dynamic captcha feature: I.e. if the captcha is configured to be dynamic and the configured threshold has been exceeded, then require a captcha to be solved. Otherwise skip the captcha entirely.