Skip to main content

GnapService

Struct GnapService 

Source
pub struct GnapService { /* private fields */ }

Implementations§

Source§

impl GnapService

Source

pub fn new(config: GnapConfig) -> Self

Source

pub fn verify_jwk_signature( jwk: &GnapJwk, message: &[u8], signature: &[u8], ) -> Result<()>

Reconstruct the raw public key bytes from a JWK and verify a signature using ring. Supports ES256 (P-256) and RS256.

This is called by middleware or application code that extracts the HTTP message signature from the request before invoking the GNAP transaction endpoints.

Source

pub fn validate_client_key_with_proof( client: &Option<GnapClientInfo>, proof_message: Option<&[u8]>, proof_signature: Option<&[u8]>, ) -> Result<Option<String>>

Validate the client key binding on a request. Returns the key thumbprint if a key is present and valid.

When proof_message and proof_signature are provided, the actual cryptographic signature is verified against the client’s JWK. For proof methods other than “test”, the caller (typically HTTP middleware) must extract and supply the message and signature bytes from the request (e.g. the HTTP Signature input string and its signature value).

Source

pub async fn handle_transaction( &self, request: GnapTransactionRequest, ) -> Result<Value>

Handle a new GNAP transaction request (draft-ietf-gnap-core-protocol §2)

Source

pub async fn continue_transaction( &self, transaction_id: &str, continue_token: &str, interact_ref: Option<&str>, interact_hash: Option<&str>, ) -> Result<Value>

Continue a GNAP transaction (polling or post-interaction).

The continuation token is rotated on every successful call per draft §5.1, preventing replay of old continuation responses.

Source

pub async fn approve_transaction( &self, transaction_id: &str, subject_id: Option<&str>, ) -> Result<()>

Approve a pending transaction (called after user interaction). Optionally sets the subject identifier for subject-info responses.

Source

pub async fn deny_transaction(&self, transaction_id: &str) -> Result<()>

Deny a pending transaction

Source

pub async fn revoke_token(&self, token_value: &str) -> Result<()>

Revoke an issued access token (draft §6.2 — DELETE on manage URI).

Source

pub async fn rotate_token(&self, old_token_value: &str) -> Result<Value>

Rotate an issued access token (draft §6.1 — POST on manage URI). Returns a new token with the same access rights and key binding.

Source

pub async fn introspect_token(&self, token_value: &str) -> Result<Option<Value>>

Introspect a token — check if it is valid and return its access rights.

Source

pub async fn validate_token_key_binding( &self, token_value: &str, presenting_jwk: &GnapJwk, ) -> Result<bool>

Validate that a key-bound token is being used with the correct key.

For tokens issued with a client key binding, verify that the presenting client’s JWK thumbprint matches the stored binding. Returns Ok(true) if the token is not key-bound (no restriction).

Source

pub async fn cleanup_expired_transactions(&self)

Remove expired transactions from the in-memory store.

Source

pub async fn cleanup_expired_tokens(&self)

Remove expired access tokens from the in-memory store.

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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