Struct JwtVerifier
pub struct JwtVerifier { /* private fields */ }Expand description
A TokenVerifier of JWTs, which checks them with a moq-auth [KeySet] as moq-relay does.
A valid token admits the peer with the publish and subscribe prefixes its
claims grant at the requested path, and its exp claim becomes the
authorization’s expiry. A token whose root does not overlap the requested
path is a rejection.
A JWT is a bearer token: whoever holds it may use it. When the peer has an iroh key, prefer a capability chain bound to that key, which a thief cannot use.
§Examples
use moq_ext_access::policy::{JwtVerifier, Verify};
let keys = moq_auth::KeySet::default();
let policy = Verify::new(JwtVerifier::new(keys));Implementations§
§impl JwtVerifier
impl JwtVerifier
pub fn new(keys: KeySet) -> JwtVerifier
pub fn new(keys: KeySet) -> JwtVerifier
Creates a verifier that accepts tokens signed by a key in keys.
pub fn verify_grant(&self, token: &str, path: &str) -> Result<Grant, Error>
pub fn verify_grant(&self, token: &str, path: &str) -> Result<Grant, Error>
Verifies token and returns what it grants at path, as moq-relay reads it.
The grant’s prefixes are relative to path, and it expires with the
token.
§Errors
Fails with the moq-auth error if no key verifies the token, the token
expired, or its root does not overlap path.
Trait Implementations§
§impl Clone for JwtVerifier
impl Clone for JwtVerifier
§fn clone(&self) -> JwtVerifier
fn clone(&self) -> JwtVerifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more