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

ログ出力を追加した 2 #229

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/sos24-presentation/src/middleware/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use jsonwebtoken::{
decode, decode_header, jwk::JwkSet, Algorithm, DecodingKey, TokenData, Validation,
};
use serde::{Deserialize, Serialize};

use sos24_use_case::context::Context;

use crate::{error::AppError, module::Modules};
Expand All @@ -33,6 +34,8 @@ pub(crate) async fn jwt_auth(
mut request: Request,
next: Next,
) -> Result<impl IntoResponse, AppError> {
tracing::info!("ユーザー認証を行います");

let authorization_header = request.headers().get("Authorization").ok_or(AppError::new(
StatusCode::UNAUTHORIZED,
"auth/missing-authorization-header".to_string(),
Expand Down Expand Up @@ -81,6 +84,7 @@ pub(crate) async fn jwt_auth(
let ctx = Context::new(token.claims.sub.clone());
request.extensions_mut().insert(ctx);

tracing::info!("ユーザー認証が完了しました");
Ok(next.run(request).await)
}

Expand Down