completely rebuilt the auth implementation to support OIDC in the future

This commit is contained in:
Lennart
2024-10-03 19:47:50 +02:00
parent 235e7b207a
commit 6f12a1d80e
29 changed files with 257 additions and 312 deletions

View File

@@ -0,0 +1,27 @@
use actix_web::{error::ErrorUnauthorized, FromRequest, HttpMessage};
use serde::{Deserialize, Serialize};
use std::future::{ready, Ready};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct User {
pub id: String,
pub displayname: Option<String>,
pub password: Option<String>,
}
impl FromRequest for User {
type Error = actix_web::Error;
type Future = Ready<Result<Self, Self::Error>>;
fn from_request(
req: &actix_web::HttpRequest,
_payload: &mut actix_web::dev::Payload,
) -> Self::Future {
ready(
req.extensions()
.get::<User>()
.cloned()
.ok_or(ErrorUnauthorized("")),
)
}
}