drogue_client/user/v1/data/
authn.rs

1use crate::{
2    metrics::{AsPassFail, PassFail},
3    user::v1::UserDetails,
4};
5use serde::{Deserialize, Serialize};
6
7/// Authenticate a user using a password request.
8#[derive(Clone, Debug, Serialize, Deserialize)]
9pub struct AuthenticationRequest {
10    pub user_id: String,
11    pub access_token: String,
12}
13
14/// The outcome of an authentication request.
15#[derive(Clone, Debug, Deserialize, Serialize)]
16pub enum Outcome {
17    Known(UserDetails),
18    Unknown,
19}
20
21/// The result of an authentication request.
22#[derive(Clone, Debug, Deserialize, Serialize)]
23pub struct AuthenticationResponse {
24    /// The outcome, of the request.
25    pub outcome: Outcome,
26}
27
28impl AsPassFail for AuthenticationResponse {
29    fn as_pass_fail(&self) -> PassFail {
30        match self.outcome {
31            Outcome::Known(_) => PassFail::Pass,
32            Outcome::Unknown => PassFail::Fail,
33        }
34    }
35}