From 378b4c17baea05f91cf580d975a2147e89c3cf1a Mon Sep 17 00:00:00 2001 From: robjtede Date: Tue, 1 Mar 2022 04:28:45 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=2012f6d?= =?UTF-8?q?b37559a14f1d59711f63370de1e0fe2d085=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actix_identity/index.html | 34 +++++++++----------- actix_identity/trait.IdentityPolicy.html | 10 +++--- actix_identity/trait.RequestIdentity.html | 4 +-- src/actix_identity/lib.rs.html | 38 ++++++++++------------- 4 files changed, 38 insertions(+), 48 deletions(-) diff --git a/actix_identity/index.html b/actix_identity/index.html index 58656ed37..99f2a9ceb 100644 --- a/actix_identity/index.html +++ b/actix_identity/index.html @@ -4,7 +4,7 @@
Expand description

Opinionated request identity service for Actix Web apps.

+

Crate actix_identity

source · []
Expand description

Opinionated request identity service for Actix Web apps.

IdentityService middleware can be used with different policies types to store identity information.

A cookie based policy is provided. CookieIdentityPolicy uses cookies as identity storage.

@@ -25,33 +25,29 @@ identity information.

#[post("/login")] async fn login(id: Identity) -> HttpResponse { - id.remember("User1".to_owned()); // <- remember identity + // remember identity + id.remember("User1".to_owned()); HttpResponse::Ok().finish() } #[post("/logout")] async fn logout(id: Identity) -> HttpResponse { - id.forget(); // <- remove identity + // remove identity + id.forget(); HttpResponse::Ok().finish() } -#[actix_web::main] -async fn main() -> std::io::Result<()> { - HttpServer::new(move || { - // create cookie identity backend - let policy = CookieIdentityPolicy::new(&[0; 32]) - .name("auth-cookie") - .secure(false); +HttpServer::new(move || { + // create cookie identity backend (inside closure, since policy is not Clone) + let policy = CookieIdentityPolicy::new(&[0; 32]) + .name("auth-cookie") + .secure(false); - App::new() - // wrap policy into middleware identity middleware - .wrap(IdentityService::new(policy)) - .service(services![index, login, logout]) - }) - .bind(("0.0.0.0", 8080u16))? - .run() - .await -}
+ App::new() + // wrap policy into middleware identity middleware + .wrap(IdentityService::new(policy)) + .service(services![index, login, logout]) +})

Structs

Use cookies for request identity storage.

The extractor type to obtain your identity from a request.

diff --git a/actix_identity/trait.IdentityPolicy.html b/actix_identity/trait.IdentityPolicy.html index faa6fb2f3..14aae9935 100644 --- a/actix_identity/trait.IdentityPolicy.html +++ b/actix_identity/trait.IdentityPolicy.html @@ -4,15 +4,15 @@
pub trait IdentityPolicy: Sized + 'static {
+    

Trait actix_identity::IdentityPolicy

source · []
pub trait IdentityPolicy: Sized + 'static {
     type Future: Future<Output = Result<Option<String>, Error>>;
     type ResponseFuture: Future<Output = Result<(), Error>>;
     fn from_request(&self, req: &mut ServiceRequest) -> Self::Future;
 
fn to_response<B>(
        &self,
        identity: Option<String>,
        changed: bool,
        response: &mut ServiceResponse<B>
    ) -> Self::ResponseFuture; }
Expand description

Identity policy.

-

Associated Types

The return type of the middleware

-

The return type of the middleware

-

Required methods

Parse the session from request and load data from a service identity.

-

Write changes to response

+

Associated Types

The return type of the middleware

+

The return type of the middleware

+

Required methods

Parse the session from request and load data from a service identity.

+

Write changes to response

Implementors

\ No newline at end of file diff --git a/actix_identity/trait.RequestIdentity.html b/actix_identity/trait.RequestIdentity.html index 79dbe669a..84b4de0c2 100644 --- a/actix_identity/trait.RequestIdentity.html +++ b/actix_identity/trait.RequestIdentity.html @@ -4,10 +4,10 @@
pub trait RequestIdentity {
+    

Trait actix_identity::RequestIdentity

source · []
pub trait RequestIdentity {
     fn get_identity(&self) -> Option<String>;
 }
Expand description

Helper trait that allows to get Identity.

It could be used in middleware but identity policy must be set before any other middleware that needs identity. RequestIdentity is implemented both for ServiceRequest and HttpRequest.

-

Required methods

Implementors

+

Required methods

Implementors

\ No newline at end of file diff --git a/src/actix_identity/lib.rs.html b/src/actix_identity/lib.rs.html index 1a86bb2ae..cde53a761 100644 --- a/src/actix_identity/lib.rs.html +++ b/src/actix_identity/lib.rs.html @@ -165,9 +165,6 @@ 160 161 162 -163 -164 -165
//! Opinionated request identity service for Actix Web apps.
 //!
 //! [`IdentityService`] middleware can be used with different policies types to store
@@ -177,7 +174,7 @@
 //!
 //! To access current request identity, use the [`Identity`] extractor.
 //!
-//! ```no_run
+//! ```
 //! use actix_web::*;
 //! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
 //!
@@ -193,33 +190,30 @@
 //!
 //! #[post("/login")]
 //! async fn login(id: Identity) -> HttpResponse {
-//!     id.remember("User1".to_owned()); // <- remember identity
+//!     // remember identity
+//!     id.remember("User1".to_owned());
 //!     HttpResponse::Ok().finish()
 //! }
 //!
 //! #[post("/logout")]
 //! async fn logout(id: Identity) -> HttpResponse {
-//!     id.forget();                      // <- remove identity
+//!     // remove identity
+//!     id.forget();
 //!     HttpResponse::Ok().finish()
 //! }
 //!
-//! #[actix_web::main]
-//! async fn main() -> std::io::Result<()> {
-//!     HttpServer::new(move || {
-//!         // create cookie identity backend
-//!         let policy = CookieIdentityPolicy::new(&[0; 32])
-//!             .name("auth-cookie")
-//!             .secure(false);
+//! HttpServer::new(move || {
+//!     // create cookie identity backend (inside closure, since policy is not Clone)
+//!     let policy = CookieIdentityPolicy::new(&[0; 32])
+//!         .name("auth-cookie")
+//!         .secure(false);
 //!
-//!         App::new()
-//!             // wrap policy into middleware identity middleware
-//!             .wrap(IdentityService::new(policy))
-//!             .service(services![index, login, logout])
-//!     })
-//!     .bind(("0.0.0.0", 8080u16))?
-//!     .run()
-//!     .await
-//! }
+//!     App::new()
+//!         // wrap policy into middleware identity middleware
+//!         .wrap(IdentityService::new(policy))
+//!         .service(services![index, login, logout])
+//! })
+//! # ;
 //! ```
 
 #![deny(rust_2018_idioms, nonstandard_style)]