lldap/auth/src/lib.rs

77 lines
2.3 KiB
Rust
Raw Normal View History

#![allow(clippy::nonstandard_macro_braces)]
2021-05-13 17:32:29 +00:00
use chrono::prelude::*;
2021-06-08 20:23:46 +00:00
use serde::{Deserialize, Serialize};
2021-05-13 17:32:29 +00:00
use std::collections::HashSet;
2021-05-09 09:52:53 +00:00
2021-06-08 20:23:46 +00:00
pub mod opaque;
2021-06-16 17:12:41 +00:00
/// The messages for the 3-step OPAQUE login process.
pub mod login {
use super::*;
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerData {
pub username: String,
pub server_login: opaque::server::login::ServerLogin,
}
2021-06-16 17:12:41 +00:00
#[derive(Serialize, Deserialize, Clone)]
pub struct ClientLoginStartRequest {
pub username: String,
pub login_start_request: opaque::server::login::CredentialRequest,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerLoginStartResponse {
/// Base64, encrypted ServerData to be passed back to the server.
pub server_data: String,
2021-06-16 17:12:41 +00:00
pub credential_response: opaque::client::login::CredentialResponse,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct ClientLoginFinishRequest {
/// Encrypted ServerData from the previous step.
pub server_data: String,
2021-06-16 17:12:41 +00:00
pub credential_finalization: opaque::client::login::CredentialFinalization,
}
}
/// The messages for the 3-step OPAQUE registration process.
/// It is used to reset a user's password.
2021-06-16 17:12:41 +00:00
pub mod registration {
use super::*;
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerData {
pub username: String,
}
2021-06-16 17:12:41 +00:00
#[derive(Serialize, Deserialize, Clone)]
pub struct ClientRegistrationStartRequest {
pub username: String,
pub registration_start_request: opaque::server::registration::RegistrationRequest,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerRegistrationStartResponse {
/// Base64, encrypted ServerData to be passed back to the server.
pub server_data: String,
2021-06-16 17:12:41 +00:00
pub registration_response: opaque::client::registration::RegistrationResponse,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct ClientRegistrationFinishRequest {
/// Encrypted ServerData from the previous step.
pub server_data: String,
2021-06-16 17:12:41 +00:00
pub registration_upload: opaque::server::registration::RegistrationUpload,
}
}
2021-05-13 17:32:29 +00:00
#[derive(Clone, Serialize, Deserialize)]
pub struct JWTClaims {
pub exp: DateTime<Utc>,
2021-05-20 15:40:30 +00:00
pub iat: DateTime<Utc>,
2021-05-13 17:32:29 +00:00
pub user: String,
pub groups: HashSet<String>,
}