From ae535d0a8a15e0f66726c7c3ec8add6fc9000f89 Mon Sep 17 00:00:00 2001 From: robjtede Date: Tue, 1 Mar 2022 04:24:55 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=20673b7?= =?UTF-8?q?7a765101999535e8ae57d9565d1fef1acbf=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actix_identity/index.html | 26 +++++++++++------ actix_identity/trait.IdentityPolicy.html | 10 +++---- actix_identity/trait.RequestIdentity.html | 4 +-- src/actix_identity/lib.rs.html | 34 +++++++++++++++++------ 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/actix_identity/index.html b/actix_identity/index.html index 493da837d..58656ed37 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.

@@ -35,15 +35,23 @@ identity information.

HttpResponse::Ok().finish() } -// create cookie identity backend -let policy = CookieIdentityPolicy::new(&[0; 32]) - .name("auth-cookie") - .secure(false); +#[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); -let app = App::new() - // wrap policy into middleware identity middleware - .wrap(IdentityService::new(policy)) - .service(services![index, login, logout]);
+ 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 +}

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 e5b25e737..faa6fb2f3 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 3cc2a4f5c..79dbe669a 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 caa96ccc7..1a86bb2ae 100644 --- a/src/actix_identity/lib.rs.html +++ b/src/actix_identity/lib.rs.html @@ -160,6 +160,14 @@ 155 156 157 +158 +159 +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
@@ -169,7 +177,7 @@
 //!
 //! To access current request identity, use the [`Identity`] extractor.
 //!
-//! ```
+//! ```no_run
 //! use actix_web::*;
 //! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
 //!
@@ -195,15 +203,23 @@
 //!     HttpResponse::Ok().finish()
 //! }
 //!
-//! // create cookie identity backend
-//! let policy = CookieIdentityPolicy::new(&[0; 32])
-//!     .name("auth-cookie")
-//!     .secure(false);
+//! #[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);
 //!
-//! let app = App::new()
-//!     // wrap policy into middleware identity middleware
-//!     .wrap(IdentityService::new(policy))
-//!     .service(services![index, login, logout]);
+//!         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
+//! }
 //! ```
 
 #![deny(rust_2018_idioms, nonstandard_style)]