pub struct CredentialResolver { /* private fields */ }Expand description
Resolves the credential for a single command invocation, memoizing the result.
Resolution — including any interactive browser/OAuth flow — runs at most once:
a handler and an authorizer that both ask share a single resolution, and the
engine resolves it up front for AuthRequirement::Required commands. For
Optional commands resolution is deferred until a
handler or authorizer calls resolve or
try_resolve, and --schema/--dry-run short-circuit
before any resolution happens.
The resolved credential is memoized: a handler and an authorizer that both
ask share a single resolution. Clones share the same underlying state, so the
engine can observe (via peek) whatever a handler resolved.
Implementations§
Source§impl CredentialResolver
impl CredentialResolver
Sourcepub async fn resolve(&self) -> Result<Credential>
pub async fn resolve(&self) -> Result<Credential>
Sourcepub async fn try_resolve(&self) -> Result<Option<Credential>>
pub async fn try_resolve(&self) -> Result<Option<Credential>>
Resolves the credential when one is available.
Returns Ok(None) for no-auth commands, Ok(Some(_)) on success, and
propagates the provider error on failure. Use this for commands whose
auth is genuinely optional; most commands should call
resolve instead.
§Errors
Propagates the auth provider error when resolution is attempted and fails.
Sourcepub fn peek(&self) -> Option<&Credential>
pub fn peek(&self) -> Option<&Credential>
Returns the memoized credential without triggering resolution.
Yields None until something resolves the credential. Used by the engine
to record identity in audit/activity output after a handler runs.
Trait Implementations§
Source§impl Clone for CredentialResolver
impl Clone for CredentialResolver
Source§fn clone(&self) -> CredentialResolver
fn clone(&self) -> CredentialResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more