pub struct OAuthRegistrationStore { /* private fields */ }
Expand description
An API to store and restore OAuth 2.0 client registrations.
This stores dynamic client registrations in a file, and accepts “static”
client registrations via
OAuthRegistrationStore::with_static_registrations()
, for servers that
don’t support dynamic client registration.
If the client metadata passed to this API changes, the previous registrations that were stored in the file are invalidated, allowing to re-register with the new metadata.
The purpose of storing client IDs outside of the state store or separate from the user’s session is that it allows to reuse the same client ID between user sessions on the same server.
Implementations§
Source§impl OAuthRegistrationStore
impl OAuthRegistrationStore
Sourcepub async fn new(
file: PathBuf,
metadata: Raw<ClientMetadata>,
) -> Result<Self, OAuthRegistrationStoreError>
pub async fn new( file: PathBuf, metadata: Raw<ClientMetadata>, ) -> Result<Self, OAuthRegistrationStoreError>
Creates a new registration store.
This method creates the file
’s parent directory if it doesn’t exist.
§Arguments
-
file
- A file path where the registrations will be stored. This previously took a directory and stored the registrations with the pathsupplied_directory/oidc/registrations.json
. -
metadata
- The metadata used to register the client. If this changes compared to the value stored in the file, any stored registrations will be invalidated so the client can re-register with the new data.
Sourcepub fn with_static_registrations(
self,
static_registrations: HashMap<Url, ClientId>,
) -> Self
pub fn with_static_registrations( self, static_registrations: HashMap<Url, ClientId>, ) -> Self
Add static registrations to the store.
Static registrations are used for servers that don’t support dynamic registration but provide a client ID out-of-band.
These registrations are not stored in the file and must be provided each time.
Sourcepub async fn client_id(
&self,
issuer: &Url,
) -> Result<Option<ClientId>, OAuthRegistrationStoreError>
pub async fn client_id( &self, issuer: &Url, ) -> Result<Option<ClientId>, OAuthRegistrationStoreError>
Sourcepub async fn set_and_write_client_id(
&self,
client_id: ClientId,
issuer: Url,
) -> Result<(), OAuthRegistrationStoreError>
pub async fn set_and_write_client_id( &self, client_id: ClientId, issuer: Url, ) -> Result<(), OAuthRegistrationStoreError>
Stores a new client ID registration for a particular issuer.
If a client ID has already been stored for the given issuer, this will overwrite the old value.
§Arguments
-
client_id
- The client ID obtained after registration. -
issuer
- The issuer associated with the client ID.
§Errors
Returns an error if the file could not be read from or written to, or if the data in the file could not be (de)serialized.
Trait Implementations§
Source§impl Debug for OAuthRegistrationStore
impl Debug for OAuthRegistrationStore
Source§impl From<OAuthRegistrationStore> for ClientRegistrationMethod
impl From<OAuthRegistrationStore> for ClientRegistrationMethod
Source§fn from(value: OAuthRegistrationStore) -> Self
fn from(value: OAuthRegistrationStore) -> Self
Auto Trait Implementations§
impl Freeze for OAuthRegistrationStore
impl RefUnwindSafe for OAuthRegistrationStore
impl Send for OAuthRegistrationStore
impl Sync for OAuthRegistrationStore
impl Unpin for OAuthRegistrationStore
impl UnwindSafe for OAuthRegistrationStore
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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