Struct oxide_auth_rocket::Generic
source · pub struct Generic<R, A, I, S = Vacant, C = Vacant, L = Vacant> {
pub registrar: R,
pub authorizer: A,
pub issuer: I,
pub solicitor: S,
pub scopes: C,
pub response: L,
}Expand description
A rather basic Endpoint implementation.
Substitue all parts that are not provided with the marker struct Vacant. This will at least
ensure that no security properties are violated. Some flows may be unavailable when some
primitives are missing. See AuthorizationFlow, AccessTokenFlow, ResourceFlow for
more details.
Included types are assumed to be implemented independently, with no major connections. All attributes are public, so there is no inner invariant.
§Usage
You should prefer this implementation when there are special requirements for your Endpoint
implementation, or it is created ad-hoc. It also does some static type checking on dedicated
methods to ensure that the creation of specific flows succeeds. You should prefer
authorization_flow, access_token_flow, and resource_flow over the erroring preparation
methods in AuthorizationFlow, AccessTokenFlow, and ResourceFlow respectively.
This should not be used when you special interacting primitives are used, that originate from
outside this library. For example if you intend for your Scopes to be dynamically generated
from a list of registered clients, its likely cleaner to provide your own Endpoint
implementation instead.
§Example
Here is an example where a Generic is used to set up an endpoint that is filled with the
minimal members to be useable for an AccessTokenFlow.
use oxide_auth::endpoint::{AccessTokenFlow, Endpoint, WebRequest};
use oxide_auth::primitives::{
authorizer::AuthMap,
generator::RandomGenerator,
issuer::TokenMap,
registrar::ClientMap,
};
fn access_token_endpoint<R: WebRequest>() -> AccessTokenFlow<impl Endpoint<R>, R>
where R::Response: Default,
{
let endpoint = Generic {
authorizer: AuthMap::new(RandomGenerator::new(16)),
registrar: ClientMap::new(),
issuer: TokenMap::new(RandomGenerator::new(16)),
scopes: Vacant,
solicitor: Vacant,
response: Vacant,
};
endpoint.access_token_flow()
}Fields§
§registrar: RThe registrar implementation, or Vacant if it is not necesary.
The authorizer implementation, or Vacant if it is not necesary.
issuer: IThe issuer implementation, or Vacant if it is not necesary.
solicitor: SA solicitor implementation fit for the request types, or Vacant if it is not necesary.
scopes: CDetermine scopes for the request types, or Vacant if this does not protect resources.
response: LCreates responses, or Vacant if Default::default is applicable.
Implementations§
source§impl<R, A, I, O, C, L> Generic<R, A, I, O, C, L>
impl<R, A, I, O, C, L> Generic<R, A, I, O, C, L>
sourcepub fn with_solicitor<N>(self, new_solicitor: N) -> Generic<R, A, I, N, C, L>
pub fn with_solicitor<N>(self, new_solicitor: N) -> Generic<R, A, I, N, C, L>
Change the used solicitor.
sourcepub fn with_scopes<S>(self, new_scopes: S) -> Generic<R, A, I, O, S, L>
pub fn with_scopes<S>(self, new_scopes: S) -> Generic<R, A, I, O, S, L>
Change the used scopes.
Create an authorization flow.
Opposed to AuthorizationFlow::prepare this statically ensures that the construction
succeeds.
sourcepub fn access_token_flow<W>(
self
) -> AccessTokenFlow<Generic<R, A, I, O, C, L>, W>where
W: WebRequest,
Generic<R, A, I, O, C, L>: Endpoint<W>,
R: Registrar,
A: Authorizer,
I: Issuer,
pub fn access_token_flow<W>(
self
) -> AccessTokenFlow<Generic<R, A, I, O, C, L>, W>where
W: WebRequest,
Generic<R, A, I, O, C, L>: Endpoint<W>,
R: Registrar,
A: Authorizer,
I: Issuer,
Create an access token flow.
Opposed to AccessTokenFlow::prepare this statically ensures that the construction
succeeds.
sourcepub fn refresh_flow<W>(self) -> RefreshFlow<Generic<R, A, I, O, C, L>, W>
pub fn refresh_flow<W>(self) -> RefreshFlow<Generic<R, A, I, O, C, L>, W>
Create a token refresh flow.
Opposed to RefreshFlow::prepare this statically ensures that the construction succeeds.
sourcepub fn resource_flow<W>(self) -> ResourceFlow<Generic<R, A, I, O, C, L>, W>
pub fn resource_flow<W>(self) -> ResourceFlow<Generic<R, A, I, O, C, L>, W>
Create a resource access flow.
Opposed to ResourceFlow::prepare this statically ensures that the construction succeeds.