model: rename to auth

Since the "model" doesn't contain any message from the API anymore, and
instead contains only the structures needed for authentication, it was
renamed as such.
This commit is contained in:
Valentin Tolmer
2021-08-31 16:29:49 +02:00
committed by nitnelave
parent 9dd579e32e
commit 3eb53ba5bf
18 changed files with 24 additions and 24 deletions

76
auth/src/lib.rs Normal file
View File

@@ -0,0 +1,76 @@
#![allow(clippy::nonstandard_macro_braces)]
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
pub mod opaque;
/// 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,
}
#[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,
pub credential_response: opaque::client::login::CredentialResponse,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct ClientLoginFinishRequest {
/// Encrypted ServerData from the previous step.
pub server_data: String,
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.
pub mod registration {
use super::*;
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerData {
pub username: String,
}
#[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,
pub registration_response: opaque::client::registration::RegistrationResponse,
}
#[derive(Serialize, Deserialize, Clone)]
pub struct ClientRegistrationFinishRequest {
/// Encrypted ServerData from the previous step.
pub server_data: String,
pub registration_upload: opaque::server::registration::RegistrationUpload,
}
}
#[derive(Clone, Serialize, Deserialize)]
pub struct JWTClaims {
pub exp: DateTime<Utc>,
pub iat: DateTime<Utc>,
pub user: String,
pub groups: HashSet<String>,
}