MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / issue_token

Function issue_token

ch_11/src/routes/authentication.rs:91–101  ·  view source on GitHub ↗
(account_id: AccountId)

Source from the content-addressed store, hash-verified

89}
90
91fn issue_token(account_id: AccountId) -> String {
92 let key = make_key();
93
94 let exp = (Utc::now() + chrono::Duration::days(1)).to_rfc3339();
95
96 PasetoBuilder::<V4, PasetoLocal>::default()
97 .set_claim(ExpirationClaim::try_from(exp.as_str()).unwrap())
98 .set_claim(CustomClaim::try_from(("account_id", serde_json::json!(account_id))).unwrap())
99 .build(&key)
100 .expect("Failed to construct paseto token w/ builder!")
101}
102
103pub fn auth() -> impl Filter<Extract = (Session,), Error = warp::Rejection> + Clone {
104 warp::header::<String>("Authorization").and_then(|token: String| {

Callers 2

loginFunction · 0.70
post_questions_authFunction · 0.70

Calls 1

make_keyFunction · 0.70

Tested by

no test coverage detected