firebase_auth/
structs.rs

1use std::time::Duration;
2
3use serde::{Deserialize, Serialize};
4use serde_json::{Map, Value};
5
6#[allow(dead_code)]
7#[derive(Debug)]
8pub struct JwkConfiguration {
9    pub jwk_url: String,
10    pub audience: String,
11    pub issuer: String,
12}
13
14#[derive(Debug, Deserialize)]
15pub struct KeyResponse {
16    pub keys: Vec<JwkKey>,
17}
18
19#[allow(dead_code)]
20#[derive(Clone, Debug, Deserialize)]
21pub struct JwkKey {
22    pub e: String,
23    pub alg: String,
24    pub kty: String,
25    pub kid: String,
26    pub n: String,
27}
28
29/// The Jwt claims decoded from the user token. Can also be viewed as the Firebase User
30/// information.
31#[derive(Serialize, Deserialize, Clone)]
32pub struct FirebaseUser {
33    pub iss: String,
34    pub aud: String,
35    pub sub: String,
36    pub iat: u64,
37    pub exp: u64,
38    pub auth_time: u64,
39    pub user_id: String,
40    pub provider_id: Option<String>,
41    pub name: Option<String>,
42    pub picture: Option<String>,
43    pub email: Option<String>,
44    pub email_verified: Option<bool>,
45    pub firebase: FirebaseProvider,
46}
47
48#[derive(Serialize, Deserialize, Clone)]
49pub struct FirebaseProvider {
50    sign_in_provider: String,
51    identities: Map<String, Value>,
52}
53
54#[derive(Debug, Clone)]
55pub struct JwkKeys {
56    pub keys: Vec<JwkKey>,
57    pub max_age: Duration,
58}
59
60#[derive(Debug)]
61pub enum PublicKeysError {
62    CouldntFetchPublicKeys(reqwest::Error),
63    NoCacheControlHeader,
64    MaxAgeValueEmpty,
65    NonNumericMaxAge,
66    NoMaxAgeSpecified,
67    CannotParsePublicKey(reqwest::Error),
68}