From a3bc90d6755acbe3670dfcf23f35acdaf9b00ffc Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sat, 10 Apr 2021 15:49:26 +0300 Subject: %(date +'%Y%m%d') --- src/auth.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/auth.rs') diff --git a/src/auth.rs b/src/auth.rs index 03930f0..65d639b 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -66,18 +66,25 @@ struct Claims { #[derive(Debug)] struct RateLimited; +#[derive(Debug, Clone)] +pub struct Pubkey { + a: String, +} + impl Reject for RateLimited {} pub fn with_auth( db: Db, t: Transaction, -) -> impl Filter + Clone { +) -> impl Filter + Clone { headers_cloned() - .map(move |headers: HeaderMap| (db.clone(), headers)) + .map(move |headers: HeaderMap| (db.clone(), headers, t.source.clone())) .and_then(authorize) } -async fn authorize((db, headers): (Db, HeaderMap)) -> Result { +async fn authorize( + (db, headers, source): (Db, HeaderMap, String), +) -> Result { match jwt_from_header(&headers) { Ok(jwt) => { let decoded = decode::( @@ -89,7 +96,9 @@ async fn authorize((db, headers): (Db, HeaderMap)) -> Result return Err(warp::reject::custom(RateLimited)), } -- cgit v1.2.3-70-g09d2