()
| 101 | } |
| 102 | |
| 103 | pub fn auth() -> impl Filter<Extract = (Session,), Error = warp::Rejection> + Clone { |
| 104 | warp::header::<String>("Authorization").and_then(|token: String| { |
| 105 | let token = match verify_token(token) { |
| 106 | Ok(t) => t, |
| 107 | Err(_) => { |
| 108 | return future::ready(Err(warp::reject::custom( |
| 109 | handle_errors::Error::Unauthorized, |
| 110 | ))) |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | future::ready(Ok(token)) |
| 115 | }) |
| 116 | } |
| 117 | |
| 118 | #[cfg(test)] |
| 119 | mod authentication_tests { |
no test coverage detected