| 102 | } |
| 103 | |
| 104 | fn 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 | |
| 118 | pub fn auth( |
| 119 | ) -> impl Filter<Extract = (Session,), Error = warp::Rejection> + Clone { |