[−][src]Trait oxide_auth::endpoint::Endpoint
Fuses requests and primitives into a coherent system to give a response.
There are multiple different valid ways to produce responses and react to internal errors for a single request type. This trait should provide those mechanisms, including trying to recover from primitive errors where appropriate.
To reduce the number of necessary impls and provide a single interface to a single trait, this
trait defines accessor methods for all possibly needed primitives. Note that not all flows
actually access all primitives. Thus, an implementation does not necessarily have to return
something in registrar
, authorizer
, issuer_mut
but failing to do so will also fail flows
that try to use them.
Panics
It is expected that the endpoint primitive functions are consistent, i.e. they don't begin
returning None
after having returned Some(registrar)
previously for example. This ensures
that the checks executed by the flow preparation methods catch missing primitives. When this
contract is violated, the execution of a flow may lead to a panic.
Associated Types
type Error
The error typed used as the error representation of each flow.
Required methods
fn registrar(&self) -> Option<&dyn Registrar>
A registrar if this endpoint can access one.
Returning None
will implicate failing any flow that requires a registrar but does not
have any effect on flows that do not require one.
fn authorizer_mut(&mut self) -> Option<&mut dyn Authorizer>
An authorizer if this endpoint can access one.
Returning None
will implicate failing any flow that requires an authorizer but does not
have any effect on flows that do not require one.
fn issuer_mut(&mut self) -> Option<&mut dyn Issuer>
An issuer if this endpoint can access one.
Returning None
will implicate failing any flow that requires an issuer but does not have
any effect on flows that do not require one.
fn owner_solicitor(&mut self) -> Option<&mut dyn OwnerSolicitor<Request>>
Return the system that checks owner consent.
Returning None
will implicated failing the authorization code flow but does have any
effect on other flows.
fn scopes(&mut self) -> Option<&mut dyn Scopes<Request>>
Determine the required scopes for a request.
The client must fulfill any one scope, so returning an empty slice will always deny the request.
fn response(
&mut self,
request: &mut Request,
kind: Template
) -> Result<Request::Response, Self::Error>
&mut self,
request: &mut Request,
kind: Template
) -> Result<Request::Response, Self::Error>
Generate a prototype response.
The endpoint can rely on this being called at most once for each flow, if it wants to preallocate the response or return a handle on an existing prototype.
fn error(&mut self, err: OAuthError) -> Self::Error
Wrap an error.
fn web_error(&mut self, err: Request::Error) -> Self::Error
Wrap an error in the request/response types.
Provided methods
fn extension(&mut self) -> Option<&mut dyn Extension>
Get the central extension instance this endpoint.
Returning None
is the default implementation and acts as simply providing any extensions.
Implementations on Foreign Types
impl<'a, R: WebRequest, E: Endpoint<R>> Endpoint<R> for &'a mut E
[src]
type Error = E::Error
fn registrar(&self) -> Option<&dyn Registrar>
[src]
fn authorizer_mut(&mut self) -> Option<&mut dyn Authorizer>
[src]
fn issuer_mut(&mut self) -> Option<&mut dyn Issuer>
[src]
fn owner_solicitor(&mut self) -> Option<&mut dyn OwnerSolicitor<R>>
[src]
fn scopes(&mut self) -> Option<&mut dyn Scopes<R>>
[src]
fn response(
&mut self,
request: &mut R,
kind: Template
) -> Result<R::Response, Self::Error>
[src]
&mut self,
request: &mut R,
kind: Template
) -> Result<R::Response, Self::Error>
fn error(&mut self, err: OAuthError) -> Self::Error
[src]
fn web_error(&mut self, err: R::Error) -> Self::Error
[src]
fn extension(&mut self) -> Option<&mut dyn Extension>
[src]
impl<'a, R: WebRequest, E: Endpoint<R> + 'a> Endpoint<R> for Box<E>
[src]
type Error = E::Error
fn registrar(&self) -> Option<&dyn Registrar>
[src]
fn authorizer_mut(&mut self) -> Option<&mut dyn Authorizer>
[src]
fn issuer_mut(&mut self) -> Option<&mut dyn Issuer>
[src]
fn owner_solicitor(&mut self) -> Option<&mut dyn OwnerSolicitor<R>>
[src]
fn scopes(&mut self) -> Option<&mut dyn Scopes<R>>
[src]
fn response(
&mut self,
request: &mut R,
kind: Template
) -> Result<R::Response, Self::Error>
[src]
&mut self,
request: &mut R,
kind: Template
) -> Result<R::Response, Self::Error>
fn error(&mut self, err: OAuthError) -> Self::Error
[src]
fn web_error(&mut self, err: R::Error) -> Self::Error
[src]
fn extension(&mut self) -> Option<&mut dyn Extension>
[src]
Implementors
impl<Request, Inner, Ext> Endpoint<Request> for Extended<Inner, Ext> where
Request: WebRequest,
Inner: Endpoint<Request>,
Ext: Extension,
[src]
Request: WebRequest,
Inner: Endpoint<Request>,
Ext: Extension,
type Error = Inner::Error
fn registrar(&self) -> Option<&dyn Registrar>
[src]
fn authorizer_mut(&mut self) -> Option<&mut dyn Authorizer>
[src]
fn issuer_mut(&mut self) -> Option<&mut dyn Issuer>
[src]
fn owner_solicitor(&mut self) -> Option<&mut dyn OwnerSolicitor<Request>>
[src]
fn scopes(&mut self) -> Option<&mut dyn Scopes<Request>>
[src]
fn response(
&mut self,
request: &mut Request,
kind: Template
) -> Result<Request::Response, Self::Error>
[src]
&mut self,
request: &mut Request,
kind: Template
) -> Result<Request::Response, Self::Error>
fn error(&mut self, err: OAuthError) -> Self::Error
[src]
fn web_error(&mut self, err: Request::Error) -> Self::Error
[src]
fn extension(&mut self) -> Option<&mut dyn Extension>
[src]
impl<W, R, A, I, O, C, L> Endpoint<W> for Generic<R, A, I, O, C, L> where
W: WebRequest,
R: OptRegistrar,
A: OptAuthorizer,
I: OptIssuer,
O: OwnerSolicitor<W>,
C: Scopes<W>,
L: ResponseCreator<W>,
[src]
W: WebRequest,
R: OptRegistrar,
A: OptAuthorizer,
I: OptIssuer,
O: OwnerSolicitor<W>,
C: Scopes<W>,
L: ResponseCreator<W>,
type Error = Error<W>
fn registrar(&self) -> Option<&dyn Registrar>
[src]
fn authorizer_mut(&mut self) -> Option<&mut dyn Authorizer>
[src]
fn issuer_mut(&mut self) -> Option<&mut dyn Issuer>
[src]
fn owner_solicitor(&mut self) -> Option<&mut dyn OwnerSolicitor<W>>
[src]
fn scopes(&mut self) -> Option<&mut dyn Scopes<W>>
[src]
fn response(
&mut self,
request: &mut W,
kind: Template
) -> Result<W::Response, Self::Error>
[src]
&mut self,
request: &mut W,
kind: Template
) -> Result<W::Response, Self::Error>