-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
77 react admin template #80
Conversation
use axum::Json; | ||
use axum_extra::extract::cookie::{Cookie, SameSite}; | ||
use jsonwebtoken::{encode, EncodingKey, Header}; | ||
use serde::{Deserialize, Serialize}; |
Check warning
Code scanning / clippy
unused import: Deserialize Warning
@@ -0,0 +1,85 @@ | |||
use std::sync::Arc; | |||
use axum::{http::Request, Json, middleware::Next, response::{IntoResponse, Response}}; |
Check warning
Code scanning / clippy
unused import: IntoResponse Warning
use axum::{http::Request, Json, middleware::Next, response::{IntoResponse, Response}}; | ||
use axum::extract::State; | ||
use axum::http::{header, StatusCode}; | ||
use axum::response::Redirect; |
Check warning
Code scanning / clippy
unused import: axum::response::Redirect Warning
use axum_extra::extract::CookieJar; | ||
use jsonwebtoken::{decode, DecodingKey, Validation}; | ||
use serde::Serialize; | ||
use serde_json::json; |
Check warning
Code scanning / clippy
unused import: serde_json::json Warning
} | ||
|
||
pub async fn require_jwt_authentication<T>( | ||
state: State<Arc<AvoRedState>>, |
Check warning
Code scanning / clippy
unused variable: state Warning
pub async fn require_jwt_authentication<T>( | ||
state: State<Arc<AvoRedState>>, | ||
cookie_jar: CookieJar, | ||
mut req: Request<T>, |
Check warning
Code scanning / clippy
variable does not need to be mutable Warning
let token = encode( | ||
&Header::default(), | ||
&claims, | ||
&EncodingKey::from_secret(&state.config.jwt_secret_key.as_ref()), |
Check warning
Code scanning / clippy
this expression creates a reference which is immediately dereferenced by the compiler Warning
.and_then(|auth_header| auth_header.to_str().ok()) | ||
.and_then(|auth_value| { | ||
if auth_value.starts_with("Bearer ") { | ||
Some(auth_value[7..].to_owned()) |
Check warning
Code scanning / clippy
stripping a prefix manually Warning
}).unwrap() | ||
.claims; | ||
|
||
if claims.sub.len() <= 0 { |
Check failure
Code scanning / clippy
this comparison involving the minimum or maximum element for this type contains a case that is always true or always false Error
JWT token