mirror of
https://github.com/actix/actix-extras.git
synced 2025-02-20 01:34:22 +01:00
docs(identity): clarify policy creation (#198)
This commit is contained in:
parent
ce92f0036f
commit
673b77a765
@ -7,7 +7,7 @@
|
|||||||
//!
|
//!
|
||||||
//! To access current request identity, use the [`Identity`] extractor.
|
//! To access current request identity, use the [`Identity`] extractor.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```no_run
|
||||||
//! use actix_web::*;
|
//! use actix_web::*;
|
||||||
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
|
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
|
||||||
//!
|
//!
|
||||||
@ -33,15 +33,23 @@
|
|||||||
//! HttpResponse::Ok().finish()
|
//! HttpResponse::Ok().finish()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! // create cookie identity backend
|
//! #[actix_web::main]
|
||||||
//! let policy = CookieIdentityPolicy::new(&[0; 32])
|
//! async fn main() -> std::io::Result<()> {
|
||||||
//! .name("auth-cookie")
|
//! HttpServer::new(move || {
|
||||||
//! .secure(false);
|
//! // create cookie identity backend
|
||||||
|
//! let policy = CookieIdentityPolicy::new(&[0; 32])
|
||||||
|
//! .name("auth-cookie")
|
||||||
|
//! .secure(false);
|
||||||
//!
|
//!
|
||||||
//! let app = App::new()
|
//! App::new()
|
||||||
//! // wrap policy into middleware identity middleware
|
//! // wrap policy into middleware identity middleware
|
||||||
//! .wrap(IdentityService::new(policy))
|
//! .wrap(IdentityService::new(policy))
|
||||||
//! .service(services![index, login, logout]);
|
//! .service(services![index, login, logout])
|
||||||
|
//! })
|
||||||
|
//! .bind(("0.0.0.0", 8080u16))?
|
||||||
|
//! .run()
|
||||||
|
//! .await
|
||||||
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user