#[non_exhaustive]pub enum AuthRequirement {
Required,
Optional,
None,
}Expand description
Declares whether a command requires an authenticated credential.
This is the policy that the engine enforces; it is separate from the
mechanism of resolution (see CredentialResolver). The default is
Required, which fails closed: the engine
resolves the credential before the handler runs, so a command that should be
gated behind authentication cannot execute unauthenticated even if its
handler never reads the credential, and audit/activity identity is always
populated for it.
--schema and --dry-run short-circuit before the engine resolves a
Required credential, so they never trigger an authentication flow on their
own regardless of requirement.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Required
The engine resolves the credential before the handler runs (fail-closed).
A failure to resolve is rendered as an auth-error and the handler never
runs. This is the default.
Optional
Resolution is deferred to the handler.
The engine does not resolve a credential on the command’s behalf; the
handler (or an authorizer) triggers the auth flow only by calling
CredentialResolver::resolve/try_resolve.
Use for commands that behave differently when authenticated but must still
run when the user is logged out.
None
The command never authenticates and has no credential.
Equivalent to the legacy no_auth(true) marker: default-env injection is
suppressed and CredentialResolver::resolve returns an error.
Implementations§
Source§impl AuthRequirement
impl AuthRequirement
Sourcepub fn is_required(self) -> bool
pub fn is_required(self) -> bool
Returns true when the engine must resolve the credential before the handler runs.
Sourcepub fn is_optional(self) -> bool
pub fn is_optional(self) -> bool
Returns true when resolution is deferred to the handler.
Trait Implementations§
Source§impl Clone for AuthRequirement
impl Clone for AuthRequirement
Source§fn clone(&self) -> AuthRequirement
fn clone(&self) -> AuthRequirement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for AuthRequirement
Source§impl Debug for AuthRequirement
impl Debug for AuthRequirement
Source§impl Default for AuthRequirement
impl Default for AuthRequirement
Source§fn default() -> AuthRequirement
fn default() -> AuthRequirement
impl Eq for AuthRequirement
Source§impl PartialEq for AuthRequirement
impl PartialEq for AuthRequirement
Source§fn eq(&self, other: &AuthRequirement) -> bool
fn eq(&self, other: &AuthRequirement) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for AuthRequirement
Auto Trait Implementations§
impl Freeze for AuthRequirement
impl RefUnwindSafe for AuthRequirement
impl Send for AuthRequirement
impl Sync for AuthRequirement
impl Unpin for AuthRequirement
impl UnsafeUnpin for AuthRequirement
impl UnwindSafe for AuthRequirement
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.