Skip to content
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

Merged
merged 2 commits into from
Dec 8, 2023
Merged

77 react admin template #80

merged 2 commits into from
Dec 8, 2023

Conversation

indpurvesh
Copy link
Member

JWT token

@indpurvesh indpurvesh self-assigned this Dec 8, 2023
@indpurvesh indpurvesh merged commit dbaed88 into main Dec 8, 2023
7 of 8 checks passed
@indpurvesh indpurvesh deleted the 77-react-admin-template branch December 8, 2023 22:02
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

unused import: Deserialize
@@ -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

unused import: IntoResponse
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

unused import: axum::response::Redirect
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

unused import: serde\_json::json
}

pub async fn require_jwt_authentication<T>(
state: State<Arc<AvoRedState>>,

Check warning

Code scanning / clippy

unused variable: state Warning

unused variable: state
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

variable does not need to be mutable
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

this expression creates a reference which is immediately dereferenced by the compiler
.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

stripping a prefix manually
}).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

this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant