Skip to content

Commit 148e4f4

Browse files
author
iOS E2E Implementation
committed
chore(clippy): fix needless-bool in cli deploy and needless-return in control-plane auth; clean unused import in cli tests
1 parent bbd1875 commit 148e4f4

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

crates/aether-cli/tests/logs_command.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use assert_cmd::Command;
22
use predicates::str::contains;
3-
use std::fs;
43

54
fn bin() -> Command { Command::cargo_bin("aether-cli").unwrap() }
65

crates/control-plane/src/auth.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ pub async fn auth_middleware(mut req: Request, next: Next, store: Arc<AuthStore>
110110
let Some(val) = req.headers().get(axum::http::header::AUTHORIZATION) else {
111111
let c = UNAUTH_COUNT.fetch_add(1, Ordering::Relaxed);
112112
if c.is_multiple_of(10) { warn!("auth.unauthorized.missing_header"); }
113-
Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap())
113+
return Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap());
114114
};
115115
let Ok(hdr) = val.to_str() else {
116116
let c = UNAUTH_COUNT.fetch_add(1, Ordering::Relaxed);
117117
if c.is_multiple_of(10) { warn!("auth.unauthorized.bad_header"); }
118-
Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap())
118+
return Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap());
119119
};
120120
let prefix = "Bearer ";
121121
if !hdr.starts_with(prefix) {
122122
let c = UNAUTH_COUNT.fetch_add(1, Ordering::Relaxed);
123123
if c.is_multiple_of(10) { warn!("auth.unauthorized.bad_schema"); }
124-
Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap())
124+
return Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap());
125125
}
126126
let token = &hdr[prefix.len()..];
127127
// Hash the token and lookup
@@ -133,7 +133,7 @@ pub async fn auth_middleware(mut req: Request, next: Next, store: Arc<AuthStore>
133133
if let Some(info) = store.by_hash.get(&arr) {
134134
// Constant-time confirmation (redundant as hash-length fixed, but good practice)
135135
if !ct_eq(&arr, &info.token_hash) {
136-
Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap())
136+
return Err(axum::response::Response::builder().status(StatusCode::UNAUTHORIZED).body(axum::body::Body::empty()).unwrap());
137137
}
138138
// Create stable user_id from sha256(token) first 16 bytes
139139
let hash = Sha256::digest(token.as_bytes());
@@ -157,7 +157,7 @@ pub async fn auth_middleware(mut req: Request, next: Next, store: Arc<AuthStore>
157157
// Route-level RBAC guard; min_role enforced if auth is enabled; otherwise pass-through
158158
pub async fn require_role(req: Request, next: Next, store: Arc<AuthStore>, min_role: Role) -> Result<axum::response::Response, axum::response::Response> {
159159
if !is_auth_enabled(&store) {
160-
Ok(next.run(req).await)
160+
return Ok(next.run(req).await);
161161
}
162162
if let Some(ctx) = req.extensions().get::<UserContext>() {
163163
if ctx.role.allows(min_role) {

0 commit comments

Comments
 (0)