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

Function issue_token

ch_10/src/routes/authentication.rs:107–119  ·  view source on GitHub ↗
(account_id: AccountId)

Source from the content-addressed store, hash-verified

105}
106
107fn issue_token(account_id: AccountId) -> String {
108 let key = make_key();
109
110 let exp = (Utc::now() + chrono::Duration::days(1)).to_rfc3339();
111 let nbf = Utc::now().to_rfc3339();
112
113 PasetoBuilder::<V4, PasetoLocal>::default()
114 .set_claim(ExpirationClaim::try_from(exp.as_str()).unwrap())
115 .set_claim(NotBeforeClaim::try_from(nbf.as_str()).unwrap())
116 .set_claim(CustomClaim::try_from(("account_id", serde_json::json!(account_id))).unwrap())
117 .build(&key)
118 .expect("Failed to construct paseto token w/ builder!")
119}
120
121pub fn auth(
122) -> impl Filter<Extract = (Session,), Error = warp::Rejection> + Clone {

Callers 1

loginFunction · 0.70

Calls 1

make_keyFunction · 0.70

Tested by

no test coverage detected