1
0
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:
Nikolay Kim
2018-07-21 04:09:47 -07:00
parent 35a9469409
commit 52a58cc626
5528 changed files with 266014 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=enum.CsrfError.html">
</head>
<body>
<p>Redirecting to <a href="enum.CsrfError.html">enum.CsrfError.html</a>...</p>
<script>location.replace("enum.CsrfError.html" + location.search + location.hash);</script>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=struct.CsrfFilter.html">
</head>
<body>
<p>Redirecting to <a href="struct.CsrfFilter.html">struct.CsrfFilter.html</a>...</p>
<script>location.replace("struct.CsrfFilter.html" + location.search + location.hash);</script>
</body>
</html>

View File

@ -0,0 +1,29 @@
<!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 `CsrfError` enum in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, CsrfError"><title>actix_web::middleware::csrf::CsrfError - 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 enum"><!--[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">&#9776;</div><p class='location'>Enum CsrfError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.MissingOrigin">MissingOrigin</a><a href="#variant.BadOrigin">BadOrigin</a><a href="#variant.CsrDenied">CsrDenied</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Fail">Fail</a><a href="#impl-Display">Display</a><a href="#impl-ResponseError">ResponseError</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'>csrf</a></p><script>window.sidebarCurrent = {name: 'CsrfError', ty: 'enum', 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'>Enum <a href='../../index.html'>actix_web</a>::<wbr><a href='../index.html'>middleware</a>::<wbr><a href='index.html'>csrf</a>::<wbr><a class="enum" href=''>CsrfError</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'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#60-70' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust enum'>pub enum CsrfError {
MissingOrigin,
BadOrigin,
CsrDenied,
}</pre></div><div class='docblock'><p>Potential cross-site request forgery detected.</p>
</div><h2 id='variants' class='variants small-section-header'>
Variants<a href='#variants' class='anchor'></a></h2>
<span id="variant.MissingOrigin" class="variant small-section-header"><a href="#variant.MissingOrigin" class="anchor field"></a><span id='MissingOrigin.v' class='invisible'><code>MissingOrigin</code></span></span><div class='docblock'><p>The HTTP request header <code>Origin</code> was required but not provided.</p>
</div><span id="variant.BadOrigin" class="variant small-section-header"><a href="#variant.BadOrigin" class="anchor field"></a><span id='BadOrigin.v' class='invisible'><code>BadOrigin</code></span></span><div class='docblock'><p>The HTTP request header <code>Origin</code> could not be parsed correctly.</p>
</div><span id="variant.CsrDenied" class="variant small-section-header"><a href="#variant.CsrDenied" class="anchor field"></a><span id='CsrDenied.v' class='invisible'><code>CsrDenied</code></span></span><div class='docblock'><p>The cross-site request was denied.</p>
</div>
<h2 id='implementations' class='small-section-header'>
Trait Implementations<a href='#implementations' class='anchor'></a>
</h2>
<div id='implementations-list'><h3 id='impl-Debug' 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/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../../../actix_web/middleware/csrf/enum.CsrfError.html" title="enum actix_web::middleware::csrf::CsrfError">CsrfError</a></code><a href='#impl-Debug' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-Fail' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl Fail for <a class="enum" href="../../../actix_web/middleware/csrf/enum.CsrfError.html" title="enum actix_web::middleware::csrf::CsrfError">CsrfError</a></code><a href='#impl-Fail' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.cause' class="method"><span id='cause.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='#method.cause' class='fnname'>cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Fail&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns a reference to the underlying cause of this failure, if it is an error that wraps other errors. <a href="#method.cause">Read more</a></p>
</div><h4 id='method.backtrace' class="method"><span id='backtrace.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='#method.backtrace' class='fnname'>backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Backtrace&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns a reference to the <code>Backtrace</code> carried by this failure, if it carries one. <a href="#method.backtrace">Read more</a></p>
</div><h4 id='method.context' class="method"><span id='context.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='#method.context' class='fnname'>context</a>&lt;D&gt;(self, context: D) -&gt; Context&lt;D&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;D: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,&nbsp;</span></code></td><td></td></tr></tbody></table></span></h4><div class='docblock'><p>Provides context for this failure. <a href="#method.context">Read more</a></p>
</div><h4 id='method.compat' class="method"><span id='compat.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='#method.compat' class='fnname'>compat</a>(self) -&gt; Compat&lt;Self&gt;</code></td><td></td></tr></tbody></table></span></h4><div class='docblock'><p>Wraps this failure in a compatibility wrapper that implements <code>std::error::Error</code>. <a href="#method.compat">Read more</a></p>
</div><h4 id='method.causes' class="method"><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for Causes&lt;'f&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for Causes&lt;'f&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'f&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for Causes&lt;'f&gt;</span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = &amp;'f (Fail + 'static);</span></code></div></div><span id='causes.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='#method.causes' class='fnname'>causes</a>(&amp;self) -&gt; Causes</code></td><td></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns a iterator over the causes of this <code>Fail</code> with itself as the first item and the <code>root_cause</code> as the final item. <a href="#method.causes">Read more</a></p>
</div><h4 id='method.root_cause' class="method"><span id='root_cause.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='#method.root_cause' class='fnname'>root_cause</a>(&amp;self) -&gt; &amp;(Fail + 'static)</code></td><td></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns the &quot;root cause&quot; of this <code>Fail</code> - the last value in the cause chain which does not return an underlying <code>cause</code>. <a href="#method.root_cause">Read more</a></p>
</div></div><h3 id='impl-Display' 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/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="enum" href="../../../actix_web/middleware/csrf/enum.CsrfError.html" title="enum actix_web::middleware::csrf::CsrfError">CsrfError</a></code><a href='#impl-Display' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt-1' class="method"><span id='fmt.v-1' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#59' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-ResponseError' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="../../../actix_web/error/trait.ResponseError.html" title="trait actix_web::error::ResponseError">ResponseError</a> for <a class="enum" href="../../../actix_web/middleware/csrf/enum.CsrfError.html" title="enum actix_web::middleware::csrf::CsrfError">CsrfError</a></code><a href='#impl-ResponseError' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#72-76' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.error_response' class="method"><span id='error_response.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../../actix_web/error/trait.ResponseError.html#method.error_response' class='fnname'>error_response</a>(&amp;self) -&gt; <a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#73-75' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Create response for error <a href="../../../actix_web/error/trait.ResponseError.html#method.error_response">Read more</a></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="enum" href="../../../actix_web/middleware/csrf/enum.CsrfError.html" title="enum actix_web::middleware::csrf::CsrfError">CsrfError</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="enum" href="../../../actix_web/middleware/csrf/enum.CsrfError.html" title="enum actix_web::middleware::csrf::CsrfError">CsrfError</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>&#9166;</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>

View File

@ -0,0 +1,57 @@
<!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 `csrf` mod in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, csrf"><title>actix_web::middleware::csrf - 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">&#9776;</div><p class='location'>Module csrf</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</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: 'csrf', 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=''>csrf</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'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#1-276' title='goto source code'>[src]</a></span></h1><div class='docblock'><p>A filter for cross-site request forgery (CSRF).</p>
<p>This middleware is stateless and <a href="https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Verifying_Same_Origin_with_Standard_Headers">based on request
headers</a>.</p>
<p>By default requests are allowed only if one of these is true:</p>
<ul>
<li>The request method is safe (<code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>). It is the
applications responsibility to ensure these methods cannot be used to
execute unwanted actions. Note that upgrade requests for websockets are
also considered safe.</li>
<li>The <code>Origin</code> header (added automatically by the browser) matches one
of the allowed origins.</li>
<li>There is no <code>Origin</code> header but the <code>Referer</code> header matches one of
the allowed origins.</li>
</ul>
<p>Use <a href="struct.CsrfFilter.html#method.allow_xhr"><code>CsrfFilter::allow_xhr()</code></a>
if you want to allow requests with unprotected methods via
<a href="../cors/struct.Cors.html">CORS</a>.</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">csrf</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">http</span>, <span class="ident">App</span>, <span class="ident">HttpRequest</span>, <span class="ident">HttpResponse</span>};
<span class="kw">fn</span> <span class="ident">handle_post</span>(<span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>) <span class="op">-&gt;</span> <span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span> {
<span class="string">&quot;This action should only be triggered with requests from the same site&quot;</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">csrf</span>::<span class="ident">CsrfFilter</span>::<span class="ident">new</span>().<span class="ident">allowed_origin</span>(<span class="string">&quot;https://www.example.com&quot;</span>),
)
.<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>, <span class="op">|</span><span class="ident">r</span><span class="op">|</span> {
<span class="ident">r</span>.<span class="ident">method</span>(<span class="ident">http</span>::<span class="ident">Method</span>::<span class="ident">GET</span>).<span class="ident">f</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>());
<span class="ident">r</span>.<span class="ident">method</span>(<span class="ident">http</span>::<span class="ident">Method</span>::<span class="ident">POST</span>).<span class="ident">f</span>(<span class="ident">handle_post</span>);
})
.<span class="ident">finish</span>();
}</pre>
<p>In this example the entire application is protected from CSRF.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class="struct" href="struct.CsrfFilter.html"
title='struct actix_web::middleware::csrf::CsrfFilter'>CsrfFilter</a></td>
<td class='docblock-short'>
<p>A middleware that filters cross-site requests.</p>
</td>
</tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class="enum" href="enum.CsrfError.html"
title='enum actix_web::middleware::csrf::CsrfError'>CsrfError</a></td>
<td class='docblock-short'>
<p>Potential cross-site request forgery detected.</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>&#9166;</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>

View File

@ -0,0 +1 @@
initSidebarItems({"enum":[["CsrfError","Potential cross-site request forgery detected."]],"struct":[["CsrfFilter","A middleware that filters cross-site requests."]]});

View File

@ -0,0 +1,52 @@
<!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 `CsrfFilter` struct in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, CsrfFilter"><title>actix_web::middleware::csrf::CsrfFilter - 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">&#9776;</div><p class='location'>Struct CsrfFilter</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.allowed_origin">allowed_origin</a><a href="#method.allow_xhr">allow_xhr</a><a href="#method.allow_missing_origin">allow_missing_origin</a><a href="#method.allow_upgrade">allow_upgrade</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Default">Default</a><a href="#impl-Middleware%3CS%3E">Middleware&lt;S&gt;</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'>csrf</a></p><script>window.sidebarCurrent = {name: 'CsrfFilter', 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'>csrf</a>::<wbr><a class="struct" href=''>CsrfFilter</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'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#132-137' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust struct'>pub struct CsrfFilter { /* fields omitted */ }</pre></div><div class='docblock'><p>A middleware that filters cross-site requests.</p>
<p>To construct a CSRF filter:</p>
<ol>
<li>Call <a href="struct.CsrfFilter.html#method.build"><code>CsrfFilter::build</code></a> to
start building.</li>
<li><a href="struct.CsrfFilterBuilder.html#method.allowed_origin">Add</a> allowed
origins.</li>
<li>Call <a href="struct.CsrfFilterBuilder.html#method.finish">finish</a> to retrieve
the constructed filter.</li>
</ol>
<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">csrf</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">App</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">csrf</span>::<span class="ident">CsrfFilter</span>::<span class="ident">new</span>().<span class="ident">allowed_origin</span>(<span class="string">&quot;https://www.example.com&quot;</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/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</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/csrf.rs.html#139-209' 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>() -&gt; <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#141-148' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Start building a <code>CsrfFilter</code>.</p>
</div><h4 id='method.allowed_origin' class="method"><span id='allowed_origin.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.allowed_origin' class='fnname'>allowed_origin</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;&gt;(self, origin: T) -&gt; <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#152-155' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Add an origin that is allowed to make requests. Will be verified
against the <code>Origin</code> request header.</p>
</div><h4 id='method.allow_xhr' class="method"><span id='allow_xhr.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.allow_xhr' class='fnname'>allow_xhr</a>(self) -&gt; <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#168-171' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Allow all requests with an <code>X-Requested-With</code> header.</p>
<p>A cross-site attacker should not be able to send requests with custom
headers unless a CORS policy whitelists them. Therefore it should be
safe to allow requests with an <code>X-Requested-With</code> header (added
automatically by many JavaScript libraries).</p>
<p>This is disabled by default, because in Safari it is possible to
circumvent this using redirects and Flash.</p>
<p>Use this method to enable more lax filtering.</p>
</div><h4 id='method.allow_missing_origin' class="method"><span id='allow_missing_origin.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.allow_missing_origin' class='fnname'>allow_missing_origin</a>(self) -&gt; <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#179-182' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Allow requests if the expected <code>Origin</code> header is missing (and
there is no <code>Referer</code> to fall back on).</p>
<p>The filter is conservative by default, but it should be safe to allow
missing <code>Origin</code> headers because a cross-site attacker cannot prevent
the browser from sending <code>Origin</code> on unprotected requests.</p>
</div><h4 id='method.allow_upgrade' class="method"><span id='allow_upgrade.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.allow_upgrade' class='fnname'>allow_upgrade</a>(self) -&gt; <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#185-188' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Allow cross-site upgrade requests (for example to open a WebSocket).</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-Default' 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/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code><a href='#impl-Default' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#131' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.default' class="method"><span id='default.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#131' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns the &quot;default value&quot; for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
</div></div><h3 id='impl-Middleware%3CS%3E' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;S&gt; <a class="trait" href="../../../actix_web/middleware/trait.Middleware.html" title="trait actix_web::middleware::Middleware">Middleware</a>&lt;S&gt; for <a class="struct" href="../../../actix_web/middleware/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</a></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/csrf.rs.html#211-216' 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>(&amp;self, req: &amp;<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>&lt;S&gt;) -&gt; <a class="type" href="../../../actix_web/error/type.Result.html" title="type actix_web::error::Result">Result</a>&lt;<a class="enum" href="../../../actix_web/middleware/enum.Started.html" title="enum actix_web::middleware::Started">Started</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/csrf.rs.html#212-215' 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>(&amp;self, req: &amp;<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>&lt;S&gt;, resp: <a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>) -&gt; <a class="type" href="../../../actix_web/error/type.Result.html" title="type actix_web::error::Result">Result</a>&lt;<a class="enum" href="../../../actix_web/middleware/enum.Response.html" title="enum actix_web::middleware::Response">Response</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../../src/actix_web/middleware/mod.rs.html#60-62' 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>(&amp;self, req: &amp;<a class="struct" href="../../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>&lt;S&gt;, resp: &amp;<a class="struct" href="../../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>) -&gt; <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 <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/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</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/csrf/struct.CsrfFilter.html" title="struct actix_web::middleware::csrf::CsrfFilter">CsrfFilter</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>&#9166;</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>