mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 14:02:29 +00:00
completely rebuilt the auth implementation to support OIDC in the future
This commit is contained in:
27
crates/store/src/auth/user.rs
Normal file
27
crates/store/src/auth/user.rs
Normal 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("")),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user