mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-20 06:54:46 +00:00
update jsonwebtoken, futures, and hyper and co
This commit is contained in:
parent
fbcc626478
commit
f425f21ff3
11 changed files with 83 additions and 71 deletions
|
@ -1,17 +1,21 @@
|
|||
use crate::HeaderName;
|
||||
use cookie::CookieJar;
|
||||
use futures::{future, future::Future};
|
||||
use futures_util::{future, future::{FutureExt, TryFutureExt}};
|
||||
use gotham::{
|
||||
handler::HandlerFuture,
|
||||
middleware::{Middleware, NewMiddleware},
|
||||
state::{FromState, State}
|
||||
};
|
||||
use hyper::header::{AUTHORIZATION, HeaderMap};
|
||||
use jsonwebtoken::errors::ErrorKind;
|
||||
use jsonwebtoken::{
|
||||
errors::ErrorKind,
|
||||
DecodingKey
|
||||
};
|
||||
use serde::de::DeserializeOwned;
|
||||
use std::{
|
||||
marker::PhantomData,
|
||||
panic::RefUnwindSafe
|
||||
panic::RefUnwindSafe,
|
||||
pin::Pin
|
||||
};
|
||||
|
||||
pub use jsonwebtoken::Validation as AuthValidation;
|
||||
|
@ -248,7 +252,7 @@ where
|
|||
};
|
||||
|
||||
// validate the token
|
||||
let data : Data = match jsonwebtoken::decode(&token, &secret, &self.validation) {
|
||||
let data : Data = match jsonwebtoken::decode(&token, &DecodingKey::from_secret(&secret), &self.validation) {
|
||||
Ok(data) => data.claims,
|
||||
Err(e) => match dbg!(e.into_kind()) {
|
||||
ErrorKind::ExpiredSignature => return AuthStatus::Expired,
|
||||
|
@ -266,9 +270,9 @@ where
|
|||
Data : DeserializeOwned + Send + 'static,
|
||||
Handler : AuthHandler<Data>
|
||||
{
|
||||
fn call<Chain>(self, mut state : State, chain : Chain) -> Box<HandlerFuture>
|
||||
fn call<Chain>(self, mut state : State, chain : Chain) -> Pin<Box<HandlerFuture>>
|
||||
where
|
||||
Chain : FnOnce(State) -> Box<HandlerFuture>
|
||||
Chain : FnOnce(State) -> Pin<Box<HandlerFuture>>
|
||||
{
|
||||
// put the source in our state, required for e.g. openapi
|
||||
state.put(self.source.clone());
|
||||
|
@ -278,7 +282,7 @@ where
|
|||
state.put(status);
|
||||
|
||||
// call the rest of the chain
|
||||
Box::new(chain(state).and_then(|(state, res)| future::ok((state, res))))
|
||||
chain(state).and_then(|(state, res)| future::ok((state, res))).boxed()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue