MCPcopy Index your code
hub / github.com/Rust-Web-Development/code / issue_token

Function issue_token

ch_09/src/routes/authentication.rs:104–116  ·  view source on GitHub ↗
(account_id: AccountId)

Source from the content-addressed store, hash-verified

102}
103
104fn issue_token(account_id: AccountId) -> String {
105 let key = make_key();
106
107 let exp = (Utc::now() + chrono::Duration::days(1)).to_rfc3339();
108 let nbf = Utc::now().to_rfc3339();
109
110 PasetoBuilder::<V4, PasetoLocal>::default()
111 .set_claim(ExpirationClaim::try_from(exp.as_str()).unwrap())
112 .set_claim(NotBeforeClaim::try_from(nbf.as_str()).unwrap())
113 .set_claim(CustomClaim::try_from(("account_id", serde_json::json!(account_id))).unwrap())
114 .build(&key)
115 .expect("Failed to construct paseto token w/ builder!")
116}
117
118pub fn auth(
119) -> 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