Skip to content

Remove short_term_phone_otp_rate_limiter_enabled configuration key#10432

Merged
mitchellhenke merged 2 commits intomainfrom
mitchellhenke/remove-short-otp-enable-configuration
Apr 15, 2024
Merged

Remove short_term_phone_otp_rate_limiter_enabled configuration key#10432
mitchellhenke merged 2 commits intomainfrom
mitchellhenke/remove-short-otp-enable-configuration

Conversation

@mitchellhenke
Copy link
Contributor

🛠 Summary of changes

Related to #10360. This has been tested and can be enabled everywhere.

@mitchellhenke mitchellhenke requested a review from aduth April 15, 2024 15:42
changelog: Internal, Configuration, Remove short_term_phone_otp_rate_limiter_enabled configuration key
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/remove-short-otp-enable-configuration branch from 9b86656 to 99c2921 Compare April 15, 2024 15:58
@mitchellhenke mitchellhenke merged commit 60a4c2c into main Apr 15, 2024
@mitchellhenke mitchellhenke deleted the mitchellhenke/remove-short-otp-enable-configuration branch April 15, 2024 16:38
secret_key_base: test_secret_key_base
session_encryption_key: 27bad3c25711099429c1afdfd1890910f3b59f5a4faec1c85e945cb8b02b02f261ba501d99cfbb4fab394e0102de6fecf8ffe260f322f610db3e96b2a775c120
short_term_phone_otp_rate_limiter_enabled: false
short_term_phone_otp_max_attempts: 100
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should have something which resets all rate limits between tests? Unclear if that would actually help for the reason this was added.

That, and/or use a fake phone generator in the phone factory setup.

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 think some of them were sending too many SMS within the same test. ex:

it 'succeeds in forcing login with prompt login and prior session' do
user = oidc_end_client_secret_jwt(prompt: 'login')
travel_to((IdentityConfig.store.sp_handoff_bounce_max_seconds + 1).seconds.from_now) do
oidc_end_client_secret_jwt(prompt: 'login', user: user)
end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, fair enough. Seems like we may want to revisit those at some point to make them more realistic to what we'd expect in the real-world.

I started poking at my previous idea of resetting the rate limiter, though I don't love the idea here of multiple calls to Redis between each test:

# spec/support/rate_limiter.rb

RSpec.configure do |config|
  config.before(:each) do
    REDIS_THROTTLE_POOL.with do |client|
      keys = client.call [:keys, 'throttle:*']
      client.call [:del, *keys]
    end
  end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need the .call? I think we can:

RSpec.configure do |config|
  config.before(:each) do
    REDIS_THROTTLE_POOL.with do |client|
      keys = client.keys('throttle:*')
      client.del(*keys)
    end
  end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Stumbling my way through the solution led me to this issue, which seemed to imply that call is a bit safer when deleting many keys. Though I doubt we have so many matches that it'd become an issue.

redis/redis-rb#122

Copy link
Contributor Author

@mitchellhenke mitchellhenke Apr 15, 2024

Choose a reason for hiding this comment

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

Haven't confirmed that it does or doesn't work, but I think we intend to reset the rate limit pool between tests:

REDIS_THROTTLE_POOL.with { |client| client.flushdb }

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that would (likely) work too! As you mentioned, it's probably more to do with limits within a single test being exceeded.

@mitchellhenke mitchellhenke mentioned this pull request Apr 16, 2024
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