summaryrefslogtreecommitdiffstats
path: root/src/auth/types.rs
blob: 8889b63445c69bb016152cf46aaec67c21874c68 (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
use chrono::{DateTime, Utc};
use multimap::MultiMap;
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: Uuid,
    pub(super) auth_token: Option<Token>,
    pub(super) xbl_token: Option<Token>,
    pub(super) refresh_token: Option<Token>
}

#[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>
}