Repository navigation
stage/authenticator*: expand attempt throttling to email- and sms-based 2FA - #21751
Conversation
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21751 +/- ##
==========================================
+ Coverage 92.21% 93.14% +0.92%
==========================================
Files 1034 1017 -17
Lines 59985 58277 -1708
Branches 2695 327 -2368
==========================================
- Hits 55317 54281 -1036
+ Misses 4595 3996 -599
+ Partials 73 0 -73
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
808bcce to
8d0e42b
Compare
…_validate/index.mdx Co-authored-by: Dominic R <[email protected]> Signed-off-by: Alexander Tereshkin <[email protected]>
…_validate/index.mdx Co-authored-by: Dominic R <[email protected]> Signed-off-by: Alexander Tereshkin <[email protected]>
…_validate/index.mdx Co-authored-by: Dominic R <[email protected]> Signed-off-by: Alexander Tereshkin <[email protected]>
…_validate/index.mdx Co-authored-by: Dominic R <[email protected]> Signed-off-by: Alexander Tereshkin <[email protected]>
…_validate/index.mdx Co-authored-by: Dominic R <[email protected]> Signed-off-by: Alexander Tereshkin <[email protected]>
| : nothing} | ||
| </div> | ||
| </ak-form-group> | ||
| <ak-form-group label="${msg("Throttling settings")}"> |
There was a problem hiding this comment.
Might be worth extracting and deduping this
There was a problem hiding this comment.
Something like this:
private renderThrottlingComponent(msg: string, field: string, value = 1) {
return html`
<ak-form-element-horizontal label=${msg} required name=${field}>
<input
type="number"
step="0.1"
value=${value}
class="pf-c-form-control pf-m-monospace"
autocomplete="off"
spellcheck="false"
required
/>
</ak-form-element-horizontal>
`;
}
And then you can ${renderThrottlingComponent(msg("Email OTP throttling factor"), "emailOtpThrottlingFactor", this.instance?.emailOtpThrottlingFactor)} for each of the types. Warm my heart and put those into a table and build them with a map(). :-)
| def component(self) -> str: | ||
| return "ak-stage-authenticator-validate-form" | ||
|
|
||
| def get_throttling_factor(self, device_class: DeviceClasses) -> float | None: |
There was a problem hiding this comment.
Couldn't we just do this instead of a giant if block?
def get_throttling_factor(self, device_class: DeviceClasses) -> float | None:
mapping = {
DeviceClasses.EMAIL: self.email_otp_throttling_factor,
DeviceClasses.SMS: self.sms_otp_throttling_factor,
DeviceClasses.TOTP: self.totp_otp_throttling_factor,
DeviceClasses.STATIC: self.static_otp_throttling_factor,
}
return mapping.get(device_class)
gergosimonyi
left a comment
There was a problem hiding this comment.
There should definitely be a follow-up refactoring ThrottlingMixin to be used with anything rather than devices only. The mixin leaves much to be desired: strategies, upper limit, etc.
That is not the aim of this PR though, and I believe no additional complexity is introduced that raises the difficulty of such a refactor.
One note: please edit the comment at the top of the mixin. It is not accurate after this PR, namely this is no longer a strict requirement:
[...] Subclasses must
implement :meth:get_throttle_factor[...]
* main: (25 commits) lifecycle/aws: bump aws-cdk from 2.1119.0 to 2.1120.0 in /lifecycle/aws (#22105) web: bump @sentry/browser from 10.50.0 to 10.51.0 in /web in the sentry group across 1 directory (#22106) ci: bump taiki-e/install-action from 2.75.30 to 2.76.0 in /.github/actions/setup (#22108) core, web: update translations (#22129) stage/authenticator*: expand attempt throttling to email- and sms-based 2FA (#21751) translate: Updates for project authentik and language pt_PT (#22122) translate: Updates for project authentik and language no_NO (#22120) stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#22128) translate: Updates for project authentik and language ja_JP (#22118) translate: Updates for project authentik and language ru_RU (#22119) translate: Updates for project authentik and language tr_TR (#22125) translate: Updates for project authentik and language pl_PL (#22124) translate: Updates for project authentik and language pt_BR (#22111) translate: Updates for project authentik and language it_IT (#22123) translate: Updates for project authentik and language zh-Hans (#22121) translate: Updates for project authentik and language cs_CZ (#22115) translate: Updates for project authentik and language fr_FR (#22117) translate: Updates for project authentik and language fi_FI (#22114) translate: Updates for project authentik and language de_DE (#22113) translate: Updates for project authentik and language es_ES (#22116) ...
* main: (30 commits) locale: fix de_DE locale placeholder (#22130) website/docs: stages cleanup (#21558) website: bump the build group in /website with 3 updates (#22104) web: bump basic-ftp from 5.3.0 to 5.3.1 in /web (#22131) web: bump knip from 6.7.0 to 6.9.0 in /web (#22107) lifecycle/aws: bump aws-cdk from 2.1119.0 to 2.1120.0 in /lifecycle/aws (#22105) web: bump @sentry/browser from 10.50.0 to 10.51.0 in /web in the sentry group across 1 directory (#22106) ci: bump taiki-e/install-action from 2.75.30 to 2.76.0 in /.github/actions/setup (#22108) core, web: update translations (#22129) stage/authenticator*: expand attempt throttling to email- and sms-based 2FA (#21751) translate: Updates for project authentik and language pt_PT (#22122) translate: Updates for project authentik and language no_NO (#22120) stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#22128) translate: Updates for project authentik and language ja_JP (#22118) translate: Updates for project authentik and language ru_RU (#22119) translate: Updates for project authentik and language tr_TR (#22125) translate: Updates for project authentik and language pl_PL (#22124) translate: Updates for project authentik and language pt_BR (#22111) translate: Updates for project authentik and language it_IT (#22123) translate: Updates for project authentik and language zh-Hans (#22121) ...
Details
This expands attempt throttling logic that's already in use for TOTP and static codes to email- and sms-based 2FA.
Additional parameters are added on the Authenticator Validation stage that control throttling speed.
One important omission is that this PR does not address the (already existing) issue of displaying throttling-specific error messages. This will be taken care of in a follow-up PR that will change code validation logic away from trying every device.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen)If changes to the frontend have been made
make web)If applicable
make docs)