2021-07-05 08:00:13 +00:00
|
|
|
#![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::*;
|
|
|
|
|
2021-06-23 18:33:36 +00:00
|
|
|
#[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 {
|
2021-06-23 18:33:36 +00:00
|
|
|
/// 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 {
|
2021-06-23 18:33:36 +00:00
|
|
|
/// 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.
|
2021-06-24 16:23:23 +00:00
|
|
|
/// It is used to reset a user's password.
|
2021-06-16 17:12:41 +00:00
|
|
|
pub mod registration {
|
|
|
|
use super::*;
|
|
|
|
|
2021-06-23 18:33:36 +00:00
|
|
|
#[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 {
|
2021-06-23 18:33:36 +00:00
|
|
|
/// 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 {
|
2021-06-23 18:33:36 +00:00
|
|
|
/// 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>,
|
|
|
|
}
|