Struct kanidmd_lib::entry::Entry
source · pub struct Entry<VALID, STATE> { /* private fields */ }
Expand description
Entry is the core data storage type of the server. Almost every aspect of the server is designed to read, handle and manipulate entries.
Entries store attribute value assertions, or AVA. These are sets of key-values.
Entries have a lifecycle within a single operation, and as part of replication.
The lifecycle for operations is defined through state and valid types. Each entry has a pair
Of these types at anytime. The first is the AVA schema
and access
control assertion
state. This is represented by the type VALID
as one of EntryValid
, EntryInvalid
or
EntryReduced
. Every entry starts as EntryInvalid
, and when checked by the schema for
correctness, transitions to EntryValid
. While an entry is EntryValid
it can not be
altered - you must invalidate it to EntryInvalid
, then modify, then check again.
An entry that has had access controls applied moves from EntryValid
to EntryReduced
,
to show that the AVAs have reduced to the valid read set of the current event
user.
The second type of STATE
represents the database commit state and internal db ID’s. A
new entry that has never been committed is EntryNew
, but an entry that has been retrieved
from the database is EntryCommitted
. This affects the operations you can apply IE modify
or delete.
These types exist to prevent at compile time, mishandling of Entries, to ensure they are always handled with the correct lifecycles and processes.
Implementations§
source§impl Entry<EntryInit, EntryNew>
impl Entry<EntryInit, EntryNew>
pub fn new() -> Self
sourcepub fn from_proto_entry(
e: &ProtoEntry,
qs: &mut QueryServerWriteTransaction<'_>
) -> Result<Self, OperationError>
pub fn from_proto_entry(
e: &ProtoEntry,
qs: &mut QueryServerWriteTransaction<'_>
) -> Result<Self, OperationError>
Consume a Protocol Entry from JSON, and validate and process the data into an internal
Entry
type.
sourcepub fn from_proto_entry_str(
es: &str,
qs: &mut QueryServerWriteTransaction<'_>
) -> Result<Self, OperationError>
pub fn from_proto_entry_str(
es: &str,
qs: &mut QueryServerWriteTransaction<'_>
) -> Result<Self, OperationError>
Given a proto entry in JSON formed as a serialised string, processed that string into an Entry.
sourcepub fn assign_cid(
self,
cid: Cid,
schema: &dyn SchemaTransaction
) -> Entry<EntryInvalid, EntryNew>
pub fn assign_cid(
self,
cid: Cid,
schema: &dyn SchemaTransaction
) -> Entry<EntryInvalid, EntryNew>
Assign the Change Identifier to this Entry, allowing it to be modified and then
written to the Backend
sourcepub fn compare(&self, rhs: &Entry<EntrySealed, EntryCommitted>) -> bool
pub fn compare(&self, rhs: &Entry<EntrySealed, EntryCommitted>) -> bool
Compare this entry to another.
sourcepub fn add_ava(&mut self, attr: &str, value: Value)
pub fn add_ava(&mut self, attr: &str, value: Value)
Add an attribute-value-assertion to this Entry.
sourcepub fn set_ava<T>(&mut self, attr: &str, iter: T)where
T: IntoIterator<Item = Value>,
pub fn set_ava<T>(&mut self, attr: &str, iter: T)where
T: IntoIterator<Item = Value>,
Replace the existing content of an attribute set of this Entry, with a new set of Values.
pub fn get_ava_mut(&mut self, attr: &str) -> Option<&mut ValueSet>
source§impl Entry<EntryRefresh, EntryNew>
impl Entry<EntryRefresh, EntryNew>
pub fn from_repl_entry_v1(
repl_entry: &ReplEntryV1
) -> Result<Self, OperationError>
source§impl<STATE> Entry<EntryRefresh, STATE>
impl<STATE> Entry<EntryRefresh, STATE>
pub fn validate(
self,
schema: &dyn SchemaTransaction
) -> Result<Entry<EntryValid, STATE>, SchemaError>
source§impl<STATE> Entry<EntryInvalid, STATE>
impl<STATE> Entry<EntryInvalid, STATE>
sourcepub fn validate(
self,
schema: &dyn SchemaTransaction
) -> Result<Entry<EntryValid, STATE>, SchemaError>
pub fn validate(
self,
schema: &dyn SchemaTransaction
) -> Result<Entry<EntryValid, STATE>, SchemaError>
Validate that this entry and its attribute-value sets are conformant to the system’s’ schema and the relevant syntaxes.
source§impl Entry<EntryInvalid, EntryCommitted>
impl Entry<EntryInvalid, EntryCommitted>
sourcepub fn to_recycled(self) -> Self
pub fn to_recycled(self) -> Self
Convert this entry into a recycled entry, that is “in the recycle bin”.
sourcepub fn to_revived(self) -> Self
pub fn to_revived(self) -> Self
Convert this entry into a recycled entry, that is “in the recycle bin”.
source§impl Entry<EntrySealed, EntryNew>
impl Entry<EntrySealed, EntryNew>
sourcepub fn into_sealed_committed_id(
self,
id: u64
) -> Entry<EntrySealed, EntryCommitted>
pub fn into_sealed_committed_id(
self,
id: u64
) -> Entry<EntrySealed, EntryCommitted>
Given this validated and sealed entry, process it with a Backend
ID number so that it
can be then serialised to the database.
pub fn compare(&self, rhs: &Entry<EntrySealed, EntryNew>) -> bool
source§impl<VALID> Entry<VALID, EntryCommitted>
impl<VALID> Entry<VALID, EntryCommitted>
source§impl Entry<EntrySealed, EntryCommitted>
impl Entry<EntrySealed, EntryCommitted>
sourcepub fn insert_claim(&mut self, value: &str)
pub fn insert_claim(&mut self, value: &str)
Insert a claim to this entry. This claim can NOT be persisted to disk, this is only used during a single Event session.
pub fn compare(&self, rhs: &Entry<EntrySealed, EntryCommitted>) -> bool
sourcepub fn to_dbentry(&self) -> DbEntry
pub fn to_dbentry(&self) -> DbEntry
Serialise this entry to it’s Database format ready for storage.
pub fn from_dbentry(db_e: DbEntry, id: u64) -> Option<Self>
sourcepub unsafe fn into_reduced(self) -> Entry<EntryReduced, EntryCommitted>
pub unsafe fn into_reduced(self) -> Entry<EntryReduced, EntryCommitted>
Safety
This function bypasses the access control validation logic and should NOT be used without special care and attention to ensure that no private data is leaked incorrectly to clients. Generally this is ONLY used inside of the access control processing functions which correctly applies the reduction steps.
sourcepub fn reduce_attributes(
&self,
allowed_attrs: &BTreeSet<&str>
) -> Entry<EntryReduced, EntryCommitted>
pub fn reduce_attributes(
&self,
allowed_attrs: &BTreeSet<&str>
) -> Entry<EntryReduced, EntryCommitted>
Given a set of attributes that are allowed to be seen on this entry, process and remove all other values that are NOT allowed in this query.
sourcepub fn to_tombstone(&self, cid: Cid) -> Entry<EntryInvalid, EntryCommitted>
pub fn to_tombstone(&self, cid: Cid) -> Entry<EntryInvalid, EntryCommitted>
Convert this recycled entry, into a tombstone ready for reaping.
sourcepub fn into_valid(
self,
ecstate: EntryChangeState
) -> Entry<EntryValid, EntryCommitted>
pub fn into_valid(
self,
ecstate: EntryChangeState
) -> Entry<EntryValid, EntryCommitted>
Given a current transaction change identifier, mark this entry as valid and committed.
pub fn verify(
&self,
schema: &dyn SchemaTransaction,
results: &mut Vec<Result<(), ConsistencyError>>
)
source§impl<STATE> Entry<EntryValid, STATE>
impl<STATE> Entry<EntryValid, STATE>
pub fn invalidate(
self,
cid: Cid,
ecstate: EntryChangeState
) -> Entry<EntryInvalid, STATE>
pub fn seal(self, schema: &dyn SchemaTransaction) -> Entry<EntrySealed, STATE>
pub fn get_uuid(&self) -> Uuid
source§impl<STATE> Entry<EntrySealed, STATE>
impl<STATE> Entry<EntrySealed, STATE>
pub fn invalidate(self, cid: Cid) -> Entry<EntryInvalid, STATE>
pub fn get_uuid(&self) -> Uuid
pub fn get_changestate(&self) -> &EntryChangeState
source§impl Entry<EntryReduced, EntryCommitted>
impl Entry<EntryReduced, EntryCommitted>
pub fn get_uuid(&self) -> Uuid
sourcepub fn to_pe(
&self,
qs: &mut QueryServerReadTransaction<'_>
) -> Result<ProtoEntry, OperationError>
pub fn to_pe(
&self,
qs: &mut QueryServerReadTransaction<'_>
) -> Result<ProtoEntry, OperationError>
Transform this reduced entry into a JSON protocol form that can be sent to clients.
sourcepub fn to_ldap(
&self,
qs: &mut QueryServerReadTransaction<'_>,
basedn: &str,
all_attrs: bool,
l_attrs: &[String]
) -> Result<LdapSearchResultEntry, OperationError>
pub fn to_ldap(
&self,
qs: &mut QueryServerReadTransaction<'_>,
basedn: &str,
all_attrs: bool,
l_attrs: &[String]
) -> Result<LdapSearchResultEntry, OperationError>
Transform this reduced entry into an LDAP form that can be sent to clients.
source§impl<VALID, STATE> Entry<VALID, STATE>
impl<VALID, STATE> Entry<VALID, STATE>
sourcepub fn get_ava_names(&self) -> impl Iterator<Item = &str>
pub fn get_ava_names(&self) -> impl Iterator<Item = &str>
Get an iterator over the current set of attribute names that this entry contains.
sourcepub fn get_ava(&self) -> &Eattrs
pub fn get_ava(&self) -> &Eattrs
Get an iterator over the current set of values for an attribute name.
pub fn get_ava_iter(&self) -> impl Iterator<Item = (&AttrString, &ValueSet)>
sourcepub fn get_ava_set(&self, attr: &str) -> Option<&ValueSet>
pub fn get_ava_set(&self, attr: &str) -> Option<&ValueSet>
Return a reference to the current set of values that are associated to this attribute.
pub fn get_ava_refer(&self, attr: &str) -> Option<&BTreeSet<Uuid>>
pub fn get_ava_as_iutf8_iter(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
pub fn get_ava_as_iutf8(&self, attr: &str) -> Option<&BTreeSet<String>>
pub fn get_ava_as_oauthscopes(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
pub fn get_ava_as_oauthscopemaps(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, BTreeSet<String>>>
pub fn get_ava_as_intenttokens(
&self,
attr: &str
) -> Option<&BTreeMap<String, IntentTokenState>>
pub fn get_ava_as_session_map(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, Session>>
pub fn get_ava_as_apitoken_map(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, ApiToken>>
pub fn get_ava_as_oauth2session_map(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, Oauth2Session>>
sourcepub fn get_ava_iter_iname(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
pub fn get_ava_iter_iname(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
If possible, return an iterator over the set of values transformed into a &str
.
sourcepub fn get_ava_iter_iutf8(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
pub fn get_ava_iter_iutf8(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
If possible, return an iterator over the set of values transformed into a &str
.
sourcepub fn get_ava_as_refuuid(
&self,
attr: &str
) -> Option<Box<dyn Iterator<Item = Uuid> + '_>>
pub fn get_ava_as_refuuid(
&self,
attr: &str
) -> Option<Box<dyn Iterator<Item = Uuid> + '_>>
If possible, return an iterator over the set of values transformed into a Uuid
.
sourcepub fn get_ava_iter_sshpubkeys(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
pub fn get_ava_iter_sshpubkeys(
&self,
attr: &str
) -> Option<impl Iterator<Item = &str>>
If possible, return an iterator over the set of ssh key values transformed into a &str
.
sourcepub fn get_ava_single(&self, attr: &str) -> Option<Value>
pub fn get_ava_single(&self, attr: &str) -> Option<Value>
Return a single value of this attributes name, or None
if it is NOT present, or
there are multiple values present (ambiguous).
pub fn get_ava_single_proto_string(&self, attr: &str) -> Option<String>
sourcepub fn get_ava_single_bool(&self, attr: &str) -> Option<bool>
pub fn get_ava_single_bool(&self, attr: &str) -> Option<bool>
Return a single bool, if valid to transform this value into a boolean.
sourcepub fn get_ava_single_uint32(&self, attr: &str) -> Option<u32>
pub fn get_ava_single_uint32(&self, attr: &str) -> Option<u32>
Return a single uint32, if valid to transform this value.
sourcepub fn get_ava_single_syntax(&self, attr: &str) -> Option<SyntaxType>
pub fn get_ava_single_syntax(&self, attr: &str) -> Option<SyntaxType>
Return a single syntax type, if valid to transform this value.
sourcepub fn get_ava_single_credential(&self, attr: &str) -> Option<&Credential>
pub fn get_ava_single_credential(&self, attr: &str) -> Option<&Credential>
Return a single credential, if valid to transform this value.
sourcepub fn get_ava_passkeys(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, (String, PasskeyV4)>>
pub fn get_ava_passkeys(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, (String, PasskeyV4)>>
Get the set of passkeys on this account, if any are present.
sourcepub fn get_ava_devicekeys(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, (String, DeviceKeyV4)>>
pub fn get_ava_devicekeys(
&self,
attr: &str
) -> Option<&BTreeMap<Uuid, (String, DeviceKeyV4)>>
Get the set of devicekeys on this account, if any are present.
sourcepub fn get_ava_uihint(&self, attr: &str) -> Option<&BTreeSet<UiHint>>
pub fn get_ava_uihint(&self, attr: &str) -> Option<&BTreeSet<UiHint>>
Get the set of uihints on this account, if any are present.
sourcepub fn get_ava_single_secret(&self, attr: &str) -> Option<&str>
pub fn get_ava_single_secret(&self, attr: &str) -> Option<&str>
Return a single secret value, if valid to transform this value.
sourcepub fn get_ava_single_datetime(&self, attr: &str) -> Option<OffsetDateTime>
pub fn get_ava_single_datetime(&self, attr: &str) -> Option<OffsetDateTime>
Return a single datetime, if valid to transform this value.
sourcepub fn get_ava_single_url(&self, attr: &str) -> Option<&Url>
pub fn get_ava_single_url(&self, attr: &str) -> Option<&Url>
Return a single &Url
, if valid to transform this value.
pub fn get_ava_single_uuid(&self, attr: &str) -> Option<Uuid>
pub fn get_ava_single_refer(&self, attr: &str) -> Option<Uuid>
pub fn get_ava_mail_primary(&self, attr: &str) -> Option<&str>
pub fn get_ava_iter_mail(&self, attr: &str) -> Option<impl Iterator<Item = &str>>
sourcepub fn get_ava_single_protofilter(&self, attr: &str) -> Option<&ProtoFilter>
pub fn get_ava_single_protofilter(&self, attr: &str) -> Option<&ProtoFilter>
Return a single protocol filter, if valid to transform this value.
pub fn get_ava_single_private_binary(&self, attr: &str) -> Option<&[u8]>
pub fn get_ava_single_jws_key_es256(&self, attr: &str) -> Option<&JwsSigner>
sourcepub fn attribute_pres(&self, attr: &str) -> bool
pub fn attribute_pres(&self, attr: &str) -> bool
Assert if an attribute of this name is present on this entry.
sourcepub fn attribute_equality(&self, attr: &str, value: &PartialValue) -> bool
pub fn attribute_equality(&self, attr: &str, value: &PartialValue) -> bool
Assert if an attribute of this name is present, and one of it’s values contains the an exact match of this partial value.
sourcepub fn attribute_substring(&self, attr: &str, subvalue: &PartialValue) -> bool
pub fn attribute_substring(&self, attr: &str, subvalue: &PartialValue) -> bool
Assert if an attribute of this name is present, and one of it’s values contains the following substring, if possible to perform the substring comparison.
sourcepub fn attribute_lessthan(&self, attr: &str, subvalue: &PartialValue) -> bool
pub fn attribute_lessthan(&self, attr: &str, subvalue: &PartialValue) -> bool
Assert if an attribute of this name is present, and one of it’s values is less than the following partial value
sourcepub fn entry_match_no_index(&self, filter: &Filter<FilterValidResolved>) -> bool
pub fn entry_match_no_index(&self, filter: &Filter<FilterValidResolved>) -> bool
Test if the following filter applies to and matches this entry.
sourcepub fn filter_from_attrs(
&self,
attrs: &[AttrString]
) -> Option<Filter<FilterInvalid>>
pub fn filter_from_attrs(
&self,
attrs: &[AttrString]
) -> Option<Filter<FilterInvalid>>
Given this entry, generate a filter containing the requested attributes strings as equality components.
sourcepub fn gen_modlist_assert(
&self,
schema: &dyn SchemaTransaction
) -> Result<ModifyList<ModifyInvalid>, SchemaError>
pub fn gen_modlist_assert(
&self,
schema: &dyn SchemaTransaction
) -> Result<ModifyList<ModifyInvalid>, SchemaError>
Given this entry, generate a modification list that would “assert” another entry is in the same/identical attribute state.
sourcepub fn mask_recycled_ts(&self) -> Option<&Self>
pub fn mask_recycled_ts(&self) -> Option<&Self>
Determine if this entry is recycled or a tombstone, and map that to “None”. This allows filter_map to effectively remove entries that should not be considered as “alive”.
sourcepub fn mask_recycled(&self) -> Option<&Self>
pub fn mask_recycled(&self) -> Option<&Self>
Determine if this entry is recycled, and map that to “None”. This allows filter_map to effectively remove entries that are recycled in some cases.
sourcepub fn mask_tombstone(&self) -> Option<&Self>
pub fn mask_tombstone(&self) -> Option<&Self>
Determine if this entry is a tombstone, and map that to “None”. This allows filter_map to effectively remove entries that are tombstones in some cases.
source§impl<STATE> Entry<EntryInvalid, STATE>where
STATE: Clone,
impl<STATE> Entry<EntryInvalid, STATE>where
STATE: Clone,
pub fn add_ava(&mut self, attr: &str, value: Value)
sourcepub fn pop_ava(&mut self, attr: &str) -> Option<ValueSet>
pub fn pop_ava(&mut self, attr: &str) -> Option<ValueSet>
Remove all values of this attribute from the entry, and return their content.
sourcepub fn set_ava<T>(&mut self, attr: &str, iter: T)where
T: Clone + IntoIterator<Item = Value>,
pub fn set_ava<T>(&mut self, attr: &str, iter: T)where
T: Clone + IntoIterator<Item = Value>,
Replace the content of this attribute with a new value set. Effectively this is a a “purge and set”.
pub fn set_ava_set(&mut self, attr: &str, vs: ValueSet)
sourcepub fn apply_modlist(
&mut self,
modlist: &ModifyList<ModifyValid>
) -> Result<(), OperationError>
pub fn apply_modlist(
&mut self,
modlist: &ModifyList<ModifyValid>
) -> Result<(), OperationError>
Apply the content of this modlist to this entry, enforcing the expressed state.