Skip to main content

IjimaAuth

Struct IjimaAuth 

Source
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

Source

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.

Source

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.

Source

pub fn generate_seed() -> [u8; 32]

Generates a fresh random 32-byte issuer seed (for first-time setup).

Source

pub fn issuer_public_key_hex(&self) -> String

The issuer’s Ed25519 public key as lowercase hex, for distribution to verifiers and operator visibility.

Source

pub fn grassmannian(&self) -> (usize, usize)

Returns the Grassmannian the controller operates on.

Source

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.

Source

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.

Source

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”).

Source

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§

Source§

impl Debug for IjimaAuth

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool