pub struct SshAuthCredentials {
pub pubkey: String,
pub signature: String,
pub timestamp: i64,
pub nonce: String,
}Expand description
SSH authentication credentials for gRPC metadata.
Contains all the fields needed to authenticate with coven-gateway:
pubkey: OpenSSH format public keysignature: Base64-encoded SSH signature oftimestamp|noncetimestamp: Unix timestamp when credentials were creatednonce: Random hex string to prevent replay attacks
Fields§
§pubkey: StringOpenSSH format public key string.
signature: StringBase64-encoded SSH signature of the message {timestamp}|{nonce}.
timestamp: i64Unix timestamp when these credentials were created.
nonce: StringRandom nonce to prevent replay attacks.
Implementations§
Source§impl SshAuthCredentials
impl SshAuthCredentials
Sourcepub fn new(private_key: &PrivateKey) -> Result<Self>
pub fn new(private_key: &PrivateKey) -> Result<Self>
Create new authentication credentials by signing timestamp|nonce.
Generates a fresh timestamp and nonce, signs the combined message, and packages everything needed for gRPC authentication.
§Errors
Returns an error if signing fails or the public key cannot be serialized.
Sourcepub fn age_secs(&self) -> i64
pub fn age_secs(&self) -> i64
Get the age of these credentials in seconds.
Returns the number of seconds since these credentials were created.
Sourcepub fn is_stale(&self, ttl_secs: i64) -> bool
pub fn is_stale(&self, ttl_secs: i64) -> bool
Check if these credentials are stale and should be refreshed.
Credentials are considered stale if they are older than the given TTL. The gateway rejects signatures older than 5 minutes (300 seconds), so a typical TTL would be 240 seconds (4 minutes) to refresh early.
Sourcepub fn apply_to_request<T>(&self, req: &mut Request<T>) -> Result<()>
pub fn apply_to_request<T>(&self, req: &mut Request<T>) -> Result<()>
Apply credentials to a gRPC request as metadata headers.
Adds the following headers to the request:
x-ssh-pubkey: The OpenSSH format public keyx-ssh-signature: The base64-encoded signaturex-ssh-timestamp: The Unix timestamp as a stringx-ssh-nonce: The random nonce
§Errors
Returns an error if any metadata value is invalid.
Trait Implementations§
Source§impl Clone for SshAuthCredentials
impl Clone for SshAuthCredentials
Source§fn clone(&self) -> SshAuthCredentials
fn clone(&self) -> SshAuthCredentials
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SshAuthCredentials
impl RefUnwindSafe for SshAuthCredentials
impl Send for SshAuthCredentials
impl Sync for SshAuthCredentials
impl Unpin for SshAuthCredentials
impl UnwindSafe for SshAuthCredentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request