Skip to content

Proof-of-concept Delay Between OTP Sending (LG-7899)#10360

Merged
mitchellhenke merged 3 commits intomainfrom
mitchellhenke/short-term-otp-rate-limit
Apr 4, 2024
Merged

Proof-of-concept Delay Between OTP Sending (LG-7899)#10360
mitchellhenke merged 3 commits intomainfrom
mitchellhenke/short-term-otp-rate-limit

Conversation

@mitchellhenke
Copy link
Contributor

🎫 Ticket

Link to the relevant ticket:
LG-7899

🛠 Summary of changes

This is not quite ready yet, but I'm opening this PR to share a proof-of-concept implementation of LG-7899.

Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me as-is?

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/short-term-otp-rate-limit branch from b093e24 to 782c892 Compare April 4, 2024 14:04
changelog: Internal, Rate Limiting, Add short-term rate limit as delay between OTP sends
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/short-term-otp-rate-limit branch from 782c892 to aff110e Compare April 4, 2024 15:03
phone_recaptcha_mock_validator: false
piv_cac_verify_token_secret:
session_encryptor_alert_enabled: true
short_term_phone_otp_rate_limiter_enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious the rationale for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather default to off for deployed environments and opt-in manually for now. We can/should remove it if we're happy with it though.

personal_key_retired: true
phone_carrier_registration_blocklist_array: '[]'
short_term_phone_otp_max_attempt_window_in_seconds: 10
short_term_phone_otp_max_attempts: 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial impression was that this would allow someone to request 2 codes within 10 seconds, but I can only request 1 code within 10 seconds. I think either would be fine, but the configuration value felt a little misleading to me (or at least unexpected), i.e. I would expect this value to be 1 if I can only request 1 code every 10 seconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the way the RateLimiter class is kind of weird in that way unfortunately :/

We could switch

attempts && attempts >= RateLimiter.max_attempts(rate_limit_type)
to be > rather than >= and reduce everything by one 😬

@JzmCrow
Copy link

JzmCrow commented Apr 4, 2024

@mitchellhenke - My understanding is this implementation is going to limit 2 SMS / 10 seconds. I'd like to see the error message that is going to be displayed to the user in this sceanrio.

@mitchellhenke
Copy link
Contributor Author

@mitchellhenke - My understanding is this implementation is going to limit 2 SMS / 10 seconds. I'd like to see the error message that is going to be displayed to the user in this sceanrio.

The limit is 1 SMS / 10 seconds. Andrew has a comment here, the "max" is not very intuitive.

The error will look like:
image

@mitchellhenke mitchellhenke marked this pull request as ready for review April 4, 2024 18:12
subject.user_session[:context] = 'confirmation'
allow(IdentityConfig.store).to receive(:otp_delivery_blocklist_maxretry).and_return(999)

expect(@analytics).to receive(:track_event).with('OTP: Delivery Selection', anything).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use have_logged_event after the actions instead of receive(:track_event) so it uses all FakeAnalytics behaviors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, thanks, added be2fd98 to do that

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/short-term-otp-rate-limit branch from be2fd98 to 1c00b91 Compare April 4, 2024 20:04
@mitchellhenke mitchellhenke merged commit 96c6389 into main Apr 4, 2024
@mitchellhenke mitchellhenke deleted the mitchellhenke/short-term-otp-rate-limit branch April 4, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants