mirror of
https://github.com/actix/actix-website
synced 2025-06-30 08:44:27 +02:00
Add api docs
This commit is contained in:
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=struct.CookieIdentityPolicy.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="struct.CookieIdentityPolicy.html">struct.CookieIdentityPolicy.html</a>...</p>
|
||||
<script>location.replace("struct.CookieIdentityPolicy.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=trait.Identity.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="trait.Identity.html">trait.Identity.html</a>...</p>
|
||||
<script>location.replace("trait.Identity.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=trait.IdentityPolicy.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="trait.IdentityPolicy.html">trait.IdentityPolicy.html</a>...</p>
|
||||
<script>location.replace("trait.IdentityPolicy.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=struct.IdentityService.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="struct.IdentityService.html">struct.IdentityService.html</a>...</p>
|
||||
<script>location.replace("struct.IdentityService.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=trait.RequestIdentity.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="trait.RequestIdentity.html">trait.RequestIdentity.html</a>...</p>
|
||||
<script>location.replace("trait.RequestIdentity.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `identity` mod in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, identity"><title>actix_web::middleware::identity - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Module identity</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div><p class='location'><a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a></p><script>window.sidebarCurrent = {name: 'identity', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Module <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a class="mod" href=''>identity</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#1-387' title='goto source code'>[src]</a></span></h1><div class='docblock'><p>Request identity service for Actix applications.</p>
|
||||
<p><a href="struct.IdentityService.html"><strong>IdentityService</strong></a> middleware can be
|
||||
used with different policies types to store identity information.</p>
|
||||
<p>By default, only cookie identity policy is implemented. Other backend
|
||||
implementations can be added separately.</p>
|
||||
<p><a href="struct.CookieIdentityPolicy.html"><strong>CookieIdentityPolicy</strong></a>
|
||||
uses cookies as identity storage.</p>
|
||||
<p>To access current request identity
|
||||
<a href="trait.RequestIdentity.html"><strong>RequestIdentity</strong></a> should be used.
|
||||
<em>HttpRequest</em> implements <em>RequestIdentity</em> trait.</p>
|
||||
|
||||
<pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">middleware</span>::<span class="ident">identity</span>::<span class="ident">RequestIdentity</span>;
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">middleware</span>::<span class="ident">identity</span>::{<span class="ident">CookieIdentityPolicy</span>, <span class="ident">IdentityService</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="kw-2">*</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">req</span>: <span class="ident">HttpRequest</span>) <span class="op">-></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">String</span><span class="op">></span> {
|
||||
<span class="comment">// access request identity</span>
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">id</span>) <span class="op">=</span> <span class="ident">req</span>.<span class="ident">identity</span>() {
|
||||
<span class="prelude-val">Ok</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">"Welcome! {}"</span>, <span class="ident">id</span>))
|
||||
} <span class="kw">else</span> {
|
||||
<span class="prelude-val">Ok</span>(<span class="string">"Welcome Anonymous!"</span>.<span class="ident">to_owned</span>())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">login</span>(<span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">HttpRequest</span>) <span class="op">-></span> <span class="ident">HttpResponse</span> {
|
||||
<span class="ident">req</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="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>()
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">logout</span>(<span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">HttpRequest</span>) <span class="op">-></span> <span class="ident">HttpResponse</span> {
|
||||
<span class="ident">req</span>.<span class="ident">forget</span>(); <span class="comment">// <- remove identity</span>
|
||||
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>()
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>().<span class="ident">middleware</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
|
||||
<span class="comment">// <- create identity middleware</span>
|
||||
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&</span>[<span class="number">0</span>; <span class="number">32</span>]) <span class="comment">// <- create cookie session backend</span>
|
||||
.<span class="ident">name</span>(<span class="string">"auth-cookie"</span>)
|
||||
.<span class="ident">secure</span>(<span class="bool-val">false</span>),
|
||||
));
|
||||
}</pre>
|
||||
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
||||
<table>
|
||||
<tr class=' module-item'>
|
||||
<td><a class="struct" href="struct.CookieIdentityPolicy.html"
|
||||
title='struct actix_web::middleware::identity::CookieIdentityPolicy'>CookieIdentityPolicy</a></td>
|
||||
<td class='docblock-short'>
|
||||
<p>Use cookies for request identity storage.</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr class=' module-item'>
|
||||
<td><a class="struct" href="struct.IdentityService.html"
|
||||
title='struct actix_web::middleware::identity::IdentityService'>IdentityService</a></td>
|
||||
<td class='docblock-short'>
|
||||
<p>Request identity middleware</p>
|
||||
|
||||
</td>
|
||||
</tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
|
||||
<table>
|
||||
<tr class=' module-item'>
|
||||
<td><a class="trait" href="trait.Identity.html"
|
||||
title='trait actix_web::middleware::identity::Identity'>Identity</a></td>
|
||||
<td class='docblock-short'>
|
||||
<p>An identity</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr class=' module-item'>
|
||||
<td><a class="trait" href="trait.IdentityPolicy.html"
|
||||
title='trait actix_web::middleware::identity::IdentityPolicy'>IdentityPolicy</a></td>
|
||||
<td class='docblock-short'>
|
||||
<p>Identity policy definition.</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr class=' module-item'>
|
||||
<td><a class="trait" href="trait.RequestIdentity.html"
|
||||
title='trait actix_web::middleware::identity::RequestIdentity'>RequestIdentity</a></td>
|
||||
<td class='docblock-short'>
|
||||
<p>The helper trait to obtain your identity from a request.</p>
|
||||
|
||||
</td>
|
||||
</tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "actix_web";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["CookieIdentityPolicy","Use cookies for request identity storage."],["IdentityService","Request identity middleware"]],"trait":[["Identity","An identity"],["IdentityPolicy","Identity policy definition."],["RequestIdentity","The helper trait to obtain your identity from a request."]]});
|
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `CookieIdentityPolicy` struct in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, CookieIdentityPolicy"><title>actix_web::middleware::identity::CookieIdentityPolicy - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Struct CookieIdentityPolicy</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.path">path</a><a href="#method.name">name</a><a href="#method.domain">domain</a><a href="#method.secure">secure</a><a href="#method.max_age">max_age</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-IdentityPolicy%3CS%3E">IdentityPolicy<S></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a></div></div><p class='location'><a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a></p><script>window.sidebarCurrent = {name: 'CookieIdentityPolicy', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a>::<wbr><a class="struct" href=''>CookieIdentityPolicy</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#331' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust struct'>pub struct CookieIdentityPolicy(_);</pre></div><div class='docblock'><p>Use cookies for request identity storage.</p>
|
||||
<p>The constructors take a key as an argument.
|
||||
This is the private key for cookie - when this value is changed,
|
||||
all identities are lost. The constructors will panic if the key is less
|
||||
than 32 bytes in length.</p>
|
||||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||||
<pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">middleware</span>::<span class="ident">identity</span>::{<span class="ident">CookieIdentityPolicy</span>, <span class="ident">IdentityService</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">App</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>().<span class="ident">middleware</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
|
||||
<span class="comment">// <- create identity middleware</span>
|
||||
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&</span>[<span class="number">0</span>; <span class="number">32</span>]) <span class="comment">// <- construct cookie policy</span>
|
||||
.<span class="ident">domain</span>(<span class="string">"www.rust-lang.org"</span>)
|
||||
.<span class="ident">name</span>(<span class="string">"actix_auth"</span>)
|
||||
.<span class="ident">path</span>(<span class="string">"/"</span>)
|
||||
.<span class="ident">secure</span>(<span class="bool-val">true</span>),
|
||||
));
|
||||
}</pre>
|
||||
</div>
|
||||
<h2 id='methods' class='small-section-header'>
|
||||
Methods<a href='#methods' class='anchor'></a>
|
||||
</h2>
|
||||
<h3 id='impl' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code><a href='#impl' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#333-373' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.new' class='fnname'>new</a>(key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#337-339' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Construct new <code>CookieIdentityPolicy</code> instance.</p>
|
||||
<p>Panics if key length is less than 32 bytes.</p>
|
||||
</div><h4 id='method.path' class="method"><span id='path.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.path' class='fnname'>path</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(self, value: S) -> <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#342-345' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Sets the <code>path</code> field in the session cookie being built.</p>
|
||||
</div><h4 id='method.name' class="method"><span id='name.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.name' class='fnname'>name</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(self, value: S) -> <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#348-351' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Sets the <code>name</code> field in the session cookie being built.</p>
|
||||
</div><h4 id='method.domain' class="method"><span id='domain.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.domain' class='fnname'>domain</a><S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>>(self, value: S) -> <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#354-357' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Sets the <code>domain</code> field in the session cookie being built.</p>
|
||||
</div><h4 id='method.secure' class="method"><span id='secure.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.secure' class='fnname'>secure</a>(self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#363-366' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Sets the <code>secure</code> field in the session cookie being built.</p>
|
||||
<p>If the <code>secure</code> field is set, a cookie will only be transmitted when the
|
||||
connection is secure - i.e. <code>https</code></p>
|
||||
</div><h4 id='method.max_age' class="method"><span id='max_age.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.max_age' class='fnname'>max_age</a>(self, value: <a class="struct" href="https://doc.rust-lang.org/time/time/duration/struct.Duration.html" title="struct time::duration::Duration">Duration</a>) -> <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#369-372' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Sets the <code>max-age</code> field in the session cookie being built.</p>
|
||||
</div></div>
|
||||
<h2 id='implementations' class='small-section-header'>
|
||||
Trait Implementations<a href='#implementations' class='anchor'></a>
|
||||
</h2>
|
||||
<div id='implementations-list'><h3 id='impl-IdentityPolicy%3CS%3E' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl<S> <a class="trait" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html" title="trait actix_web::middleware::identity::IdentityPolicy">IdentityPolicy</a><S> for <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code><a href='#impl-IdentityPolicy%3CS%3E' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#375-387' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Identity' class="type"><span id='Identity.t' class='invisible'><code>type <a href='../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Identity' class="type">Identity</a> = CookieIdentity</code></span></h4>
|
||||
<div class='docblock'><p>The associated identity</p>
|
||||
</div><h4 id='associatedtype.Future' class="type"><span id='Future.t' class='invisible'><code>type <a href='../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Future' class="type">Future</a> = <a class="struct" href="https://docs.rs/futures/0.1/futures/future/result_/struct.FutureResult.html" title="struct futures::future::result_::FutureResult">FutureResult</a><CookieIdentity, <a class="struct" href="../../../actix_web/error/struct.Error.html" title="struct actix_web::error::Error">Error</a>></code></span></h4>
|
||||
<div class='docblock'><p>The return type of the middleware</p>
|
||||
</div><h4 id='method.from_request' class="method"><span id='from_request.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../../actix_web/middleware/identity/trait.IdentityPolicy.html#tymethod.from_request' class='fnname'>from_request</a>(&self, req: &<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S>) -> Self::<a class="type" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Future" title="type actix_web::middleware::identity::IdentityPolicy::Future">Future</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#379-386' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Parse the session from request and load data from a service identity.</p>
|
||||
</div></div></div>
|
||||
<h2 id='synthetic-implementations' class='small-section-header'>
|
||||
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
|
||||
</h2>
|
||||
<div id='synthetic-implementations-list'>
|
||||
<h3 id='impl-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "actix_web";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `IdentityService` struct in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, IdentityService"><title>actix_web::middleware::identity::IdentityService - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Struct IdentityService</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Middleware%3CS%3E">Middleware<S></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div></div><p class='location'><a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a></p><script>window.sidebarCurrent = {name: 'IdentityService', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a>::<wbr><a class="struct" href=''>IdentityService</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#167-169' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust struct'>pub struct IdentityService<T> { /* fields omitted */ }</pre></div><div class='docblock'><p>Request identity middleware</p>
|
||||
|
||||
<pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">middleware</span>::<span class="ident">identity</span>::{<span class="ident">CookieIdentityPolicy</span>, <span class="ident">IdentityService</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">App</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>().<span class="ident">middleware</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
|
||||
<span class="comment">// <- create identity middleware</span>
|
||||
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&</span>[<span class="number">0</span>; <span class="number">32</span>]) <span class="comment">// <- create cookie session backend</span>
|
||||
.<span class="ident">name</span>(<span class="string">"auth-cookie"</span>)
|
||||
.<span class="ident">secure</span>(<span class="bool-val">false</span>),
|
||||
));
|
||||
}</pre>
|
||||
</div>
|
||||
<h2 id='methods' class='small-section-header'>
|
||||
Methods<a href='#methods' class='anchor'></a>
|
||||
</h2>
|
||||
<h3 id='impl' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl<T> <a class="struct" href="../../../actix_web/middleware/identity/struct.IdentityService.html" title="struct actix_web::middleware::identity::IdentityService">IdentityService</a><T></code><a href='#impl' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#171-176' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.new' class='fnname'>new</a>(backend: T) -> Self</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#173-175' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Create new identity service with specified backend.</p>
|
||||
</div></div>
|
||||
<h2 id='implementations' class='small-section-header'>
|
||||
Trait Implementations<a href='#implementations' class='anchor'></a>
|
||||
</h2>
|
||||
<div id='implementations-list'><h3 id='impl-Middleware%3CS%3E' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl<S: 'static, T: <a class="trait" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html" title="trait actix_web::middleware::identity::IdentityPolicy">IdentityPolicy</a><S>> <a class="trait" href="../../../actix_web/middleware/trait.Middleware.html" title="trait actix_web::middleware::Middleware">Middleware</a><S> for <a class="struct" href="../../../actix_web/middleware/identity/struct.IdentityService.html" title="struct actix_web::middleware::identity::IdentityService">IdentityService</a><T></code><a href='#impl-Middleware%3CS%3E' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#180-200' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.start' class="method"><span id='start.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../../actix_web/middleware/trait.Middleware.html#method.start' class='fnname'>start</a>(&self, req: &<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S>) -> <a class="type" href="../../../actix_web/error/type.Result.html" title="type actix_web::error::Result">Result</a><<a class="enum" href="../../../actix_web/middleware/enum.Started.html" title="enum actix_web::middleware::Started">Started</a>></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#181-191' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Method is called when request is ready. It may return future, which should resolve before next middleware get called. <a href="../../../actix_web/middleware/trait.Middleware.html#method.start">Read more</a></p>
|
||||
</div><h4 id='method.response' class="method"><span id='response.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../../actix_web/middleware/trait.Middleware.html#method.response' class='fnname'>response</a>(&self, req: &<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S>, resp: <a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>) -> <a class="type" href="../../../actix_web/error/type.Result.html" title="type actix_web::error::Result">Result</a><<a class="enum" href="../../../actix_web/middleware/enum.Response.html" title="enum actix_web::middleware::Response">Response</a>></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#193-199' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Method is called when handler returns response, but before sending http message to peer. <a href="../../../actix_web/middleware/trait.Middleware.html#method.response">Read more</a></p>
|
||||
</div><h4 id='method.finish' class="method"><span id='finish.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../../actix_web/middleware/trait.Middleware.html#method.finish' class='fnname'>finish</a>(&self, req: &<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S>, resp: &<a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>) -> <a class="enum" href="../../../actix_web/middleware/enum.Finished.html" title="enum actix_web::middleware::Finished">Finished</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/mod.rs.html#65-67' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Method is called after body stream get sent to peer.</p>
|
||||
</div></div></div>
|
||||
<h2 id='synthetic-implementations' class='small-section-header'>
|
||||
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
|
||||
</h2>
|
||||
<div id='synthetic-implementations-list'>
|
||||
<h3 id='impl-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../actix_web/middleware/identity/struct.IdentityService.html" title="struct actix_web::middleware::identity::IdentityService">IdentityService</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../actix_web/middleware/identity/struct.IdentityService.html" title="struct actix_web::middleware::identity::IdentityService">IdentityService</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>, </span></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "actix_web";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Identity` trait in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, Identity"><title>actix_web::middleware::identity::Identity - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Trait Identity</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.identity">identity</a><a href="#tymethod.remember">remember</a><a href="#tymethod.forget">forget</a><a href="#tymethod.write">write</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a></p><script>window.sidebarCurrent = {name: 'Identity', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Trait <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a>::<wbr><a class="trait" href=''>Identity</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#123-137' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust trait'>pub trait Identity: 'static {
|
||||
fn <a href='#tymethod.identity' class='fnname'>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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>;
|
||||
<div class='item-spacer'></div> fn <a href='#tymethod.remember' class='fnname'>remember</a>(&mut self, key: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>);
|
||||
<div class='item-spacer'></div> fn <a href='#tymethod.forget' class='fnname'>forget</a>(&mut self);
|
||||
<div class='item-spacer'></div> fn <a href='#tymethod.write' class='fnname'>write</a>(&mut self, resp: <a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>) -> <a class="type" href="../../../actix_web/error/type.Result.html" title="type actix_web::error::Result">Result</a><<a class="enum" href="../../../actix_web/middleware/enum.Response.html" title="enum actix_web::middleware::Response">Response</a>>;
|
||||
}</pre></div><div class='docblock'><p>An identity</p>
|
||||
</div>
|
||||
<h2 id='required-methods' class='small-section-header'>
|
||||
Required Methods<a href='#required-methods' class='anchor'></a>
|
||||
</h2>
|
||||
<div class='methods'>
|
||||
<h3 id='tymethod.identity' class='method'><span id='identity.v' class='invisible'><code>fn <a href='#tymethod.identity' class='fnname'>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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></code></span></h3><div class='docblock'><p>Return the claimed identity of the user associated request or
|
||||
<code>None</code> if no identity can be found associated with the request.</p>
|
||||
</div><h3 id='tymethod.remember' class='method'><span id='remember.v' class='invisible'><code>fn <a href='#tymethod.remember' class='fnname'>remember</a>(&mut self, key: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>)</code></span></h3><div class='docblock'><p>Remember identity.</p>
|
||||
</div><h3 id='tymethod.forget' class='method'><span id='forget.v' class='invisible'><code>fn <a href='#tymethod.forget' class='fnname'>forget</a>(&mut self)</code></span></h3><div class='docblock'><p>This method is used to 'forget' the current identity on subsequent
|
||||
requests.</p>
|
||||
</div><h3 id='tymethod.write' class='method'><span id='write.v' class='invisible'><code>fn <a href='#tymethod.write' class='fnname'>write</a>(&mut self, resp: <a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>) -> <a class="type" href="../../../actix_web/error/type.Result.html" title="type actix_web::error::Result">Result</a><<a class="enum" href="../../../actix_web/middleware/enum.Response.html" title="enum actix_web::middleware::Response">Response</a>></code></span></h3><div class='docblock'><p>Write session to storage backend.</p>
|
||||
</div></div>
|
||||
<h2 id='implementors' class='small-section-header'>
|
||||
Implementors<a href='#implementors' class='anchor'></a>
|
||||
</h2>
|
||||
<ul class='item-list' id='implementors-list'>
|
||||
</ul><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
|
||||
src="../../../implementors/actix_web/middleware/identity/trait.Identity.js">
|
||||
</script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "actix_web";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `IdentityPolicy` trait in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, IdentityPolicy"><title>actix_web::middleware::identity::IdentityPolicy - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Trait IdentityPolicy</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Identity">Identity</a><a href="#associatedtype.Future">Future</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.from_request">from_request</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a></p><script>window.sidebarCurrent = {name: 'IdentityPolicy', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Trait <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a>::<wbr><a class="trait" href=''>IdentityPolicy</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#140-149' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust trait'>pub trait IdentityPolicy<S>: <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.Identity' class="type">Identity</a>: <a class="trait" href="../../../actix_web/middleware/identity/trait.Identity.html" title="trait actix_web::middleware::identity::Identity">Identity</a>;
|
||||
type <a href='#associatedtype.Future' class="type">Future</a>: <a class="trait" href="https://docs.rs/futures/0.1/futures/future/trait.Future.html" title="trait futures::future::Future">Future</a><Item = Self::<a class="type" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Identity" title="type actix_web::middleware::identity::IdentityPolicy::Identity">Identity</a>, Error = <a class="struct" href="../../../actix_web/error/struct.Error.html" title="struct actix_web::error::Error">Error</a>>;
|
||||
fn <a href='#tymethod.from_request' class='fnname'>from_request</a>(&self, request: &<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S>) -> Self::<a class="type" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Future" title="type actix_web::middleware::identity::IdentityPolicy::Future">Future</a>;
|
||||
}</pre></div><div class='docblock'><p>Identity policy definition.</p>
|
||||
</div>
|
||||
<h2 id='associated-types' class='small-section-header'>
|
||||
Associated Types<a href='#associated-types' class='anchor'></a>
|
||||
</h2>
|
||||
<div class='methods'>
|
||||
<h3 id='associatedtype.Identity' class='method'><span id='Identity.t' class='invisible'><code>type <a href='#associatedtype.Identity' class="type">Identity</a>: <a class="trait" href="../../../actix_web/middleware/identity/trait.Identity.html" title="trait actix_web::middleware::identity::Identity">Identity</a></code></span></h3><div class='docblock'><p>The associated identity</p>
|
||||
</div><h3 id='associatedtype.Future' class='method'><span id='Future.t' class='invisible'><code>type <a href='#associatedtype.Future' class="type">Future</a>: <a class="trait" href="https://docs.rs/futures/0.1/futures/future/trait.Future.html" title="trait futures::future::Future">Future</a><Item = Self::<a class="type" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Identity" title="type actix_web::middleware::identity::IdentityPolicy::Identity">Identity</a>, Error = <a class="struct" href="../../../actix_web/error/struct.Error.html" title="struct actix_web::error::Error">Error</a>></code></span></h3><div class='docblock'><p>The return type of the middleware</p>
|
||||
</div></div>
|
||||
<h2 id='required-methods' class='small-section-header'>
|
||||
Required Methods<a href='#required-methods' class='anchor'></a>
|
||||
</h2>
|
||||
<div class='methods'>
|
||||
<h3 id='tymethod.from_request' class='method'><span id='from_request.v' class='invisible'><code>fn <a href='#tymethod.from_request' class='fnname'>from_request</a>(&self, request: &<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S>) -> Self::<a class="type" href="../../../actix_web/middleware/identity/trait.IdentityPolicy.html#associatedtype.Future" title="type actix_web::middleware::identity::IdentityPolicy::Future">Future</a></code></span></h3><div class='docblock'><p>Parse the session from request and load data from a service identity.</p>
|
||||
</div></div>
|
||||
<h2 id='implementors' class='small-section-header'>
|
||||
Implementors<a href='#implementors' class='anchor'></a>
|
||||
</h2>
|
||||
<ul class='item-list' id='implementors-list'>
|
||||
<li><table class='table-display'><tbody><tr><td><code>impl<S> IdentityPolicy<S> for <a class="struct" href="../../../actix_web/middleware/identity/struct.CookieIdentityPolicy.html" title="struct actix_web::middleware::identity::CookieIdentityPolicy">CookieIdentityPolicy</a><span class="where fmt-newline"> type <a href='#associatedtype.Identity' class="type">Identity</a> = CookieIdentity;</span><span class="where fmt-newline"> type <a href='#associatedtype.Future' class="type">Future</a> = <a class="struct" href="https://docs.rs/futures/0.1/futures/future/result_/struct.FutureResult.html" title="struct futures::future::result_::FutureResult">FutureResult</a><CookieIdentity, <a class="struct" href="../../../actix_web/error/struct.Error.html" title="struct actix_web::error::Error">Error</a>>;</span></code><td><div class='out-of-band'><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#375-387' title='goto source code'>[src]</a></div></td></tr></tbody></table></li>
|
||||
</ul><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
|
||||
src="../../../implementors/actix_web/middleware/identity/trait.IdentityPolicy.js">
|
||||
</script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "actix_web";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `RequestIdentity` trait in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, RequestIdentity"><title>actix_web::middleware::identity::RequestIdentity - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Trait RequestIdentity</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.identity">identity</a><a href="#tymethod.remember">remember</a><a href="#tymethod.forget">forget</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a></p><script>window.sidebarCurrent = {name: 'RequestIdentity', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Trait <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>identity</a>::<wbr><a class="trait" href=''>RequestIdentity</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#88-99' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust trait'>pub trait RequestIdentity {
|
||||
fn <a href='#tymethod.identity' class='fnname'>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>>;
|
||||
<div class='item-spacer'></div> fn <a href='#tymethod.remember' class='fnname'>remember</a>(&self, identity: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>);
|
||||
<div class='item-spacer'></div> fn <a href='#tymethod.forget' class='fnname'>forget</a>(&self);
|
||||
}</pre></div><div class='docblock'><p>The helper trait to obtain your identity from a request.</p>
|
||||
|
||||
<pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">middleware</span>::<span class="ident">identity</span>::<span class="ident">RequestIdentity</span>;
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="kw-2">*</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">req</span>: <span class="ident">HttpRequest</span>) <span class="op">-></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">String</span><span class="op">></span> {
|
||||
<span class="comment">// access request identity</span>
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">id</span>) <span class="op">=</span> <span class="ident">req</span>.<span class="ident">identity</span>() {
|
||||
<span class="prelude-val">Ok</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">"Welcome! {}"</span>, <span class="ident">id</span>))
|
||||
} <span class="kw">else</span> {
|
||||
<span class="prelude-val">Ok</span>(<span class="string">"Welcome Anonymous!"</span>.<span class="ident">to_owned</span>())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">login</span>(<span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">HttpRequest</span>) <span class="op">-></span> <span class="ident">HttpResponse</span> {
|
||||
<span class="ident">req</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="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>()
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">logout</span>(<span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">HttpRequest</span>) <span class="op">-></span> <span class="ident">HttpResponse</span> {
|
||||
<span class="ident">req</span>.<span class="ident">forget</span>(); <span class="comment">// <- remove identity</span>
|
||||
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>()
|
||||
}</pre>
|
||||
</div>
|
||||
<h2 id='required-methods' class='small-section-header'>
|
||||
Required Methods<a href='#required-methods' class='anchor'></a>
|
||||
</h2>
|
||||
<div class='methods'>
|
||||
<h3 id='tymethod.identity' class='method'><span id='identity.v' class='invisible'><code>fn <a href='#tymethod.identity' class='fnname'>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></span></h3><div class='docblock'><p>Return the claimed identity of the user associated request or
|
||||
<code>None</code> if no identity can be found associated with the request.</p>
|
||||
</div><h3 id='tymethod.remember' class='method'><span id='remember.v' class='invisible'><code>fn <a href='#tymethod.remember' class='fnname'>remember</a>(&self, identity: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>)</code></span></h3><div class='docblock'><p>Remember identity.</p>
|
||||
</div><h3 id='tymethod.forget' class='method'><span id='forget.v' class='invisible'><code>fn <a href='#tymethod.forget' class='fnname'>forget</a>(&self)</code></span></h3><div class='docblock'><p>This method is used to 'forget' the current identity on subsequent
|
||||
requests.</p>
|
||||
</div></div>
|
||||
<h2 id='implementors' class='small-section-header'>
|
||||
Implementors<a href='#implementors' class='anchor'></a>
|
||||
</h2>
|
||||
<ul class='item-list' id='implementors-list'>
|
||||
<li><table class='table-display'><tbody><tr><td><code>impl<S> RequestIdentity for <a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a><S></code><td><div class='out-of-band'><a class='srclink' href='../../../src/actix_web/middleware/identity.rs.html#101-120' title='goto source code'>[src]</a></div></td></tr></tbody></table></li>
|
||||
</ul><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
|
||||
src="../../../implementors/actix_web/middleware/identity/trait.RequestIdentity.js">
|
||||
</script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "actix_web";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
Reference in New Issue
Block a user