Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions rust/crates/keygo-server/src/api/authenticated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ impl FromRequestParts<AppState> for Authenticated {
}
}

#[cfg_attr(
not(test),
expect(dead_code, reason = "no route requires a fresh sign-in yet")
)]
#[derive(Debug, Error)]
#[error("recent sign-in required")]
pub struct FreshAuthRequired;
Expand All @@ -123,8 +127,10 @@ impl HttpError for FreshAuthRequired {
}
}

#[expect(dead_code, reason = "no route requires a fresh sign-in yet")]
pub struct FreshAuthenticated(Authenticated);

#[expect(dead_code, reason = "no route requires a fresh sign-in yet")]
impl FreshAuthenticated {
pub fn claims(&self) -> &Claims {
self.0.claims()
Expand Down
4 changes: 4 additions & 0 deletions rust/crates/keygo-server/src/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ pub enum ErrorCode {
RegistrationExpired,
LoginExpired,
// session
#[cfg_attr(
not(test),
expect(dead_code, reason = "no route requires a fresh sign-in yet")
)]
FreshAuthRequired,
InvalidToken,
RefreshExpired,
Expand Down
6 changes: 5 additions & 1 deletion rust/crates/keygo-server/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ mod tests {
let body: Value = serde_json::from_slice(&body).unwrap();
assert_eq!(
body,
json!({ "version": env!("CARGO_PKG_VERSION"), "allow_signups": true }),
json!({
"version": env!("CARGO_PKG_VERSION"),
"allow_signups": true,
"public_url": "http://localhost/",
}),
);
}

Expand Down
12 changes: 12 additions & 0 deletions rust/crates/keygo-server/src/domain/access_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ impl Claims {
}
}

#[cfg_attr(
not(test),
expect(dead_code, reason = "no route requires a fresh sign-in yet")
)]
pub fn user_id(&self) -> UserId {
self.user_id
}
Expand All @@ -151,6 +155,10 @@ impl Claims {
self.session_id
}

#[cfg_attr(
not(test),
expect(dead_code, reason = "no route requires a fresh sign-in yet")
)]
pub fn auth_time(&self) -> u64 {
self.auth_time
}
Expand All @@ -159,6 +167,10 @@ impl Claims {
&self.cnf.jkt
}

#[cfg_attr(
not(test),
expect(dead_code, reason = "no route requires a fresh sign-in yet")
)]
pub fn is_fresh(&self) -> bool {
self.is_fresh_at(unix_now())
}
Expand Down
Loading