pub struct TokenPolicy<'a> { /* private fields */ }Expand description
What the request is allowed to be, given the resource it reached and the revision it negotiated.
Two deployment facts and one spec fact, all of which change whether a token is checked at all. Bundled because passing three arguments to every call site invites two of them being forgotten.
Implementations§
Source§impl<'a> TokenPolicy<'a>
impl<'a> TokenPolicy<'a>
Sourcepub const fn new(resource: &'a ResourceUri, model: AuthorizationModel) -> Self
pub const fn new(resource: &'a ResourceUri, model: AuthorizationModel) -> Self
A policy that accepts any issuer.
§Examples
use protocol_droid::domain::{ProtocolVersion, authorization_model};
use protocol_droid::domain::mcp::ResourceUri;
use protocol_droid::application::oauth::TokenPolicy;
let resource = ResourceUri::new("https://example.com/mcp")?;
let policy = TokenPolicy::new(&resource, authorization_model(ProtocolVersion::V2026_07_28));
assert!(policy.accepts_any_issuer());Sourcepub fn with_expected_issuer(self, issuer: impl Into<Arc<str>>) -> Self
pub fn with_expected_issuer(self, issuer: impl Into<Arc<str>>) -> Self
Requires tokens to name issuer, refusing any minted by anyone else.
Sourcepub const fn accepts_any_issuer(&self) -> bool
pub const fn accepts_any_issuer(&self) -> bool
Whether an issuer check will be made.
Trait Implementations§
Source§impl<'a> Clone for TokenPolicy<'a>
impl<'a> Clone for TokenPolicy<'a>
Auto Trait Implementations§
impl<'a> Freeze for TokenPolicy<'a>
impl<'a> RefUnwindSafe for TokenPolicy<'a>
impl<'a> Send for TokenPolicy<'a>
impl<'a> Sync for TokenPolicy<'a>
impl<'a> Unpin for TokenPolicy<'a>
impl<'a> UnsafeUnpin for TokenPolicy<'a>
impl<'a> UnwindSafe for TokenPolicy<'a>
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
Mutably borrows from an owned value. Read more