framework_cqrs_lib/cqrs/infra/token/
jwt_claims.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::collections::HashMap;

use chrono::Utc;
use serde::{Deserialize, Serialize};

use crate::cqrs::core::context::Context;

impl From<JwtClaims> for Context {
    fn from(value: JwtClaims) -> Self {
        Self {
            subject: value.sub,
            now: Utc::now(),
            meta: HashMap::new(),
            filters: HashMap::new(),
        }
    }
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct JwtClaims {
    pub sub: String,
    pub exp: u64,
}