mirror of
https://github.com/actix/actix-extras.git
synced 2025-02-17 08:33:30 +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.
|
||||
//!
|
||||
//! ```
|
||||
//! ```no_run
|
||||
//! use actix_web::*;
|
||||
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
|
||||
//!
|
||||
@ -33,15 +33,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)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user