fix(jwt source): cookie from request (#18)

- JwtSource:Bearer renamed to AuthorizationHeader for more consistency with jwt terminology
- documentation added
- the token cookie should be taken from request not from the tower-cookies middleware jar
  - dependency on tower-cookies is no longer needed
- tests added
This commit is contained in:
cduvray 2023-04-09 08:31:39 +02:00 committed by GitHub
parent 3292d59d1c
commit bad5ad18f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 58 deletions

View file

@ -9,7 +9,7 @@ use std::{
};
use axum::{response::Response, routing::get, Json, Router};
use http::{Request, StatusCode};
use http::{header::AUTHORIZATION, Request, StatusCode};
use hyper::Body;
use jwt_authorizer::{JwtAuthorizer, JwtClaims, Refresh, RefreshStrategy};
use lazy_static::lazy_static;
@ -129,7 +129,7 @@ async fn make_proteced_request(app: &mut Router, bearer: &str) -> Response {
.call(
Request::builder()
.uri("/protected")
.header("Authorization", format!("Bearer {bearer}"))
.header(AUTHORIZATION.as_str(), format!("Bearer {bearer}"))
.body(Body::empty())
.unwrap(),
)