mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
Deploying to gh-pages from @ 12f6db3755
🚀
This commit is contained in:
parent
ae535d0a8a
commit
378b4c17ba
@ -4,7 +4,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<nav class="sidebar"><a class="sidebar-logo" href="../actix_identity/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
|
<nav class="sidebar"><a class="sidebar-logo" href="../actix_identity/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
|
||||||
</a><h2 class="location"><a href="#">Crate actix_identity</a></h2><div class="sidebar-elems"><div class="block"><ul><li class="version">Version 0.4.0</li><li><a id="all-types" href="all.html">All Items</a></li></div></ul><section><div class="block"><ul><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div></section><div id="sidebar-vars" data-name="actix_identity" data-ty="mod" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../actix_identity/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
|
</a><h2 class="location"><a href="#">Crate actix_identity</a></h2><div class="sidebar-elems"><div class="block"><ul><li class="version">Version 0.4.0</li><li><a id="all-types" href="all.html">All Items</a></li></div></ul><section><div class="block"><ul><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div></section><div id="sidebar-vars" data-name="actix_identity" data-ty="mod" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../actix_identity/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
|
||||||
<h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">actix_identity</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/actix_identity/lib.rs.html#1-165">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Opinionated request identity service for Actix Web apps.</p>
|
<h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">actix_identity</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/actix_identity/lib.rs.html#1-162">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Opinionated request identity service for Actix Web apps.</p>
|
||||||
<p><a href="struct.IdentityService.html" title="IdentityService"><code>IdentityService</code></a> middleware can be used with different policies types to store
|
<p><a href="struct.IdentityService.html" title="IdentityService"><code>IdentityService</code></a> middleware can be used with different policies types to store
|
||||||
identity information.</p>
|
identity information.</p>
|
||||||
<p>A cookie based policy is provided. <a href="struct.CookieIdentityPolicy.html" title="CookieIdentityPolicy"><code>CookieIdentityPolicy</code></a> uses cookies as identity storage.</p>
|
<p>A cookie based policy is provided. <a href="struct.CookieIdentityPolicy.html" title="CookieIdentityPolicy"><code>CookieIdentityPolicy</code></a> uses cookies as identity storage.</p>
|
||||||
@ -25,20 +25,20 @@ identity information.</p>
|
|||||||
|
|
||||||
<span class="attribute">#[<span class="ident">post</span>(<span class="string">"/login"</span>)]</span>
|
<span class="attribute">#[<span class="ident">post</span>(<span class="string">"/login"</span>)]</span>
|
||||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">login</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) -> <span class="ident">HttpResponse</span> {
|
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">login</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) -> <span class="ident">HttpResponse</span> {
|
||||||
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">"User1"</span>.<span class="ident">to_owned</span>()); <span class="comment">// <- remember identity</span>
|
<span class="comment">// remember identity</span>
|
||||||
|
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">"User1"</span>.<span class="ident">to_owned</span>());
|
||||||
<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()
|
<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="attribute">#[<span class="ident">post</span>(<span class="string">"/logout"</span>)]</span>
|
<span class="attribute">#[<span class="ident">post</span>(<span class="string">"/logout"</span>)]</span>
|
||||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">logout</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) -> <span class="ident">HttpResponse</span> {
|
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">logout</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) -> <span class="ident">HttpResponse</span> {
|
||||||
<span class="ident">id</span>.<span class="ident">forget</span>(); <span class="comment">// <- remove identity</span>
|
<span class="comment">// remove identity</span>
|
||||||
|
<span class="ident">id</span>.<span class="ident">forget</span>();
|
||||||
<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()
|
<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="attribute">#[<span class="ident">actix_web::main</span>]</span>
|
<span class="ident">HttpServer::new</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> {
|
||||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() -> <span class="ident">std::io::Result</span><span class="op"><</span>()<span class="op">></span> {
|
<span class="comment">// create cookie identity backend (inside closure, since policy is not Clone)</span>
|
||||||
<span class="ident">HttpServer::new</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> {
|
|
||||||
<span class="comment">// create cookie identity backend</span>
|
|
||||||
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&</span>[<span class="number">0</span>; <span class="number">32</span>])
|
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&</span>[<span class="number">0</span>; <span class="number">32</span>])
|
||||||
.<span class="ident">name</span>(<span class="string">"auth-cookie"</span>)
|
.<span class="ident">name</span>(<span class="string">"auth-cookie"</span>)
|
||||||
.<span class="ident">secure</span>(<span class="bool-val">false</span>);
|
.<span class="ident">secure</span>(<span class="bool-val">false</span>);
|
||||||
@ -47,11 +47,7 @@ identity information.</p>
|
|||||||
<span class="comment">// wrap policy into middleware identity middleware</span>
|
<span class="comment">// wrap policy into middleware identity middleware</span>
|
||||||
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(<span class="ident">policy</span>))
|
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(<span class="ident">policy</span>))
|
||||||
.<span class="ident">service</span>(<span class="macro">services!</span>[<span class="ident">index</span>, <span class="ident">login</span>, <span class="ident">logout</span>])
|
.<span class="ident">service</span>(<span class="macro">services!</span>[<span class="ident">index</span>, <span class="ident">login</span>, <span class="ident">logout</span>])
|
||||||
})
|
})</code></pre></div>
|
||||||
.<span class="ident">bind</span>((<span class="string">"0.0.0.0"</span>, <span class="number">8080u16</span>))<span class="question-mark">?</span>
|
|
||||||
.<span class="ident">run</span>()
|
|
||||||
.<span class="kw">await</span>
|
|
||||||
}</code></pre></div>
|
|
||||||
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2>
|
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2>
|
||||||
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CookieIdentityPolicy.html" title="actix_identity::CookieIdentityPolicy struct">CookieIdentityPolicy</a></div><div class="item-right docblock-short"><p>Use cookies for request identity storage.</p>
|
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CookieIdentityPolicy.html" title="actix_identity::CookieIdentityPolicy struct">CookieIdentityPolicy</a></div><div class="item-right docblock-short"><p>Use cookies for request identity storage.</p>
|
||||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Identity.html" title="actix_identity::Identity struct">Identity</a></div><div class="item-right docblock-short"><p>The extractor type to obtain your identity from a request.</p>
|
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Identity.html" title="actix_identity::Identity struct">Identity</a></div><div class="item-right docblock-short"><p>The extractor type to obtain your identity from a request.</p>
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<nav class="sidebar"><a class="sidebar-logo" href="../actix_identity/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
|
<nav class="sidebar"><a class="sidebar-logo" href="../actix_identity/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
|
||||||
</a><h2 class="location"><a href="#">IdentityPolicy</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#associated-types">Associated Types</a></h3><ul><li><a href="#associatedtype.Future">Future</a></li><li><a href="#associatedtype.ResponseFuture">ResponseFuture</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.from_request">from_request</a></li><li><a href="#tymethod.to_response">to_response</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In actix_identity</a></h2><div id="sidebar-vars" data-name="IdentityPolicy" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../actix_identity/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
|
</a><h2 class="location"><a href="#">IdentityPolicy</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#associated-types">Associated Types</a></h3><ul><li><a href="#associatedtype.Future">Future</a></li><li><a href="#associatedtype.ResponseFuture">ResponseFuture</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.from_request">from_request</a></li><li><a href="#tymethod.to_response">to_response</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In actix_identity</a></h2><div id="sidebar-vars" data-name="IdentityPolicy" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../actix_identity/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
|
||||||
<h1 class="fqn"><span class="in-band">Trait <a href="index.html">actix_identity</a>::<wbr><a class="trait" href="#">IdentityPolicy</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/actix_identity/lib.rs.html#74-91">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait IdentityPolicy: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'static {
|
<h1 class="fqn"><span class="in-band">Trait <a href="index.html">actix_identity</a>::<wbr><a class="trait" href="#">IdentityPolicy</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/actix_identity/lib.rs.html#71-88">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait IdentityPolicy: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'static {
|
||||||
type <a href="#associatedtype.Future" class="associatedtype">Future</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error>>;
|
type <a href="#associatedtype.Future" class="associatedtype">Future</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error>>;
|
||||||
type <a href="#associatedtype.ResponseFuture" class="associatedtype">ResponseFuture</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error>>;
|
type <a href="#associatedtype.ResponseFuture" class="associatedtype">ResponseFuture</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error>>;
|
||||||
fn <a href="#tymethod.from_request" class="fnname">from_request</a>(&self, req: &mut ServiceRequest) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.Future" title="type actix_identity::IdentityPolicy::Future">Future</a>;
|
fn <a href="#tymethod.from_request" class="fnname">from_request</a>(&self, req: &mut ServiceRequest) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.Future" title="type actix_identity::IdentityPolicy::Future">Future</a>;
|
||||||
<div class="item-spacer"></div> fn <a href="#tymethod.to_response" class="fnname">to_response</a><B>(<br> &self, <br> identity: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, <br> changed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <br> response: &mut ServiceResponse<B><br> ) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.ResponseFuture" title="type actix_identity::IdentityPolicy::ResponseFuture">ResponseFuture</a>;
|
<div class="item-spacer"></div> fn <a href="#tymethod.to_response" class="fnname">to_response</a><B>(<br> &self, <br> identity: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, <br> changed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <br> response: &mut ServiceResponse<B><br> ) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.ResponseFuture" title="type actix_identity::IdentityPolicy::ResponseFuture">ResponseFuture</a>;
|
||||||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Identity policy.</p>
|
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Identity policy.</p>
|
||||||
</div></details><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Future" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#76">source</a></div><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error>></h4></div></summary><div class="docblock"><p>The return type of the middleware</p>
|
</div></details><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Future" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#73">source</a></div><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error>></h4></div></summary><div class="docblock"><p>The return type of the middleware</p>
|
||||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.ResponseFuture" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#79">source</a></div><h4 class="code-header">type <a href="#associatedtype.ResponseFuture" class="associatedtype">ResponseFuture</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error>></h4></div></summary><div class="docblock"><p>The return type of the middleware</p>
|
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.ResponseFuture" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#76">source</a></div><h4 class="code-header">type <a href="#associatedtype.ResponseFuture" class="associatedtype">ResponseFuture</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = Result<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error>></h4></div></summary><div class="docblock"><p>The return type of the middleware</p>
|
||||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.from_request" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#82">source</a></div><h4 class="code-header">fn <a href="#tymethod.from_request" class="fnname">from_request</a>(&self, req: &mut ServiceRequest) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.Future" title="type actix_identity::IdentityPolicy::Future">Future</a></h4></div></summary><div class="docblock"><p>Parse the session from request and load data from a service identity.</p>
|
</div></details></div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.from_request" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#79">source</a></div><h4 class="code-header">fn <a href="#tymethod.from_request" class="fnname">from_request</a>(&self, req: &mut ServiceRequest) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.Future" title="type actix_identity::IdentityPolicy::Future">Future</a></h4></div></summary><div class="docblock"><p>Parse the session from request and load data from a service identity.</p>
|
||||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.to_response" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#85-90">source</a></div><h4 class="code-header">fn <a href="#tymethod.to_response" class="fnname">to_response</a><B>(<br> &self, <br> identity: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, <br> changed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <br> response: &mut ServiceResponse<B><br>) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.ResponseFuture" title="type actix_identity::IdentityPolicy::ResponseFuture">ResponseFuture</a></h4></div></summary><div class="docblock"><p>Write changes to response</p>
|
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.to_response" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#82-87">source</a></div><h4 class="code-header">fn <a href="#tymethod.to_response" class="fnname">to_response</a><B>(<br> &self, <br> identity: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, <br> changed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <br> response: &mut ServiceResponse<B><br>) -> Self::<a class="associatedtype" href="trait.IdentityPolicy.html#associatedtype.ResponseFuture" title="type actix_identity::IdentityPolicy::ResponseFuture">ResponseFuture</a></h4></div></summary><div class="docblock"><p>Write changes to response</p>
|
||||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-IdentityPolicy" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/actix_identity/cookie.rs.html#303-367">source</a></span><a href="#impl-IdentityPolicy" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.IdentityPolicy.html" title="trait actix_identity::IdentityPolicy">IdentityPolicy</a> for <a class="struct" href="struct.CookieIdentityPolicy.html" title="struct actix_identity::CookieIdentityPolicy">CookieIdentityPolicy</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Future-1" class="type trait-impl has-srclink"><a href="#associatedtype.Future-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = Ready<Result<<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error>></h4></section><section id="associatedtype.ResponseFuture-1" class="type trait-impl has-srclink"><a href="#associatedtype.ResponseFuture-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.ResponseFuture" class="associatedtype">ResponseFuture</a> = Ready<Result<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error>></h4></section></div></details></div><script type="text/javascript" src="../implementors/actix_identity/trait.IdentityPolicy.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (4ce374923 2022-02-28)" ></div>
|
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-IdentityPolicy" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/actix_identity/cookie.rs.html#303-367">source</a></span><a href="#impl-IdentityPolicy" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.IdentityPolicy.html" title="trait actix_identity::IdentityPolicy">IdentityPolicy</a> for <a class="struct" href="struct.CookieIdentityPolicy.html" title="struct actix_identity::CookieIdentityPolicy">CookieIdentityPolicy</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Future-1" class="type trait-impl has-srclink"><a href="#associatedtype.Future-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = Ready<Result<<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error>></h4></section><section id="associatedtype.ResponseFuture-1" class="type trait-impl has-srclink"><a href="#associatedtype.ResponseFuture-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.ResponseFuture" class="associatedtype">ResponseFuture</a> = Ready<Result<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error>></h4></section></div></details></div><script type="text/javascript" src="../implementors/actix_identity/trait.IdentityPolicy.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (4ce374923 2022-02-28)" ></div>
|
||||||
</body></html>
|
</body></html>
|
@ -4,10 +4,10 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<nav class="sidebar"><a class="sidebar-logo" href="../actix_identity/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
|
<nav class="sidebar"><a class="sidebar-logo" href="../actix_identity/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
|
||||||
</a><h2 class="location"><a href="#">RequestIdentity</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.get_identity">get_identity</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In actix_identity</a></h2><div id="sidebar-vars" data-name="RequestIdentity" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../actix_identity/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
|
</a><h2 class="location"><a href="#">RequestIdentity</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.get_identity">get_identity</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In actix_identity</a></h2><div id="sidebar-vars" data-name="RequestIdentity" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../actix_identity/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
|
||||||
<h1 class="fqn"><span class="in-band">Trait <a href="index.html">actix_identity</a>::<wbr><a class="trait" href="#">RequestIdentity</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/actix_identity/lib.rs.html#97-99">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait RequestIdentity {
|
<h1 class="fqn"><span class="in-band">Trait <a href="index.html">actix_identity</a>::<wbr><a class="trait" href="#">RequestIdentity</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/actix_identity/lib.rs.html#94-96">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait RequestIdentity {
|
||||||
fn <a href="#tymethod.get_identity" class="fnname">get_identity</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>;
|
fn <a href="#tymethod.get_identity" class="fnname">get_identity</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>;
|
||||||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Helper trait that allows to get Identity.</p>
|
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Helper trait that allows to get Identity.</p>
|
||||||
<p>It could be used in middleware but identity policy must be set before any other middleware that
|
<p>It could be used in middleware but identity policy must be set before any other middleware that
|
||||||
needs identity. RequestIdentity is implemented both for <code>ServiceRequest</code> and <code>HttpRequest</code>.</p>
|
needs identity. RequestIdentity is implemented both for <code>ServiceRequest</code> and <code>HttpRequest</code>.</p>
|
||||||
</div></details><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><div id="tymethod.get_identity" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#98">source</a></div><h4 class="code-header">fn <a href="#tymethod.get_identity" class="fnname">get_identity</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>></h4></div></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><section id="impl-RequestIdentity" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#101-108">source</a></span><a href="#impl-RequestIdentity" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="trait.RequestIdentity.html" title="trait actix_identity::RequestIdentity">RequestIdentity</a> for T <span class="where fmt-newline">where<br> T: HttpMessage, </span></h3></section></div><script type="text/javascript" src="../implementors/actix_identity/trait.RequestIdentity.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (4ce374923 2022-02-28)" ></div>
|
</div></details><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><div id="tymethod.get_identity" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#95">source</a></div><h4 class="code-header">fn <a href="#tymethod.get_identity" class="fnname">get_identity</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>></h4></div></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><section id="impl-RequestIdentity" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/actix_identity/lib.rs.html#98-105">source</a></span><a href="#impl-RequestIdentity" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="trait.RequestIdentity.html" title="trait actix_identity::RequestIdentity">RequestIdentity</a> for T <span class="where fmt-newline">where<br> T: HttpMessage, </span></h3></section></div><script type="text/javascript" src="../implementors/actix_identity/trait.RequestIdentity.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (4ce374923 2022-02-28)" ></div>
|
||||||
</body></html>
|
</body></html>
|
@ -165,9 +165,6 @@
|
|||||||
<span id="160">160</span>
|
<span id="160">160</span>
|
||||||
<span id="161">161</span>
|
<span id="161">161</span>
|
||||||
<span id="162">162</span>
|
<span id="162">162</span>
|
||||||
<span id="163">163</span>
|
|
||||||
<span id="164">164</span>
|
|
||||||
<span id="165">165</span>
|
|
||||||
</pre><pre class="rust"><code><span class="doccomment">//! Opinionated request identity service for Actix Web apps.</span>
|
</pre><pre class="rust"><code><span class="doccomment">//! Opinionated request identity service for Actix Web apps.</span>
|
||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
<span class="doccomment">//! [`IdentityService`] middleware can be used with different policies types to store</span>
|
<span class="doccomment">//! [`IdentityService`] middleware can be used with different policies types to store</span>
|
||||||
@ -177,7 +174,7 @@
|
|||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
<span class="doccomment">//! To access current request identity, use the [`Identity`] extractor.</span>
|
<span class="doccomment">//! To access current request identity, use the [`Identity`] extractor.</span>
|
||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
<span class="doccomment">//! ```no_run</span>
|
<span class="doccomment">//! ```</span>
|
||||||
<span class="doccomment">//! use actix_web::*;</span>
|
<span class="doccomment">//! use actix_web::*;</span>
|
||||||
<span class="doccomment">//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};</span>
|
<span class="doccomment">//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};</span>
|
||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
@ -193,20 +190,20 @@
|
|||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
<span class="doccomment">//! #[post("/login")]</span>
|
<span class="doccomment">//! #[post("/login")]</span>
|
||||||
<span class="doccomment">//! async fn login(id: Identity) -> HttpResponse {</span>
|
<span class="doccomment">//! async fn login(id: Identity) -> HttpResponse {</span>
|
||||||
<span class="doccomment">//! id.remember("User1".to_owned()); // <- remember identity</span>
|
<span class="doccomment">//! // remember identity</span>
|
||||||
|
<span class="doccomment">//! id.remember("User1".to_owned());</span>
|
||||||
<span class="doccomment">//! HttpResponse::Ok().finish()</span>
|
<span class="doccomment">//! HttpResponse::Ok().finish()</span>
|
||||||
<span class="doccomment">//! }</span>
|
<span class="doccomment">//! }</span>
|
||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
<span class="doccomment">//! #[post("/logout")]</span>
|
<span class="doccomment">//! #[post("/logout")]</span>
|
||||||
<span class="doccomment">//! async fn logout(id: Identity) -> HttpResponse {</span>
|
<span class="doccomment">//! async fn logout(id: Identity) -> HttpResponse {</span>
|
||||||
<span class="doccomment">//! id.forget(); // <- remove identity</span>
|
<span class="doccomment">//! // remove identity</span>
|
||||||
|
<span class="doccomment">//! id.forget();</span>
|
||||||
<span class="doccomment">//! HttpResponse::Ok().finish()</span>
|
<span class="doccomment">//! HttpResponse::Ok().finish()</span>
|
||||||
<span class="doccomment">//! }</span>
|
<span class="doccomment">//! }</span>
|
||||||
<span class="doccomment">//!</span>
|
<span class="doccomment">//!</span>
|
||||||
<span class="doccomment">//! #[actix_web::main]</span>
|
|
||||||
<span class="doccomment">//! async fn main() -> std::io::Result<()> {</span>
|
|
||||||
<span class="doccomment">//! HttpServer::new(move || {</span>
|
<span class="doccomment">//! HttpServer::new(move || {</span>
|
||||||
<span class="doccomment">//! // create cookie identity backend</span>
|
<span class="doccomment">//! // create cookie identity backend (inside closure, since policy is not Clone)</span>
|
||||||
<span class="doccomment">//! let policy = CookieIdentityPolicy::new(&[0; 32])</span>
|
<span class="doccomment">//! let policy = CookieIdentityPolicy::new(&[0; 32])</span>
|
||||||
<span class="doccomment">//! .name("auth-cookie")</span>
|
<span class="doccomment">//! .name("auth-cookie")</span>
|
||||||
<span class="doccomment">//! .secure(false);</span>
|
<span class="doccomment">//! .secure(false);</span>
|
||||||
@ -216,10 +213,7 @@
|
|||||||
<span class="doccomment">//! .wrap(IdentityService::new(policy))</span>
|
<span class="doccomment">//! .wrap(IdentityService::new(policy))</span>
|
||||||
<span class="doccomment">//! .service(services![index, login, logout])</span>
|
<span class="doccomment">//! .service(services![index, login, logout])</span>
|
||||||
<span class="doccomment">//! })</span>
|
<span class="doccomment">//! })</span>
|
||||||
<span class="doccomment">//! .bind(("0.0.0.0", 8080u16))?</span>
|
<span class="doccomment">//! # ;</span>
|
||||||
<span class="doccomment">//! .run()</span>
|
|
||||||
<span class="doccomment">//! .await</span>
|
|
||||||
<span class="doccomment">//! }</span>
|
|
||||||
<span class="doccomment">//! ```</span>
|
<span class="doccomment">//! ```</span>
|
||||||
|
|
||||||
<span class="attribute">#![<span class="ident">deny</span>(<span class="ident">rust_2018_idioms</span>, <span class="ident">nonstandard_style</span>)]</span>
|
<span class="attribute">#![<span class="ident">deny</span>(<span class="ident">rust_2018_idioms</span>, <span class="ident">nonstandard_style</span>)]</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user