pub struct BiscuitConfig { /* private fields */ }Expand description
Cheap-to-clone biscuit configuration. Wraps the active keypair +
history behind an RwLock so a future rotate lands without
breaking inflight callers.
Implementations§
Source§impl BiscuitConfig
impl BiscuitConfig
Sourcepub fn from_active(active: ActiveRootKey, history: Vec<HistoryRootKey>) -> Self
pub fn from_active(active: ActiveRootKey, history: Vec<HistoryRootKey>) -> Self
Construct from an explicit active root keypair. Useful for tests and for engine boot’s “load row, build config” path.
Sourcepub fn generate_ephemeral() -> Self
pub fn generate_ephemeral() -> Self
Generate a fresh ephemeral Ed25519 root keypair without touching
any DB. The default for crate::ctx::AuthCtx::new callers
that don’t have a persistent root key yet — engine boot replaces
this with the loaded-or-generated row via
crate::ctx::AuthCtx::with_biscuit.
Sourcepub fn from_pem(pem: &str) -> Result<Self>
pub fn from_pem(pem: &str) -> Result<Self>
Construct from an existing root keypair PEM (the format
KeyPair::to_private_key_pem emits). Used by engine boot
when the auth.biscuit_root_keys row carries a stored private
key.
Sourcepub fn active_kid(&self) -> String
pub fn active_kid(&self) -> String
Borrow the active root key id (kid). Cheap; clones one short string under the read lock.
Sourcepub fn public_pem(&self) -> Result<String>
pub fn public_pem(&self) -> Result<String>
Render the active root public key as a PEM string for
distribution to standalone verifiers (mobile clients, edge
services). Stable as long as the active row in
auth.biscuit_root_keys doesn’t rotate.
Sourcepub fn active_public_key(&self) -> PublicKey
pub fn active_public_key(&self) -> PublicKey
Borrow the active root public key. Useful for test reconstruction and for the public_pem helper.
Sourcepub fn issue<F>(&self, build: F) -> Result<String>
pub fn issue<F>(&self, build: F) -> Result<String>
Issue a fresh biscuit via the supplied builder closure. The
closure receives an empty BiscuitBuilder and returns the
completed builder; we sign + base64-URL-encode it for the wire.
Example:
let token = cfg.issue(|b| b.fact("user(\"alice\")"))?;Sourcepub fn verify<F>(&self, token: &str, build: F) -> Result<()>
pub fn verify<F>(&self, token: &str, build: F) -> Result<()>
Verify a biscuit and run the supplied authorizer against it. The
closure receives a fresh AuthorizerBuilder; add policies +
checks via its builder methods, returning the completed builder.
We then build the authorizer against the parsed token and call
authorize.
Ok(()) means the token was syntactically valid, signed by a
known root key, and matched at least one allow policy without
triggering any deny / failed check.
Trait Implementations§
Source§impl Clone for BiscuitConfig
impl Clone for BiscuitConfig
Source§fn clone(&self) -> BiscuitConfig
fn clone(&self) -> BiscuitConfig
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 BiscuitConfig
impl !RefUnwindSafe for BiscuitConfig
impl Send for BiscuitConfig
impl Sync for BiscuitConfig
impl Unpin for BiscuitConfig
impl UnsafeUnpin for BiscuitConfig
impl !UnwindSafe for BiscuitConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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