1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Handle password strength verification through OPA

This commit is contained in:
Quentin Gliech
2022-06-03 16:04:14 +02:00
parent eb22c33a7d
commit e694932daf
4 changed files with 68 additions and 4 deletions

View File

@ -133,7 +133,7 @@ pub(crate) async fn post(
let mut policy = policy_factory.instantiate().await?;
let res = policy
.evaluate_register(&form.username, &form.email)
.evaluate_register(&form.username, &form.password, &form.email)
.await?;
for violation in res.violations {
@ -150,6 +150,12 @@ pub(crate) async fn post(
message: violation.msg,
},
),
Some("password") => state.add_error_on_field(
RegisterFormField::Password,
FieldError::Policy {
message: violation.msg,
},
),
_ => state.add_error_on_form(FormError::Policy {
message: violation.msg,
}),