From 231f9c948bb2aca1e819be823bce616326a7a7a2 Mon Sep 17 00:00:00 2001
From: meskill <8974488+meskill@users.noreply.github.com>
Date: Thu, 28 Mar 2024 21:50:27 +0000
Subject: [PATCH] refactor(auth): change the way multiple auth providers are
defined
---
src/auth/basic.rs | 6 ++
src/auth/context.rs | 20 +++--
src/auth/error.rs | 12 +--
src/auth/verify.rs | 175 +++++++++++++++++++++++++-----------
src/blueprint/auth.rs | 194 ++++++++++++++++++++++++++++++++++++----
src/blueprint/server.rs | 2 +-
6 files changed, 319 insertions(+), 90 deletions(-)
diff --git a/src/auth/basic.rs b/src/auth/basic.rs
index d2d201a08c..8685b72857 100644
--- a/src/auth/basic.rs
+++ b/src/auth/basic.rs
@@ -49,6 +49,12 @@ testuser2:$2y$10$wJ/mZDURcAOBIrswCAKFsO0Nk7BpHmWl/XuhF7lNm3gBAFH3ofsuu
testuser3:{SHA}Y2fEjdGT1W6nsLqtJbGUVeUp9e4=
";
+ impl blueprint::BasicProvider {
+ pub fn test_value() -> Self {
+ Self { htpasswd: HTPASSWD_TEST.to_owned() }
+ }
+ }
+
pub fn create_basic_auth_request(username: &str, password: &str) -> RequestContext {
let mut req_context = RequestContext::default();
diff --git a/src/auth/context.rs b/src/auth/context.rs
index 571007ecb1..dc9a5597cc 100644
--- a/src/auth/context.rs
+++ b/src/auth/context.rs
@@ -1,4 +1,4 @@
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, RwLock};
use anyhow::Result;
@@ -14,8 +14,7 @@ pub struct GlobalAuthContext {
#[derive(Default)]
pub struct AuthContext {
- // TODO: can we do without mutex?
- auth_result: Mutex