pub struct RemoteKeySet { /* private fields */ }Available on crate feature
http only.Expand description
A JWKS source that fetches from an HTTP endpoint on every request.
This implementation does not cache keys. Every call to get_key
or get_keyset will make an HTTP request.
For production use with high request volumes, wrap this in CachedKeySet:
ⓘ
use jwk_simple::{RemoteKeySet, CachedKeySet};
use std::time::Duration;
let remote = RemoteKeySet::new("https://example.com/.well-known/jwks.json");
let cached = CachedKeySet::new(remote, Duration::from_secs(300));§Examples
ⓘ
use jwk_simple::{KeySource, RemoteKeySet};
let jwks = RemoteKeySet::new("https://example.com/.well-known/jwks.json");
let key = jwks.get_key("my-key-id").await?;§Custom HTTP Client
You can provide a custom reqwest::Client for full control over HTTP behavior:
ⓘ
use jwk_simple::RemoteKeySet;
use std::time::Duration;
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(10))
.user_agent("my-app/1.0")
.build()
.unwrap();
let jwks = RemoteKeySet::new_with_client(
"https://example.com/.well-known/jwks.json",
client,
);Implementations§
Source§impl RemoteKeySet
impl RemoteKeySet
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Creates a new RemoteKeySet from a URL.
Uses a default HTTP client with a 30-second timeout. To customize the client,
use new_with_client.
§Arguments
url- The JWKS endpoint URL.
Sourcepub fn new_with_client(url: impl Into<String>, client: Client) -> Self
pub fn new_with_client(url: impl Into<String>, client: Client) -> Self
Creates a new RemoteKeySet with a custom HTTP client.
Use this to configure custom timeouts, headers, proxies, TLS settings, etc.
§Arguments
url- The JWKS endpoint URL.client- A configuredreqwest::Client.
§Examples
ⓘ
use jwk_simple::RemoteKeySet;
use std::time::Duration;
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(10))
.build()
.unwrap();
let jwks = RemoteKeySet::new_with_client(
"https://example.com/.well-known/jwks.json",
client,
);Trait Implementations§
Source§impl Clone for RemoteKeySet
impl Clone for RemoteKeySet
Source§fn clone(&self) -> RemoteKeySet
fn clone(&self) -> RemoteKeySet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RemoteKeySet
impl Debug for RemoteKeySet
Source§impl KeySource for RemoteKeySet
impl KeySource for RemoteKeySet
Auto Trait Implementations§
impl Freeze for RemoteKeySet
impl !RefUnwindSafe for RemoteKeySet
impl Send for RemoteKeySet
impl Sync for RemoteKeySet
impl Unpin for RemoteKeySet
impl !UnwindSafe for RemoteKeySet
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