pub struct ClientStore { /* private fields */ }Available on crate features
sso-server and sso only.Expand description
In-memory registry of OAuthClients, looked up by client_id.
§Example
use rust_web_server::sso::client_store::{ClientStore, OAuthClient, GrantType};
let clients = ClientStore::new()
.add(OAuthClient {
client_id: "spa-frontend".into(),
client_secret: None,
redirect_uris: vec!["https://spa.example.com/callback".into()],
grants: vec![GrantType::AuthorizationCode],
scopes: vec!["openid".into(), "email".into()],
})
.add(OAuthClient {
client_id: "backend-service".into(),
client_secret: Some("s3cr3t".into()),
redirect_uris: vec![],
grants: vec![GrantType::ClientCredentials],
scopes: vec!["api:read".into(), "api:write".into()],
});
assert!(clients.get("spa-frontend").is_some());
assert!(clients.get("unknown-client").is_none());Implementations§
Source§impl ClientStore
impl ClientStore
Sourcepub fn add(self, client: OAuthClient) -> Self
pub fn add(self, client: OAuthClient) -> Self
Register a client. Later registrations with a duplicate client_id
are still stored; ClientStore::get returns the first match.
Sourcepub fn get(&self, client_id: &str) -> Option<&OAuthClient>
pub fn get(&self, client_id: &str) -> Option<&OAuthClient>
Look up a registered client by client_id.
Trait Implementations§
Source§impl Clone for ClientStore
impl Clone for ClientStore
Source§impl Debug for ClientStore
impl Debug for ClientStore
Auto Trait Implementations§
impl Freeze for ClientStore
impl RefUnwindSafe for ClientStore
impl Send for ClientStore
impl Sync for ClientStore
impl Unpin for ClientStore
impl UnsafeUnpin for ClientStore
impl UnwindSafe for ClientStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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