mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
httpd: Refactor auth and session handling
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
committed by
Alexis Sellier
parent
f689cb2c9f
commit
ffdf7c171d
@@ -11,25 +11,17 @@ impl Serialize for DateTime {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum AuthState {
|
||||
Authorized(Session),
|
||||
Unauthorized(Session),
|
||||
Authorized,
|
||||
Unauthorized,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Session {
|
||||
pub status: String,
|
||||
pub status: AuthState,
|
||||
pub public_key: PublicKey,
|
||||
pub issued_at: DateTime,
|
||||
pub expires_at: DateTime,
|
||||
}
|
||||
|
||||
impl From<AuthState> for Session {
|
||||
fn from(other: AuthState) -> Self {
|
||||
match other {
|
||||
AuthState::Authorized(s) => s,
|
||||
AuthState::Unauthorized(s) => s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user