pub struct IjimaAuth { /* private fields */ }Expand description
Ijima’s auth core: an AccessController (authz) plus a capability
token issuer and verifier (authn) sharing one Ed25519 key.
A daemon constructs one of these at startup; an admin CLI uses the
issuer to mint tokens via IjimaAuth::issue_bearer.
Implementations§
Source§impl IjimaAuth
impl IjimaAuth
Sourcepub fn from_embedded_policy() -> Result<Self>
pub fn from_embedded_policy() -> Result<Self>
Loads the embedded policy/policy.toml and generates a fresh
Ed25519 issuer key pair.
Use only for tests/ephemeral runs — every call produces a new key,
so issued tokens will not verify against a different instance. For
a persistent daemon/CLI, use
from_embedded_policy_with_seed
with a seed from key_store.
§Errors
Returns IjimaError::InvalidInput if the policy TOML is invalid.
Sourcepub fn from_embedded_policy_with_seed(seed: [u8; 32]) -> Result<Self>
pub fn from_embedded_policy_with_seed(seed: [u8; 32]) -> Result<Self>
Loads the embedded policy and constructs the issuer from a known 32-byte Ed25519 seed. The same seed must be shared by every process that issues or verifies tokens for this Ijima instance.
§Errors
Returns IjimaError::InvalidInput if the policy TOML is invalid.
Sourcepub fn generate_seed() -> [u8; 32]
pub fn generate_seed() -> [u8; 32]
Generates a fresh random 32-byte issuer seed (for first-time setup).
Sourcepub fn issuer_public_key_hex(&self) -> String
pub fn issuer_public_key_hex(&self) -> String
The issuer’s Ed25519 public key as lowercase hex, for distribution to verifiers and operator visibility.
Sourcepub fn grassmannian(&self) -> (usize, usize)
pub fn grassmannian(&self) -> (usize, usize)
Returns the Grassmannian the controller operates on.
Sourcepub fn issue_bearer(
&self,
principal: impl Into<PrincipalId>,
capability: impl AsRef<str>,
) -> Result<String>
pub fn issue_bearer( &self, principal: impl Into<PrincipalId>, capability: impl AsRef<str>, ) -> Result<String>
Issues a bearer token (base64 wire format) granting capability
to principal.
§Errors
Returns IjimaError::InvalidInput if Schubert’s issuer rejects
the inputs.
Sourcepub fn verify_bearer(&self, bearer: &str) -> Result<AuthenticatedPrincipal>
pub fn verify_bearer(&self, bearer: &str) -> Result<AuthenticatedPrincipal>
Decodes + cryptographically verifies a bearer token, returning the authenticated principal and the capability the token grants.
§Errors
Returns IjimaError::InvalidInput on a malformed or
bad-signature token.
Sourcepub fn check(
&self,
principal: &PrincipalId,
required: &[&str],
) -> Result<AccessDecision>
pub fn check( &self, principal: &PrincipalId, required: &[&str], ) -> Result<AccessDecision>
Authorizes principal for required capabilities via the
geometric Schubert check. Returns the AccessDecision.
This is the authorization half; combine with [verify_bearer] in
handlers that need both (“who is calling” + “may they do this”).
Sourcepub fn require(
&self,
bearer: &str,
required: &str,
) -> Result<AuthenticatedPrincipal>
pub fn require( &self, bearer: &str, required: &str, ) -> Result<AuthenticatedPrincipal>
Convenience guard for handlers: verifies the token (authn) and
authorizes via proof-carrying semantics — the token’s capability
field is the authorization, verified cryptographically against the
issuer’s public key. Succeeds when the token grants exactly
required or grants ADMIN
(the point class implies every capability).
For richer geometric implication (e.g. “mining:trigger composes over
session:ingest”), use check against a controller
with explicit grants — that path is for offline policy analysis,
not per-request runtime checks.
§Errors
Returns an error if the token is invalid or does not grant required.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for IjimaAuth
impl !UnwindSafe for IjimaAuth
impl Freeze for IjimaAuth
impl Send for IjimaAuth
impl Sync for IjimaAuth
impl Unpin for IjimaAuth
impl UnsafeUnpin for IjimaAuth
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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