pub struct Client { /* private fields */ }
Expand description
A client for performing Portier authentication.
Create a client using either Client::builder
or Client::new
. Sharing a client can be done
simply by reference, even across threads. All methods take an immutable reference to self
only.
If necessary, a client can also be cloned. This is not cheap, however, because settings within are also cloned. The exception is the store, which is shared between clones.
Implementations§
source§impl Client
impl Client
sourcepub fn builder(redirect_uri: Url) -> Builder
pub fn builder(redirect_uri: Url) -> Builder
Create a builder-style struct to configure a Client.
sourcepub fn new(redirect_uri: Url) -> Self
pub fn new(redirect_uri: Url) -> Self
Create a client with default settings.
This uses a MemoryStore
, which has some limitations. See the documentation for
MemoryStore
for details.
sourcepub async fn start_auth(&self, email: &str) -> Result<Url, StartAuthError>
pub async fn start_auth(&self, email: &str) -> Result<Url, StartAuthError>
Create a login session for the given email, and return a URL to redirect the user agent (browser) to so authentication can continue.
If performing the redirect in the HTTP response, the recommended method is to send a 303
HTTP status code with the Location
header set to the URL. But other solutions are
possible, such as fetching this URL using a request from client-side JavaScript.