Skip to content

Commit f3dae72

Browse files
committed
style: minor formatting cleanup in axum helpers, pkce and examples
1 parent 9f910d6 commit f3dae72

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

authly-axum/src/helpers.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,21 @@ pub async fn get_token(
281281
parts: &Parts,
282282
token_manager: &TokenManager,
283283
) -> Result<authly_token::Claims, AuthlyAxumError> {
284-
let auth_header = parts.headers
284+
let auth_header = parts
285+
.headers
285286
.get(axum::http::header::AUTHORIZATION)
286287
.and_then(|h| h.to_str().ok())
287288
.ok_or_else(|| AuthlyAxumError::Unauthorized("Missing Authorization header".to_string()))?;
288289

289290
if !auth_header.starts_with("Bearer ") {
290-
return Err(AuthlyAxumError::Unauthorized("Invalid Authorization header".to_string()));
291+
return Err(AuthlyAxumError::Unauthorized(
292+
"Invalid Authorization header".to_string(),
293+
));
291294
}
292295

293296
let token = &auth_header[7..];
294-
let claims = token_manager.validate_token(token)
297+
let claims = token_manager
298+
.validate_token(token)
295299
.map_err(|e| AuthlyAxumError::Unauthorized(format!("Invalid token: {}", e)))?;
296300

297301
Ok(claims)

authly-core/src/pkce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
2-
use rand::{Rng, distr::Alphanumeric, rng};
2+
use rand::{distr::Alphanumeric, rng, Rng};
33
use sha2::{Digest, Sha256};
44

55
/// Proof Key for Code Exchange (PKCE) parameters.

examples/axum_oauth.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,13 @@ async fn github_callback(
185185
// --- Google Handlers ---
186186
async fn google_login(State(state): State<AppState>, cookies: Cookies) -> Response {
187187
if let Some(flow) = &state.google_flow {
188-
initiate_oauth_login(flow, &state.session_config, &cookies, &["openid", "email", "profile"])
189-
.into_response()
188+
initiate_oauth_login(
189+
flow,
190+
&state.session_config,
191+
&cookies,
192+
&["openid", "email", "profile"],
193+
)
194+
.into_response()
190195
} else {
191196
(
192197
axum::http::StatusCode::NOT_IMPLEMENTED,
@@ -224,8 +229,13 @@ async fn google_callback(
224229
// --- Discord Handlers ---
225230
async fn discord_login(State(state): State<AppState>, cookies: Cookies) -> Response {
226231
if let Some(flow) = &state.discord_flow {
227-
initiate_oauth_login(flow, &state.session_config, &cookies, &["identify", "email"])
228-
.into_response()
232+
initiate_oauth_login(
233+
flow,
234+
&state.session_config,
235+
&cookies,
236+
&["identify", "email"],
237+
)
238+
.into_response()
229239
} else {
230240
(
231241
axum::http::StatusCode::NOT_IMPLEMENTED,

examples/oidc_generic.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ async fn oidc_login(State(state): State<AppState>, cookies: Cookies) -> impl Int
9292
std::env::var("OIDC_SCOPES").unwrap_or_else(|_| "openid email profile".to_string());
9393
let scope_list: Vec<&str> = scopes.split_whitespace().collect();
9494

95-
initiate_oauth_login(&state.oidc_flow, &state.session_config, &cookies, &scope_list)
95+
initiate_oauth_login(
96+
&state.oidc_flow,
97+
&state.session_config,
98+
&cookies,
99+
&scope_list,
100+
)
96101
}
97102

98103
async fn oidc_callback(

0 commit comments

Comments
 (0)