pub struct AuthSettings { /* private fields */ }Expand description
Authentication settings view/interface over Doc data
Keys are stored by pubkey in the “keys” sub-object. Delegations are stored by root tree ID in the “delegations” sub-object. Global permission is stored in the “global” sub-object.
Implementations§
Source§impl AuthSettings
impl AuthSettings
Sourcepub fn as_doc_mut(&mut self) -> &mut Doc
pub fn as_doc_mut(&mut self) -> &mut Doc
Get mutable access to the underlying Doc
Sourcepub fn add_key(&mut self, pubkey: &PublicKey, key: AuthKey) -> Result<()>
pub fn add_key(&mut self, pubkey: &PublicKey, key: AuthKey) -> Result<()>
Add a new authentication key by pubkey (fails if key already exists)
§Arguments
pubkey- The public keykey- The AuthKey containing permissions, status, and optional name
Sourcepub fn overwrite_key(&mut self, pubkey: &PublicKey, key: AuthKey) -> Result<()>
pub fn overwrite_key(&mut self, pubkey: &PublicKey, key: AuthKey) -> Result<()>
Explicitly overwrite an existing authentication key
Sourcepub fn get_key_by_pubkey(&self, pubkey: &PublicKey) -> Result<AuthKey>
pub fn get_key_by_pubkey(&self, pubkey: &PublicKey) -> Result<AuthKey>
Get a key by its public key
Sourcepub fn find_keys_by_name(&self, name: &str) -> Vec<(String, AuthKey)>
pub fn find_keys_by_name(&self, name: &str) -> Vec<(String, AuthKey)>
Find keys by name (may return multiple if names collide)
Returns Vec of (pubkey, AuthKey) tuples sorted by pubkey for deterministic ordering.
Sourcepub fn rename_key(
&mut self,
pubkey: &PublicKey,
name: Option<&str>,
) -> Result<()>
pub fn rename_key( &mut self, pubkey: &PublicKey, name: Option<&str>, ) -> Result<()>
Rename a key by pubkey
Updates only the display name of an existing key, preserving its permissions and status.
Sourcepub fn revoke_key(&mut self, pubkey: &PublicKey) -> Result<()>
pub fn revoke_key(&mut self, pubkey: &PublicKey) -> Result<()>
Revoke a key by pubkey
Sourcepub fn add_delegated_tree(&mut self, tree_ref: DelegatedTreeRef) -> Result<()>
pub fn add_delegated_tree(&mut self, tree_ref: DelegatedTreeRef) -> Result<()>
Add or update a delegated tree reference
The delegation is stored by root tree ID, extracted from tree_ref.tree.root.
This ensures collision-resistant storage similar to key storage by pubkey.
Sourcepub fn get_delegated_tree(&self, root_id: &ID) -> Result<DelegatedTreeRef>
pub fn get_delegated_tree(&self, root_id: &ID) -> Result<DelegatedTreeRef>
Get a delegated tree reference by root tree ID
Sourcepub fn get_delegated_tree_by_str(
&self,
root_id: &str,
) -> Result<DelegatedTreeRef>
pub fn get_delegated_tree_by_str( &self, root_id: &str, ) -> Result<DelegatedTreeRef>
Get a delegated tree reference by root tree ID string
This variant accepts a string directly, useful when the ID comes from
a DelegationStep.tree field which stores the root ID as a string.
Sourcepub fn get_all_delegated_trees(&self) -> Result<HashMap<ID, DelegatedTreeRef>>
pub fn get_all_delegated_trees(&self) -> Result<HashMap<ID, DelegatedTreeRef>>
Get all delegated tree references
Returns a map from root tree ID to the delegation reference.
Sourcepub fn set_global_permission(&mut self, key: AuthKey)
pub fn set_global_permission(&mut self, key: AuthKey)
Set the global permission
Stores the global permission at the global path, separate from
individual key entries in the keys namespace.
Sourcepub fn get_global_key(&self) -> Result<AuthKey>
pub fn get_global_key(&self) -> Result<AuthKey>
Get the global permission AuthKey
Reads from the global path.
Sourcepub fn resolve_hint(&self, hint: &KeyHint) -> Result<Vec<ResolvedAuth>>
pub fn resolve_hint(&self, hint: &KeyHint) -> Result<Vec<ResolvedAuth>>
Resolve a key hint to matching authentication info
Returns Vec of ResolvedAuth. For pubkey hints, returns at most one. For name hints, may return multiple if names collide. Caller should try each until signature verifies.
§Name Collision Handling
When multiple keys share the same name, all matching keys are returned.
The caller (typically validate_entry) should iterate through the matches
and attempt signature verification with each until one succeeds.
Sourcepub fn has_global_permission(&self) -> bool
pub fn has_global_permission(&self) -> bool
Check if global permission exists and is active
Sourcepub fn get_global_permission(&self) -> Option<Permission>
pub fn get_global_permission(&self) -> Option<Permission>
Get global permission level if it exists and is active
Sourcepub fn global_permission_grants_access(
&self,
requested_permission: &Permission,
) -> bool
pub fn global_permission_grants_access( &self, requested_permission: &Permission, ) -> bool
Check if global permission grants sufficient access
Sourcepub fn can_access(
&self,
pubkey: &PublicKey,
requested_permission: &Permission,
) -> bool
pub fn can_access( &self, pubkey: &PublicKey, requested_permission: &Permission, ) -> bool
Check if a public key can access the database with the requested permission
Sourcepub fn find_all_sigkeys_for_pubkey(
&self,
pubkey: &PublicKey,
) -> Vec<(SigKey, Permission)>
pub fn find_all_sigkeys_for_pubkey( &self, pubkey: &PublicKey, ) -> Vec<(SigKey, Permission)>
Find all SigKeys that a public key can use to access this database
Returns (SigKey, Permission) tuples sorted by permission (highest first)
Sourcepub fn resolve_sig_key_for_operation(
&self,
pubkey: &PublicKey,
) -> Result<(SigKey, Permission)>
pub fn resolve_sig_key_for_operation( &self, pubkey: &PublicKey, ) -> Result<(SigKey, Permission)>
Resolve which SigKey should be used for an operation
Returns the SigKey with highest permission for the given pubkey.
Sourcepub fn can_modify_key(
&self,
signing_key: &ResolvedAuth,
target_pubkey: &PublicKey,
) -> Result<bool>
pub fn can_modify_key( &self, signing_key: &ResolvedAuth, target_pubkey: &PublicKey, ) -> Result<bool>
Check if a signing key can modify an existing target key
Sourcepub fn can_create_key(
&self,
signing_key: &ResolvedAuth,
new_key_permissions: &Permission,
) -> Result<bool>
pub fn can_create_key( &self, signing_key: &ResolvedAuth, new_key_permissions: &Permission, ) -> Result<bool>
Check if a signing key can create a new key with the specified permissions
Trait Implementations§
Source§impl Clone for AuthSettings
impl Clone for AuthSettings
Source§fn clone(&self) -> AuthSettings
fn clone(&self) -> AuthSettings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthSettings
impl Debug for AuthSettings
Source§impl Default for AuthSettings
impl Default for AuthSettings
Source§impl<'de> Deserialize<'de> for AuthSettings
impl<'de> Deserialize<'de> for AuthSettings
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<AuthSettings> for Doc
impl From<AuthSettings> for Doc
Source§fn from(settings: AuthSettings) -> Doc
fn from(settings: AuthSettings) -> Doc
Source§impl From<Doc> for AuthSettings
impl From<Doc> for AuthSettings
Auto Trait Implementations§
impl Freeze for AuthSettings
impl RefUnwindSafe for AuthSettings
impl Send for AuthSettings
impl Sync for AuthSettings
impl Unpin for AuthSettings
impl UnwindSafe for AuthSettings
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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more