Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Remove OPA-based password policy enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Jun 26, 2024
1 parent babce67 commit 27fd30e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
6 changes: 1 addition & 5 deletions crates/handlers/src/graphql/mutations/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,7 @@ impl UserMutations {
return Err(async_graphql::Error::new("Unauthorized"));
}

let mut policy = state.policy().await?;

let res = policy.evaluate_password(&input.new_password).await?;

if !res.valid() {
if input.new_password.is_empty() {
// TODO Expose the reason for the policy violation
// This involves redesigning the error handling
// Idea would be to expose an errors array in the response,
Expand Down
19 changes: 1 addition & 18 deletions crates/policy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ use thiserror::Error;
use tokio::io::{AsyncRead, AsyncReadExt};
use wasmtime::{Config, Engine, Module, Store};

use self::model::{
AuthorizationGrantInput, ClientRegistrationInput, EmailInput, PasswordInput, RegisterInput,
};
use self::model::{AuthorizationGrantInput, ClientRegistrationInput, EmailInput, RegisterInput};
pub use self::model::{EvaluationResult, Violation};
use crate::model::GrantType;

Expand Down Expand Up @@ -193,21 +191,6 @@ impl Policy {
Ok(res)
}

#[tracing::instrument(name = "policy.evaluate_password", skip_all, err)]
pub async fn evaluate_password(
&mut self,
password: &str,
) -> Result<EvaluationResult, EvaluationError> {
let input = PasswordInput { password };

let [res]: [EvaluationResult; 1] = self
.instance
.evaluate(&mut self.store, &self.entrypoints.password, &input)
.await?;

Ok(res)
}

#[tracing::instrument(
name = "policy.evaluate.register",
skip_all,
Expand Down

0 comments on commit 27fd30e

Please sign in to comment.