pub struct GnapService { /* private fields */ }Implementations§
Source§impl GnapService
impl GnapService
pub fn new(config: GnapConfig) -> Self
Sourcepub fn with_access_policy(self, policy: Arc<dyn GnapAccessPolicy>) -> Self
pub fn with_access_policy(self, policy: Arc<dyn GnapAccessPolicy>) -> Self
Set the policy that decides what access tokens carry. Without one, every request for an access token is denied.
Sourcepub fn verify_jwk_signature(
jwk: &GnapJwk,
message: &[u8],
signature: &[u8],
) -> Result<()>
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.
Sourcepub fn validate_client_key_with_proof(
client: &Option<GnapClientInfo>,
proof_message: Option<&[u8]>,
proof_signature: Option<&[u8]>,
) -> Result<Option<String>>
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).
Sourcepub async fn handle_transaction_with_proof(
&self,
dpop: &DpopManager,
proof: &GnapProof<'_>,
request: GnapTransactionRequest,
) -> Result<Value>
pub async fn handle_transaction_with_proof( &self, dpop: &DpopManager, proof: &GnapProof<'_>, request: GnapTransactionRequest, ) -> Result<Value>
Handle a new GNAP transaction request (RFC 9635 section 2). The request must name a
client key with the dpop proof method, and proof carries the request’s DPoP header,
which must be signed by that key. A request that names no client key is refused, and no
access token is issued unless the service has an access policy that grants something.
Sourcepub async fn continue_transaction_with_proof(
&self,
dpop: &DpopManager,
proof: &GnapProof<'_>,
transaction_id: &str,
continue_token: &str,
interact_ref: Option<&str>,
interact_hash: Option<&str>,
) -> Result<Value>
pub async fn continue_transaction_with_proof( &self, dpop: &DpopManager, proof: &GnapProof<'_>, transaction_id: &str, continue_token: &str, interact_ref: Option<&str>, interact_hash: Option<&str>, ) -> Result<Value>
Continue a GNAP transaction (polling or post-interaction), RFC 9635 section 5.
The continuation request must carry a DPoP proof signed by the transaction’s client
key. A transaction that uses a finish method continues only with the one-time
interact_ref that Self::approve_transaction returned. The continuation token is
rotated on every successful call, preventing replay of old continuation responses.
Sourcepub async fn approve_transaction(
&self,
transaction_id: &str,
subject_id: Option<&str>,
) -> Result<GnapInteractionCompletion>
pub async fn approve_transaction( &self, transaction_id: &str, subject_id: Option<&str>, ) -> Result<GnapInteractionCompletion>
Approve a pending transaction (called after user interaction). Optionally sets the subject identifier for subject-info responses.
For a transaction that uses a finish method this issues the one-time interaction reference and its hash (RFC 9635 section 4.2); deliver both to the client’s finish URI.
Sourcepub async fn deny_transaction(&self, transaction_id: &str) -> Result<()>
pub async fn deny_transaction(&self, transaction_id: &str) -> Result<()>
Deny a pending transaction
Sourcepub async fn revoke_token(&self, token_value: &str) -> Result<()>
pub async fn revoke_token(&self, token_value: &str) -> Result<()>
Revoke an issued access token (draft §6.2 — DELETE on manage URI).
Sourcepub async fn rotate_token(&self, old_token_value: &str) -> Result<Value>
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.
Sourcepub async fn introspect_token(&self, token_value: &str) -> Result<Option<Value>>
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.
Sourcepub async fn validate_token_key_binding(
&self,
token_value: &str,
presenting_jwk: &GnapJwk,
) -> Result<bool>
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).
Sourcepub async fn cleanup_expired_transactions(&self)
pub async fn cleanup_expired_transactions(&self)
Remove expired transactions from the in-memory store.
Sourcepub async fn cleanup_expired_tokens(&self)
pub async fn cleanup_expired_tokens(&self)
Remove expired access tokens from the in-memory store.
Auto Trait Implementations§
impl !RefUnwindSafe for GnapService
impl !UnwindSafe for GnapService
impl Forget for GnapService
impl Freeze for GnapService
impl Send for GnapService
impl Sync for GnapService
impl Unpin for GnapService
impl UnsafeUnpin for GnapService
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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