aboutsummaryrefslogtreecommitdiffstats
path: root/lib/auth-service
diff options
context:
space:
mode:
Diffstat (limited to 'lib/auth-service')
-rw-r--r--lib/auth-service/Cargo.toml7
-rw-r--r--lib/auth-service/src/client/mod.rs5
-rw-r--r--lib/auth-service/src/lib.rs2
-rw-r--r--lib/auth-service/src/service/mod.rs51
4 files changed, 62 insertions, 3 deletions
diff --git a/lib/auth-service/Cargo.toml b/lib/auth-service/Cargo.toml
index 8efdc57..e972312 100644
--- a/lib/auth-service/Cargo.toml
+++ b/lib/auth-service/Cargo.toml
@@ -7,8 +7,13 @@ readme.workspace = true
documentation.workspace = true
[dependencies]
-secrecy = "0.10.3"
+async-session = "3.0.0"
+async-trait.workspace = true
oauth2 = "5.0.0"
+secrecy = "0.10.3"
+shared-svc = { workspace = true, features = ["cache"] }
+sqlx.workspace = true
thiserror.workspace = true
+time.workspace = true
tracing.workspace = true
url = { workspace = true, features = ["serde"] }
diff --git a/lib/auth-service/src/client/mod.rs b/lib/auth-service/src/client/mod.rs
index af581b0..45e7e4d 100644
--- a/lib/auth-service/src/client/mod.rs
+++ b/lib/auth-service/src/client/mod.rs
@@ -5,6 +5,7 @@ use url::Url;
use crate::AuthServiceError;
+#[derive(Debug, Clone)]
pub struct OauthClient(
oauth2::basic::BasicClient<
EndpointSet,
@@ -38,10 +39,10 @@ impl ClientConfig {
}
}
-impl TryFrom<ClientConfig> for OauthClient {
+impl TryFrom<&ClientConfig> for OauthClient {
type Error = AuthServiceError;
- fn try_from(value: ClientConfig) -> Result<Self, Self::Error> {
+ fn try_from(value: &ClientConfig) -> Result<Self, Self::Error> {
debug!("creating oauth client");
Ok(Self(
oauth2::basic::BasicClient::new(ClientId::new(value.client_id.to_string()))
diff --git a/lib/auth-service/src/lib.rs b/lib/auth-service/src/lib.rs
index f7b9e80..308ce0f 100644
--- a/lib/auth-service/src/lib.rs
+++ b/lib/auth-service/src/lib.rs
@@ -1,4 +1,6 @@
pub mod client;
+mod service;
+pub use service::*;
use thiserror::Error;
diff --git a/lib/auth-service/src/service/mod.rs b/lib/auth-service/src/service/mod.rs
new file mode 100644
index 0000000..3d45523
--- /dev/null
+++ b/lib/auth-service/src/service/mod.rs
@@ -0,0 +1,51 @@
+use async_session::{Result, Session, SessionStore};
+use async_trait::async_trait;
+use shared_svc::cache::RedisManager;
+use tracing::instrument;
+
+#[derive(Debug, Clone)]
+pub struct AuthService {
+ cache: RedisManager,
+}
+
+impl AuthService {
+ pub fn new(cache: &RedisManager) -> Self {
+ Self {
+ cache: cache.clone(),
+ }
+ }
+}
+
+#[async_trait]
+impl SessionStore for AuthService {
+ #[doc = " Get a session from the storage backend."]
+ #[doc = ""]
+ #[doc = " The input is expected to be the value of an identifying"]
+ #[doc = " cookie. This will then be parsed by the session middleware"]
+ #[doc = " into a session if possible"]
+ #[instrument(skip(self))]
+ async fn load_session(&self, cookie_value: String) -> Result<Option<Session>> {
+ todo!()
+ }
+
+ #[doc = " Store a session on the storage backend."]
+ #[doc = ""]
+ #[doc = " The return value is the value of the cookie to store for the"]
+ #[doc = " user that represents this session"]
+ #[instrument(skip(self))]
+ async fn store_session(&self, session: Session) -> Result<Option<String>> {
+ todo!()
+ }
+
+ #[doc = " Remove a session from the session store"]
+ #[instrument(skip(self))]
+ async fn destroy_session(&self, session: Session) -> Result {
+ todo!()
+ }
+
+ #[doc = " Empties the entire store, destroying all sessions"]
+ #[instrument(skip(self))]
+ async fn clear_store(&self) -> Result {
+ todo!()
+ }
+}