feat: fix incorrect JWT cookie key
This commit is contained in:
@@ -7,6 +7,7 @@ use axum::{
|
||||
response::Response,
|
||||
};
|
||||
use axum_extra::extract::cookie::CookieJar;
|
||||
use tracing::debug;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
@@ -25,6 +26,7 @@ pub async fn require_auth(
|
||||
let token = if let Some(cookie) = cookies.get(JWT_COOKIE_NAME) {
|
||||
cookie.value().to_string()
|
||||
} else {
|
||||
debug!("No JWT cookie found. cookies: {:?}", cookies);
|
||||
return handle_unauthenticated().await;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, from_value};
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::routes::{AppState, api::openapi::tag::AUTH_TAG};
|
||||
use crate::{
|
||||
helpers::constants::JWT_COOKIE_NAME,
|
||||
routes::{AppState, api::openapi::tag::AUTH_TAG},
|
||||
};
|
||||
|
||||
/// Login request payload
|
||||
#[derive(Serialize, Deserialize, utoipa::ToSchema)]
|
||||
@@ -81,7 +84,8 @@ pub async fn login(State(state): State<Arc<AppState>>, Json(payload): Json<Value
|
||||
.header(
|
||||
SET_COOKIE,
|
||||
format!(
|
||||
"token={}; HttpOnly; Path=/; Max-Age={}; SameSite=Strict;",
|
||||
"{}={}; HttpOnly; Path=/; Max-Age={}; SameSite=Strict;",
|
||||
JWT_COOKIE_NAME,
|
||||
jwt,
|
||||
claims.exp - claims.iat
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user