summaryrefslogtreecommitdiffstats
path: root/src/auth/types.rs
blob: f45565774ba8e351e16d12a5b916d73c4ae8b94b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use chrono::{DateTime, Utc};
use multimap::MultiMap;
use oauth2::RefreshToken;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Debug, Serialize, Deserialize)]
pub struct Property {
    pub value: String,
    pub signature: Option<String>
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UserProfile {
    pub uuid: Option<Uuid>,
    pub name: Option<String>,

    #[serde(default, skip_serializing_if = "MultiMap::is_empty")]
    pub properties: MultiMap<String, Property>
}

#[derive(Debug, Serialize, Deserialize)]
pub(super) struct Token {
    pub value: String,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub expire: Option<DateTime<Utc>>
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MsaUser {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub profile: Option<UserProfile>,
    pub xuid: Option<Uuid>,

    pub(super) client_id: oauth2::ClientId,

    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
    pub(super) is_azure_client_id: bool,

    pub(super) auth_token: Option<Token>,
    pub(super) xbl_token: Option<Token>,
    pub(super) refresh_token: Option<RefreshToken>
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum User {
    Dummy(UserProfile),
    MSA(MsaUser)
}

#[derive(Debug, Serialize, Deserialize)]
pub struct AuthenticationDatabase {
    pub users: Vec<User>
}