MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / is_token_expired

Function is_token_expired

crates/openshell-bootstrap/src/oidc_token.rs:82–92  ·  view source on GitHub ↗

Check if the stored access token is expired or near expiry. Returns `true` if the token expires within the next 30 seconds.

(bundle: &OidcTokenBundle)

Source from the content-addressed store, hash-verified

80///
81/// Returns `true` if the token expires within the next 30 seconds.
82pub fn is_token_expired(bundle: &OidcTokenBundle) -> bool {
83 let Some(expires_at) = bundle.expires_at else {
84 // No expiry info — assume valid.
85 return false;
86 };
87 let now = std::time::SystemTime::now()
88 .duration_since(std::time::UNIX_EPOCH)
89 .unwrap_or_default()
90 .as_secs();
91 now + 30 >= expires_at
92}
93
94#[cfg(test)]
95mod tests {

Callers 4

connect_to_gatewayFunction · 0.85
ensure_valid_oidc_tokenFunction · 0.85
apply_authFunction · 0.85
completion_grpc_clientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected