1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-08-31 19:37:00 +02:00

Deploying to gh-pages from @ ff06958b32 🚀

This commit is contained in:
robjtede
2022-07-21 01:52:33 +00:00
parent bd6959c23f
commit 3266418d24
172 changed files with 807 additions and 1177 deletions

View File

@@ -117,5 +117,5 @@
<span class="macro">assert!</span>(<span class="ident">AllOrSome::Some</span>(()).<span class="ident">is_some</span>());
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -1289,5 +1289,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -105,5 +105,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -771,5 +771,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -127,5 +127,5 @@
<span class="kw">use</span> <span class="ident">inner</span>::{<span class="ident">Inner</span>, <span class="ident">OriginFn</span>};
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">middleware::CorsMiddleware</span>;
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -535,5 +535,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -207,5 +207,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -535,5 +535,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -59,5 +59,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -205,5 +205,5 @@
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::identity_ext::IdentityExt</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::middleware::IdentityMiddleware</span>;
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -517,5 +517,5 @@
<span class="ident">LogOut</span>,
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -249,5 +249,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -91,5 +91,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -325,5 +325,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -239,5 +239,5 @@
(<span class="ident">result</span>, <span class="ident">fallback</span>)
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -243,5 +243,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_limitation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -667,5 +667,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_protobuf" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_protobuf" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -65,5 +65,5 @@
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::resp::RespValue</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::resp_array</span>;
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -287,5 +287,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -745,5 +745,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -1471,5 +1471,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -933,5 +933,5 @@
<span class="prelude-val">Ok</span>(())
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -643,5 +643,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -83,5 +83,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -249,5 +249,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -237,5 +237,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -59,5 +59,5 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;redis-rs-session&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_rs</span>::{<span class="ident">RedisSessionStore</span>, <span class="ident">RedisSessionStoreBuilder</span>};
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -637,5 +637,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -701,5 +701,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -123,5 +123,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -45,5 +45,5 @@
<span class="ident">String::from_utf8</span>(<span class="ident">value</span>).<span class="ident">unwrap</span>().<span class="ident">try_into</span>().<span class="ident">unwrap</span>()
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -116,71 +116,30 @@
<span id="110">110</span>
<span id="111">111</span>
<span id="112">112</span>
<span id="113">113</span>
<span id="114">114</span>
<span id="115">115</span>
<span id="116">116</span>
<span id="117">117</span>
<span id="118">118</span>
<span id="119">119</span>
<span id="120">120</span>
<span id="121">121</span>
<span id="122">122</span>
<span id="123">123</span>
<span id="124">124</span>
<span id="125">125</span>
<span id="126">126</span>
<span id="127">127</span>
<span id="128">128</span>
<span id="129">129</span>
<span id="130">130</span>
<span id="131">131</span>
<span id="132">132</span>
<span id="133">133</span>
<span id="134">134</span>
<span id="135">135</span>
<span id="136">136</span>
<span id="137">137</span>
<span id="138">138</span>
<span id="139">139</span>
<span id="140">140</span>
<span id="141">141</span>
<span id="142">142</span>
<span id="143">143</span>
<span id="144">144</span>
<span id="145">145</span>
<span id="146">146</span>
<span id="147">147</span>
<span id="148">148</span>
</pre><pre class="rust"><code><span class="doccomment">//! Extractor for the &quot;Basic&quot; HTTP Authentication Scheme</span>
</pre><pre class="rust"><code><span class="doccomment">//! Extractor for the &quot;Basic&quot; HTTP Authentication Scheme.</span>
<span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">actix_utils::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">actix_web::dev</span>::{<span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header::Header</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">dev::Payload</span>, <span class="ident">http::header::Header</span>, <span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::config::AuthExtractorConfig</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::errors::AuthenticationError</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::AuthExtractor</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization</span>::{<span class="ident">Authorization</span>, <span class="ident">Basic</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::www_authenticate::basic::Basic</span> <span class="kw">as</span> <span class="ident">Challenge</span>;
<span class="kw">use</span> <span class="kw">super</span>::{<span class="ident">config::AuthExtractorConfig</span>, <span class="ident">errors::AuthenticationError</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers</span>::{
<span class="ident">authorization</span>::{<span class="ident">Authorization</span>, <span class="ident">Basic</span>},
<span class="ident">www_authenticate::basic::Basic</span> <span class="kw">as</span> <span class="ident">Challenge</span>,
};
<span class="doccomment">/// [`BasicAuth`] extractor configuration,</span>
<span class="doccomment">/// used for [`WWW-Authenticate`] header later.</span>
<span class="doccomment">/// [`BasicAuth`] extractor configuration used for [`WWW-Authenticate`] header later.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [`BasicAuth`]: ./struct.BasicAuth.html</span>
<span class="doccomment">/// [`WWW-Authenticate`]:</span>
<span class="doccomment">/// ../../headers/www_authenticate/struct.WwwAuthenticate.html</span>
<span class="doccomment">/// [`WWW-Authenticate`]: crate::headers::www_authenticate::WwwAuthenticate</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>, <span class="ident">Default</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Config</span>(<span class="ident">Challenge</span>);
<span class="kw">impl</span> <span class="ident">Config</span> {
<span class="doccomment">/// Set challenge `realm` attribute.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// The &quot;realm&quot; attribute indicates the scope of protection in the manner</span>
<span class="doccomment">/// described in HTTP/1.1 [RFC2617](https://tools.ietf.org/html/rfc2617#section-1.2).</span>
<span class="doccomment">/// The &quot;realm&quot; attribute indicates the scope of protection in the manner described in HTTP/1.1</span>
<span class="doccomment">/// [RFC 2617 §1.2](https://tools.ietf.org/html/rfc2617#section-1.2).</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">realm</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) -&gt; <span class="ident">Config</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -204,14 +163,10 @@
}
}
<span class="comment">// Needs `fn main` to display complete example.</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::needless_doctest_main</span>)]</span>
<span class="doccomment">/// Extractor for HTTP Basic auth.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// use actix_web::Result;</span>
<span class="doccomment">/// use actix_web_httpauth::extractors::basic::BasicAuth;</span>
<span class="doccomment">///</span>
<span class="doccomment">/// async fn index(auth: BasicAuth) -&gt; String {</span>
@@ -219,41 +174,36 @@
<span class="doccomment">/// }</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">///</span>
<span class="doccomment">/// If authentication fails, this extractor fetches the [`Config`] instance</span>
<span class="doccomment">/// from the [app data] in order to properly form the `WWW-Authenticate`</span>
<span class="doccomment">/// response header.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">/// If authentication fails, this extractor fetches the [`Config`] instance from the [app data] in</span>
<span class="doccomment">/// order to properly form the `WWW-Authenticate` response header.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// use actix_web::{web, App};</span>
<span class="doccomment">/// use actix_web_httpauth::extractors::basic::{BasicAuth, Config};</span>
<span class="doccomment">/// use actix_web_httpauth::extractors::basic::{self, BasicAuth};</span>
<span class="doccomment">///</span>
<span class="doccomment">/// async fn index(auth: BasicAuth) -&gt; String {</span>
<span class="doccomment">/// format!(&quot;Hello, {}!&quot;, auth.user_id())</span>
<span class="doccomment">/// }</span>
<span class="doccomment">///</span>
<span class="doccomment">/// fn main() {</span>
<span class="doccomment">/// let app = App::new()</span>
<span class="doccomment">/// .app_data(Config::default().realm(&quot;Restricted area&quot;))</span>
<span class="doccomment">/// .service(web::resource(&quot;/index.html&quot;).route(web::get().to(index)));</span>
<span class="doccomment">/// }</span>
<span class="doccomment">/// App::new()</span>
<span class="doccomment">/// .app_data(basic::Config::default().realm(&quot;Restricted area&quot;))</span>
<span class="doccomment">/// .service(web::resource(&quot;/index.html&quot;).route(web::get().to(index)));</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [`Config`]: ./struct.Config.html</span>
<span class="doccomment">/// [app data]: https://docs.rs/actix-web/1.0.0-beta.5/actix_web/struct.App.html#method.data</span>
<span class="doccomment">/// [app data]: https://docs.rs/actix-web/4/actix_web/struct.App.html#method.app_data</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">BasicAuth</span>(<span class="ident">Basic</span>);
<span class="kw">impl</span> <span class="ident">BasicAuth</span> {
<span class="doccomment">/// Returns client&#39;s user-ID.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">user_id</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="ident">str</span> {
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">user_id</span>().<span class="ident">as_ref</span>()
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">user_id</span>()
}
<span class="doccomment">/// Returns client&#39;s password.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">password</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">password</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_ref</span>())
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">password</span>()
}
}
@@ -265,35 +215,13 @@
<span class="ident">ready</span>(
<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BasicAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="comment">// TODO: debug! the original error</span>
.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> {
<span class="macro">log::debug!</span>(<span class="string">&quot;`BasicAuth` extract error: {}&quot;</span>, <span class="ident">err</span>);
<span class="kw">let</span> <span class="ident">challenge</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
<span class="comment">// TODO: Add trace! about `Default::default` call</span>
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
<span class="ident">AuthenticationError::new</span>(<span class="ident">challenge</span>)
}),
)
}
}
<span class="kw">impl</span> <span class="ident">AuthExtractor</span> <span class="kw">for</span> <span class="ident">BasicAuth</span> {
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">Challenge</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) -&gt; <span class="ident"><span class="self">Self</span>::Future</span> {
<span class="ident">ready</span>(
<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BasicAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="comment">// TODO: debug! the original error</span>
<span class="kw">let</span> <span class="ident">challenge</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
<span class="comment">// TODO: Add trace! about `Default::default` call</span>
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
.<span class="ident">unwrap_or_default</span>();
<span class="ident">AuthenticationError::new</span>(<span class="ident">challenge</span>)
}),
@@ -301,5 +229,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -148,52 +148,18 @@
<span id="142">142</span>
<span id="143">143</span>
<span id="144">144</span>
<span id="145">145</span>
<span id="146">146</span>
<span id="147">147</span>
<span id="148">148</span>
<span id="149">149</span>
<span id="150">150</span>
<span id="151">151</span>
<span id="152">152</span>
<span id="153">153</span>
<span id="154">154</span>
<span id="155">155</span>
<span id="156">156</span>
<span id="157">157</span>
<span id="158">158</span>
<span id="159">159</span>
<span id="160">160</span>
<span id="161">161</span>
<span id="162">162</span>
<span id="163">163</span>
<span id="164">164</span>
<span id="165">165</span>
<span id="166">166</span>
<span id="167">167</span>
<span id="168">168</span>
<span id="169">169</span>
<span id="170">170</span>
<span id="171">171</span>
<span id="172">172</span>
<span id="173">173</span>
<span id="174">174</span>
</pre><pre class="rust"><code><span class="doccomment">//! Extractor for the &quot;Bearer&quot; HTTP Authentication Scheme</span>
</pre><pre class="rust"><code><span class="doccomment">//! Extractor for the &quot;Bearer&quot; HTTP Authentication Scheme.</span>
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">borrow::Cow</span>, <span class="ident">default::Default</span>};
<span class="kw">use</span> <span class="ident">actix_utils::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::{<span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>},
<span class="ident">http::header::Header</span>,
<span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>,
};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">dev::Payload</span>, <span class="ident">http::header::Header</span>, <span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>};
<span class="kw">use</span> <span class="kw">super</span>::{<span class="ident">config::AuthExtractorConfig</span>, <span class="ident">errors::AuthenticationError</span>, <span class="ident">AuthExtractor</span>};
<span class="kw">use</span> <span class="kw">super</span>::{<span class="ident">config::AuthExtractorConfig</span>, <span class="ident">errors::AuthenticationError</span>};
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::www_authenticate::bearer::Error</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers</span>::{<span class="ident">authorization</span>, <span class="ident">www_authenticate::bearer</span>};
<span class="doccomment">/// [BearerAuth](./struct/BearerAuth.html) extractor configuration.</span>
<span class="doccomment">/// [`BearerAuth`] extractor configuration.</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>, <span class="ident">Default</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Config</span>(<span class="ident">bearer::Bearer</span>);
@@ -211,7 +177,7 @@
<span class="doccomment">/// Set challenge `realm` attribute.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// The &quot;realm&quot; attribute indicates the scope of protection in the manner</span>
<span class="doccomment">/// described in HTTP/1.1 [RFC2617](https://tools.ietf.org/html/rfc2617#section-1.2).</span>
<span class="doccomment">/// described in HTTP/1.1 [RFC 2617](https://tools.ietf.org/html/rfc2617#section-1.2).</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">realm</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) -&gt; <span class="ident">Config</span> {
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">realm</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>.<span class="ident">into</span>());
<span class="self">self</span>
@@ -232,12 +198,9 @@
}
}
<span class="comment">// Needs `fn main` to display complete example.</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::needless_doctest_main</span>)]</span>
<span class="doccomment">/// Extractor for HTTP Bearer auth</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// use actix_web_httpauth::extractors::bearer::BearerAuth;</span>
<span class="doccomment">///</span>
@@ -250,25 +213,22 @@
<span class="doccomment">/// from the [app data] in order to properly form the `WWW-Authenticate`</span>
<span class="doccomment">/// response header.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// use actix_web::{web, App};</span>
<span class="doccomment">/// use actix_web_httpauth::extractors::bearer::{BearerAuth, Config};</span>
<span class="doccomment">/// use actix_web_httpauth::extractors::bearer::{self, BearerAuth};</span>
<span class="doccomment">///</span>
<span class="doccomment">/// async fn index(auth: BearerAuth) -&gt; String {</span>
<span class="doccomment">/// format!(&quot;Hello, {}!&quot;, auth.token())</span>
<span class="doccomment">/// }</span>
<span class="doccomment">///</span>
<span class="doccomment">/// fn main() {</span>
<span class="doccomment">/// let app = App::new()</span>
<span class="doccomment">/// .app_data(</span>
<span class="doccomment">/// Config::default()</span>
<span class="doccomment">/// .realm(&quot;Restricted area&quot;)</span>
<span class="doccomment">/// .scope(&quot;email photo&quot;),</span>
<span class="doccomment">/// )</span>
<span class="doccomment">/// .service(web::resource(&quot;/index.html&quot;).route(web::get().to(index)));</span>
<span class="doccomment">/// }</span>
<span class="doccomment">/// App::new()</span>
<span class="doccomment">/// .app_data(</span>
<span class="doccomment">/// bearer::Config::default()</span>
<span class="doccomment">/// .realm(&quot;Restricted area&quot;)</span>
<span class="doccomment">/// .scope(&quot;email photo&quot;),</span>
<span class="doccomment">/// )</span>
<span class="doccomment">/// .service(web::resource(&quot;/index.html&quot;).route(web::get().to(index)));</span>
<span class="doccomment">/// ```</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">BearerAuth</span>(<span class="ident">authorization::Bearer</span>);
@@ -300,26 +260,6 @@
}
}
<span class="kw">impl</span> <span class="ident">AuthExtractor</span> <span class="kw">for</span> <span class="ident">BearerAuth</span> {
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer::Bearer</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) -&gt; <span class="ident"><span class="self">Self</span>::Future</span> {
<span class="ident">ready</span>(
<span class="ident">authorization::Authorization</span>::<span class="op">&lt;</span><span class="ident">authorization::Bearer</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BearerAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">bearer</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
<span class="ident">AuthenticationError::new</span>(<span class="ident">bearer</span>)
}),
)
}
}
<span class="doccomment">/// Extended error customization for HTTP `Bearer` auth.</span>
<span class="kw">impl</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer::Bearer</span><span class="op">&gt;</span> {
<span class="doccomment">/// Attach `Error` to the current Authentication error.</span>
@@ -353,5 +293,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -25,15 +25,11 @@
<span id="19">19</span>
<span id="20">20</span>
<span id="21">21</span>
<span id="22">22</span>
<span id="23">23</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident"><span class="kw">super</span>::AuthenticationError</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::www_authenticate::Challenge</span>;
<span class="doccomment">/// Trait implemented for types that provides configuration</span>
<span class="doccomment">/// for the authentication [extractors].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [extractors]: ./trait.AuthExtractor.html</span>
<span class="doccomment">/// Trait implemented for types that provides configuration for the authentication</span>
<span class="doccomment">/// [extractors](super::AuthExtractor).</span>
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">AuthExtractorConfig</span> {
<span class="doccomment">/// Associated challenge type.</span>
<span class="kw">type</span> <span class="ident">Inner</span>: <span class="ident">Challenge</span>;
@@ -51,5 +47,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -83,23 +83,16 @@
<span id="77">77</span>
<span id="78">78</span>
<span id="79">79</span>
<span id="80">80</span>
<span id="81">81</span>
<span id="82">82</span>
<span id="83">83</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::error::Error</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">error::Error</span>, <span class="ident">fmt</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::StatusCode</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">HttpResponse</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">http::StatusCode</span>, <span class="ident">HttpResponse</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::www_authenticate::Challenge</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::www_authenticate::WwwAuthenticate</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::www_authenticate</span>::{<span class="ident">Challenge</span>, <span class="ident">WwwAuthenticate</span>};
<span class="doccomment">/// Authentication error returned by authentication extractors.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Different extractors may extend `AuthenticationError` implementation</span>
<span class="doccomment">/// in order to provide access to inner challenge fields.</span>
<span class="doccomment">/// Different extractors may extend `AuthenticationError` implementation in order to provide access</span>
<span class="doccomment">/// inner challenge fields.</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span><span class="op">&gt;</span> {
<span class="ident">challenge</span>: <span class="ident">C</span>,
@@ -124,8 +117,8 @@
<span class="doccomment">/// Returns mutable reference to the inner status code.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Can be used to override returned status code, but by default</span>
<span class="doccomment">/// this lib tries to stick to the RFC, so it might be unreasonable.</span>
<span class="doccomment">/// Can be used to override returned status code, but by default this lib tries to stick to the</span>
<span class="doccomment">/// RFC, so it might be unreasonable.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">status_code_mut</span>(<span class="kw-2">&amp;mut</span> <span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut</span> <span class="ident">StatusCode</span> {
<span class="kw-2">&amp;mut</span> <span class="self">self</span>.<span class="ident">status_code</span>
}
@@ -137,19 +130,18 @@
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">Challenge</span><span class="op">&gt;</span> <span class="ident">Error</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">Challenge</span><span class="op">&gt;</span> <span class="ident">ResponseError</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">error_response</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">HttpResponse</span> {
<span class="ident">HttpResponse::build</span>(<span class="self">self</span>.<span class="ident">status_code</span>)
<span class="comment">// TODO: Get rid of the `.clone()`</span>
.<span class="ident">insert_header</span>(<span class="ident">WwwAuthenticate</span>(<span class="self">self</span>.<span class="ident">challenge</span>.<span class="ident">clone</span>()))
.<span class="ident">finish</span>()
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span> <span class="op">+</span> <span class="lifetime">&#39;static</span><span class="op">&gt;</span> <span class="ident">Error</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span> <span class="op">+</span> <span class="lifetime">&#39;static</span><span class="op">&gt;</span> <span class="ident">ResponseError</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">status_code</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">StatusCode</span> {
<span class="self">self</span>.<span class="ident">status_code</span>
}
<span class="kw">fn</span> <span class="ident">error_response</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">HttpResponse</span> {
<span class="ident">HttpResponse::build</span>(<span class="self">self</span>.<span class="ident">status_code</span>())
.<span class="ident">insert_header</span>(<span class="ident">WwwAuthenticate</span>(<span class="self">self</span>.<span class="ident">challenge</span>.<span class="ident">clone</span>()))
.<span class="ident">finish</span>()
}
}
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
@@ -161,15 +153,15 @@
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">test_status_code_is_preserved_across_error_conversions</span>() {
<span class="kw">let</span> <span class="ident">ae</span>: <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">AuthenticationError::new</span>(<span class="ident">Basic::default</span>());
<span class="kw">let</span> <span class="ident">ae</span> <span class="op">=</span> <span class="ident">AuthenticationError::new</span>(<span class="ident">Basic::default</span>());
<span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> <span class="ident">ae</span>.<span class="ident">status_code</span>;
<span class="comment">// Converting the AuthenticationError into a ResponseError should preserve the status code.</span>
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">Error::from</span>(<span class="ident">ae</span>);
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">e</span>.<span class="ident">as_response_error</span>();
<span class="macro">assert_eq!</span>(<span class="ident">expected</span>, <span class="ident">re</span>.<span class="ident">status_code</span>());
<span class="kw">let</span> <span class="ident">err</span> <span class="op">=</span> <span class="ident">Error::from</span>(<span class="ident">ae</span>);
<span class="kw">let</span> <span class="ident">res_err</span> <span class="op">=</span> <span class="ident">err</span>.<span class="ident">as_response_error</span>();
<span class="macro">assert_eq!</span>(<span class="ident">expected</span>, <span class="ident">res_err</span>.<span class="ident">status_code</span>());
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -13,112 +13,7 @@
<span id="7">7</span>
<span id="8">8</span>
<span id="9">9</span>
<span id="10">10</span>
<span id="11">11</span>
<span id="12">12</span>
<span id="13">13</span>
<span id="14">14</span>
<span id="15">15</span>
<span id="16">16</span>
<span id="17">17</span>
<span id="18">18</span>
<span id="19">19</span>
<span id="20">20</span>
<span id="21">21</span>
<span id="22">22</span>
<span id="23">23</span>
<span id="24">24</span>
<span id="25">25</span>
<span id="26">26</span>
<span id="27">27</span>
<span id="28">28</span>
<span id="29">29</span>
<span id="30">30</span>
<span id="31">31</span>
<span id="32">32</span>
<span id="33">33</span>
<span id="34">34</span>
<span id="35">35</span>
<span id="36">36</span>
<span id="37">37</span>
<span id="38">38</span>
<span id="39">39</span>
<span id="40">40</span>
<span id="41">41</span>
<span id="42">42</span>
<span id="43">43</span>
<span id="44">44</span>
<span id="45">45</span>
<span id="46">46</span>
<span id="47">47</span>
<span id="48">48</span>
<span id="49">49</span>
<span id="50">50</span>
<span id="51">51</span>
<span id="52">52</span>
<span id="53">53</span>
<span id="54">54</span>
<span id="55">55</span>
<span id="56">56</span>
<span id="57">57</span>
<span id="58">58</span>
<span id="59">59</span>
<span id="60">60</span>
<span id="61">61</span>
<span id="62">62</span>
<span id="63">63</span>
<span id="64">64</span>
<span id="65">65</span>
<span id="66">66</span>
<span id="67">67</span>
<span id="68">68</span>
<span id="69">69</span>
<span id="70">70</span>
<span id="71">71</span>
<span id="72">72</span>
<span id="73">73</span>
<span id="74">74</span>
<span id="75">75</span>
<span id="76">76</span>
<span id="77">77</span>
<span id="78">78</span>
<span id="79">79</span>
<span id="80">80</span>
<span id="81">81</span>
<span id="82">82</span>
<span id="83">83</span>
<span id="84">84</span>
<span id="85">85</span>
<span id="86">86</span>
<span id="87">87</span>
<span id="88">88</span>
<span id="89">89</span>
<span id="90">90</span>
<span id="91">91</span>
<span id="92">92</span>
<span id="93">93</span>
<span id="94">94</span>
<span id="95">95</span>
<span id="96">96</span>
<span id="97">97</span>
<span id="98">98</span>
<span id="99">99</span>
<span id="100">100</span>
<span id="101">101</span>
<span id="102">102</span>
<span id="103">103</span>
</pre><pre class="rust"><code><span class="doccomment">//! Type-safe authentication information extractors</span>
<span class="kw">use</span> <span class="ident">std</span>::{
<span class="ident">future::Future</span>,
<span class="ident">pin::Pin</span>,
<span class="ident">task</span>::{<span class="ident">Context</span>, <span class="ident">Poll</span>},
};
<span class="kw">use</span> <span class="ident">actix_web::dev::ServiceRequest</span>;
<span class="kw">use</span> <span class="ident">actix_web::Error</span>;
<span class="kw">use</span> <span class="ident">futures_core::ready</span>;
<span class="kw">use</span> <span class="ident">pin_project_lite::pin_project</span>;
</pre><pre class="rust"><code><span class="doccomment">//! Type-safe authentication information extractors.</span>
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">basic</span>;
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">bearer</span>;
@@ -127,89 +22,6 @@
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::config::AuthExtractorConfig</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::errors::AuthenticationError</span>;
<span class="doccomment">/// Trait implemented by types that can extract</span>
<span class="doccomment">/// HTTP authentication scheme credentials from the request.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// It is very similar to actix&#39; `FromRequest` trait,</span>
<span class="doccomment">/// except it operates with a `ServiceRequest` struct instead,</span>
<span class="doccomment">/// therefore it can be used in the middlewares.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// You will not need it unless you want to implement your own</span>
<span class="doccomment">/// authentication scheme.</span>
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">AuthExtractor</span>: <span class="ident">Sized</span> {
<span class="doccomment">/// The associated error which can be returned.</span>
<span class="kw">type</span> <span class="ident">Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Error</span><span class="op">&gt;</span>;
<span class="doccomment">/// Future that resolves into extracted credentials type.</span>
<span class="kw">type</span> <span class="ident">Future</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="doccomment">/// Parse the authentication credentials from the actix&#39; `ServiceRequest`.</span>
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) -&gt; <span class="ident"><span class="self">Self</span>::Future</span>;
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">AuthExtractor</span><span class="op">&gt;</span> <span class="ident">AuthExtractor</span> <span class="kw">for</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">T::Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">AuthExtractorOptFut</span><span class="op">&lt;</span><span class="ident">T::Future</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) -&gt; <span class="ident"><span class="self">Self</span>::Future</span> {
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="ident">T::from_service_request</span>(<span class="ident">req</span>);
<span class="ident">AuthExtractorOptFut</span> { <span class="ident">fut</span> }
}
}
<span class="macro">pin_project!</span> {
<span class="attribute">#[<span class="ident">doc</span>(<span class="ident">hidden</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">AuthExtractorOptFut</span><span class="op">&lt;</span><span class="ident">F</span><span class="op">&gt;</span> {
<span class="attribute">#[<span class="ident">pin</span>]</span>
<span class="ident">fut</span>: <span class="ident">F</span>
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">F</span>, <span class="ident">T</span>, <span class="ident">E</span><span class="op">&gt;</span> <span class="ident">Future</span> <span class="kw">for</span> <span class="ident">AuthExtractorOptFut</span><span class="op">&lt;</span><span class="ident">F</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">F</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">E</span><span class="op">&gt;</span><span class="op">&gt;</span>,
{
<span class="kw">type</span> <span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>, <span class="ident">E</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">poll</span>(<span class="self">self</span>: <span class="ident">Pin</span><span class="op">&lt;</span><span class="kw-2">&amp;mut</span> <span class="self">Self</span><span class="op">&gt;</span>, <span class="ident">cx</span>: <span class="kw-2">&amp;mut</span> <span class="ident">Context</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="ident">Poll</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Output</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="macro">ready!</span>(<span class="self">self</span>.<span class="ident">project</span>().<span class="ident">fut</span>.<span class="ident">poll</span>(<span class="ident">cx</span>));
<span class="ident">Poll::Ready</span>(<span class="prelude-val">Ok</span>(<span class="ident">res</span>.<span class="ident">ok</span>()))
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">AuthExtractor</span><span class="op">&gt;</span> <span class="ident">AuthExtractor</span> <span class="kw">for</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">T::Error</span><span class="op">&gt;</span> {
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">T::Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">AuthExtractorResFut</span><span class="op">&lt;</span><span class="ident">T::Future</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) -&gt; <span class="ident"><span class="self">Self</span>::Future</span> {
<span class="ident">AuthExtractorResFut</span> {
<span class="ident">fut</span>: <span class="ident">T::from_service_request</span>(<span class="ident">req</span>),
}
}
}
<span class="macro">pin_project!</span> {
<span class="attribute">#[<span class="ident">doc</span>(<span class="ident">hidden</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">AuthExtractorResFut</span><span class="op">&lt;</span><span class="ident">F</span><span class="op">&gt;</span> {
<span class="attribute">#[<span class="ident">pin</span>]</span>
<span class="ident">fut</span>: <span class="ident">F</span>
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">F</span>, <span class="ident">T</span>, <span class="ident">E</span><span class="op">&gt;</span> <span class="ident">Future</span> <span class="kw">for</span> <span class="ident">AuthExtractorResFut</span><span class="op">&lt;</span><span class="ident">F</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">F</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">E</span><span class="op">&gt;</span><span class="op">&gt;</span>,
{
<span class="kw">type</span> <span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">F::Output</span>, <span class="ident">E</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">poll</span>(<span class="self">self</span>: <span class="ident">Pin</span><span class="op">&lt;</span><span class="kw-2">&amp;mut</span> <span class="self">Self</span><span class="op">&gt;</span>, <span class="ident">cx</span>: <span class="kw-2">&amp;mut</span> <span class="ident">Context</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="ident">Poll</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Output</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="macro">ready!</span>(<span class="self">self</span>.<span class="ident">project</span>().<span class="ident">fut</span>.<span class="ident">poll</span>(<span class="ident">cx</span>));
<span class="ident">Poll::Ready</span>(<span class="prelude-val">Ok</span>(<span class="ident">res</span>))
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -73,44 +73,48 @@
<span id="67">67</span>
<span id="68">68</span>
<span id="69">69</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::convert::From</span>;
<span class="kw">use</span> <span class="ident">std::error::Error</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">std::str</span>;
<span id="70">70</span>
<span id="71">71</span>
<span id="72">72</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">convert::From</span>, <span class="ident">error::Error</span>, <span class="ident">fmt</span>, <span class="ident">str</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>;
<span class="doccomment">/// Possible errors while parsing `Authorization` header.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Should not be used directly unless you are implementing</span>
<span class="doccomment">/// your own [authentication scheme](./trait.Scheme.html).</span>
<span class="doccomment">/// Should not be used directly unless you are implementing your own</span>
<span class="doccomment">/// [authentication scheme](super::Scheme).</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">ParseError</span> {
<span class="doccomment">/// Header value is malformed</span>
<span class="doccomment">/// Header value is malformed.</span>
<span class="ident">Invalid</span>,
<span class="doccomment">/// Authentication scheme is missing</span>
<span class="doccomment">/// Authentication scheme is missing.</span>
<span class="ident">MissingScheme</span>,
<span class="doccomment">/// Required authentication field is missing</span>
<span class="doccomment">/// Required authentication field is missing.</span>
<span class="ident">MissingField</span>(<span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>),
<span class="doccomment">/// Unable to convert header into the str</span>
<span class="doccomment">/// Unable to convert header into the str.</span>
<span class="ident">ToStrError</span>(<span class="ident">header::ToStrError</span>),
<span class="doccomment">/// Malformed base64 string</span>
<span class="doccomment">/// Malformed base64 string.</span>
<span class="ident">Base64DecodeError</span>(<span class="ident">base64::DecodeError</span>),
<span class="doccomment">/// Malformed UTF-8 string</span>
<span class="doccomment">/// Malformed UTF-8 string.</span>
<span class="ident">Utf8Error</span>(<span class="ident">str::Utf8Error</span>),
}
<span class="kw">impl</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="ident">fmt::Result</span> {
<span class="kw">let</span> <span class="ident">display</span> <span class="op">=</span> <span class="kw">match</span> <span class="self">self</span> {
<span class="ident">ParseError::Invalid</span> =&gt; <span class="string">&quot;Invalid header value&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::MissingScheme</span> =&gt; <span class="string">&quot;Missing authorization scheme&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::MissingField</span>(<span class="kw">_</span>) =&gt; <span class="string">&quot;Missing header field&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::ToStrError</span>(<span class="ident">e</span>) =&gt; <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">e</span>) =&gt; <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">e</span>) =&gt; <span class="ident">e</span>.<span class="ident">to_string</span>(),
};
<span class="ident">f</span>.<span class="ident">write_str</span>(<span class="kw-2">&amp;</span><span class="ident">display</span>)
<span class="kw">match</span> <span class="self">self</span> {
<span class="ident">ParseError::Invalid</span> =&gt; <span class="ident">f</span>.<span class="ident">write_str</span>(<span class="string">&quot;Invalid header value&quot;</span>),
<span class="ident">ParseError::MissingScheme</span> =&gt; <span class="ident">f</span>.<span class="ident">write_str</span>(<span class="string">&quot;Missing authorization scheme&quot;</span>),
<span class="ident">ParseError::MissingField</span>(<span class="ident">field</span>) =&gt; <span class="macro">write!</span>(<span class="ident">f</span>, <span class="string">&quot;Missing header field ({})&quot;</span>, <span class="ident">field</span>),
<span class="ident">ParseError::ToStrError</span>(<span class="ident">err</span>) =&gt; <span class="ident">fmt::Display::fmt</span>(<span class="ident">err</span>, <span class="ident">f</span>),
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">err</span>) =&gt; <span class="ident">fmt::Display::fmt</span>(<span class="ident">err</span>, <span class="ident">f</span>),
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">err</span>) =&gt; <span class="ident">fmt::Display::fmt</span>(<span class="ident">err</span>, <span class="ident">f</span>),
}
}
}
@@ -120,28 +124,30 @@
<span class="ident">ParseError::Invalid</span> =&gt; <span class="prelude-val">None</span>,
<span class="ident">ParseError::MissingScheme</span> =&gt; <span class="prelude-val">None</span>,
<span class="ident">ParseError::MissingField</span>(<span class="kw">_</span>) =&gt; <span class="prelude-val">None</span>,
<span class="ident">ParseError::ToStrError</span>(<span class="ident">e</span>) =&gt; <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">e</span>) =&gt; <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">e</span>) =&gt; <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError::ToStrError</span>(<span class="ident">err</span>) =&gt; <span class="prelude-val">Some</span>(<span class="ident">err</span>),
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">err</span>) =&gt; <span class="prelude-val">Some</span>(<span class="ident">err</span>),
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">err</span>) =&gt; <span class="prelude-val">Some</span>(<span class="ident">err</span>),
}
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">header::ToStrError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">header::ToStrError</span>) -&gt; <span class="self">Self</span> {
<span class="ident">ParseError::ToStrError</span>(<span class="ident">e</span>)
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">err</span>: <span class="ident">header::ToStrError</span>) -&gt; <span class="self">Self</span> {
<span class="ident">ParseError::ToStrError</span>(<span class="ident">err</span>)
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">base64::DecodeError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">base64::DecodeError</span>) -&gt; <span class="self">Self</span> {
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">e</span>)
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">err</span>: <span class="ident">base64::DecodeError</span>) -&gt; <span class="self">Self</span> {
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">err</span>)
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">str::Utf8Error</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">str::Utf8Error</span>) -&gt; <span class="self">Self</span> {
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">e</span>)
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">err</span>: <span class="ident">str::Utf8Error</span>) -&gt; <span class="self">Self</span> {
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">err</span>)
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -88,47 +88,28 @@
<span id="82">82</span>
<span id="83">83</span>
<span id="84">84</span>
<span id="85">85</span>
<span id="86">86</span>
<span id="87">87</span>
<span id="88">88</span>
<span id="89">89</span>
<span id="90">90</span>
<span id="91">91</span>
<span id="92">92</span>
<span id="93">93</span>
<span id="94">94</span>
<span id="95">95</span>
<span id="96">96</span>
<span id="97">97</span>
<span id="98">98</span>
<span id="99">99</span>
<span id="100">100</span>
<span id="101">101</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">actix_web::error::ParseError</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="ident">Header</span>, <span class="ident">HeaderName</span>, <span class="ident">HeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>, <span class="ident">AUTHORIZATION</span>};
<span class="kw">use</span> <span class="ident">actix_web::HttpMessage</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">error::ParseError</span>,
<span class="ident">http::header</span>::{<span class="ident">Header</span>, <span class="ident">HeaderName</span>, <span class="ident">HeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>, <span class="ident">AUTHORIZATION</span>},
<span class="ident">HttpMessage</span>,
};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization::scheme::Scheme</span>;
<span class="doccomment">/// `Authorization` header, defined in [RFC 7235](https://tools.ietf.org/html/rfc7235#section-4.2)</span>
<span class="doccomment">///</span>
<span class="doccomment">/// The &quot;Authorization&quot; header field allows a user agent to authenticate</span>
<span class="doccomment">/// itself with an origin server -- usually, but not necessarily, after</span>
<span class="doccomment">/// receiving a 401 (Unauthorized) response. Its value consists of</span>
<span class="doccomment">/// credentials containing the authentication information of the user</span>
<span class="doccomment">/// agent for the realm of the resource being requested.</span>
<span class="doccomment">/// The &quot;Authorization&quot; header field allows a user agent to authenticate itself with an origin</span>
<span class="doccomment">/// serverusually, but not necessarily, after receiving a 401 (Unauthorized) response. Its value</span>
<span class="doccomment">/// consists of credentials containing the authentication information of the user agent for the</span>
<span class="doccomment">/// realm of the resource being requested.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// `Authorization` header is generic over [authentication</span>
<span class="doccomment">/// scheme](./trait.Scheme.html).</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
<span class="doccomment">/// `Authorization` is generic over an [authentication scheme](Scheme).</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web::http::header::Header;</span>
<span class="doccomment">/// # use actix_web::{HttpRequest, Result};</span>
<span class="doccomment">/// # use actix_web::{HttpRequest, Result, http::header::Header};</span>
<span class="doccomment">/// # use actix_web_httpauth::headers::authorization::{Authorization, Basic};</span>
<span class="doccomment">/// fn handler(req: HttpRequest) -&gt; Result&lt;String&gt; {</span>
<span class="doccomment">/// let auth = Authorization::&lt;Basic&gt;::parse(&amp;req)?;</span>
@@ -136,49 +117,40 @@
<span class="doccomment">/// Ok(format!(&quot;Hello, {}!&quot;, auth.as_ref().user_id()))</span>
<span class="doccomment">/// }</span>
<span class="doccomment">/// ```</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Eq</span>, <span class="ident">PartialEq</span>, <span class="ident">Ord</span>, <span class="ident">PartialOrd</span>, <span class="ident">Hash</span>, <span class="ident">Debug</span>, <span class="ident">Default</span>, <span class="ident">Clone</span>)]</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Default</span>, <span class="ident">Clone</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>, <span class="ident">PartialOrd</span>, <span class="ident">Ord</span>, <span class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span>(<span class="ident">S</span>);
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Scheme</span>,
{
<span class="doccomment">/// Consumes `Authorization` header and returns inner [`Scheme`]</span>
<span class="doccomment">/// implementation.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [`Scheme`]: ./trait.Scheme.html</span>
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="doccomment">/// Consumes `Authorization` header and returns inner [`Scheme`] implementation.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">into_scheme</span>(<span class="self">self</span>) -&gt; <span class="ident">S</span> {
<span class="self">self</span>.<span class="number">0</span>
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Scheme</span>,
{
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">scheme</span>: <span class="ident">S</span>) -&gt; <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="ident">Authorization</span>(<span class="ident">scheme</span>)
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="ident">AsRef</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Scheme</span>,
{
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">AsRef</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">as_ref</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="ident">S</span> {
<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="ident">AsMut</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Scheme</span>,
{
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">AsMut</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">as_mut</span>(<span class="kw-2">&amp;mut</span> <span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut</span> <span class="ident">S</span> {
<span class="kw-2">&amp;mut</span> <span class="self">self</span>.<span class="number">0</span>
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="ident">fmt::Result</span> {
<span class="ident">fmt::Display::fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>, <span class="ident">f</span>)
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">Header</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="attribute">#[<span class="ident">inline</span>]</span>
<span class="kw">fn</span> <span class="ident">name</span>() -&gt; <span class="ident">HeaderName</span> {
@@ -186,7 +158,7 @@
}
<span class="kw">fn</span> <span class="ident">parse</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">HttpMessage</span><span class="op">&gt;</span>(<span class="ident">msg</span>: <span class="kw-2">&amp;</span><span class="ident">T</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident">ParseError</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">header</span> <span class="op">=</span> <span class="ident">msg</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">AUTHORIZATION</span>).<span class="ident">ok_or</span>(<span class="ident">ParseError::Header</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">header</span> <span class="op">=</span> <span class="ident">msg</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident"><span class="self">Self</span>::name</span>()).<span class="ident">ok_or</span>(<span class="ident">ParseError::Header</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">scheme</span> <span class="op">=</span> <span class="ident">S::parse</span>(<span class="ident">header</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="ident">ParseError::Header</span>)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(<span class="ident">Authorization</span>(<span class="ident">scheme</span>))
@@ -200,12 +172,6 @@
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">try_into_value</span>()
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Scheme</span><span class="op">&gt;</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">Authorization</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="ident">fmt::Result</span> {
<span class="ident">fmt::Display::fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>, <span class="ident">f</span>)
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -13,9 +13,7 @@
<span id="7">7</span>
<span id="8">8</span>
<span id="9">9</span>
<span id="10">10</span>
<span id="11">11</span>
</pre><pre class="rust"><code><span class="doccomment">//! `Authorization` header and various auth schemes</span>
</pre><pre class="rust"><code><span class="doccomment">//! `Authorization` header and various auth schemes.</span>
<span class="kw">mod</span> <span class="ident">errors</span>;
<span class="kw">mod</span> <span class="ident">header</span>;
@@ -23,9 +21,7 @@
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::errors::ParseError</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::header::Authorization</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::scheme::basic::Basic</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::scheme::bearer::Bearer</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::scheme::Scheme</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::scheme</span>::{<span class="ident">basic::Basic</span>, <span class="ident">bearer::Bearer</span>, <span class="ident">Scheme</span>};
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -209,7 +209,7 @@
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization</span>::{<span class="ident">errors::ParseError</span>, <span class="ident">Scheme</span>};
<span class="doccomment">/// Credentials for `Basic` authentication scheme, defined in [RFC 7617](https://tools.ietf.org/html/rfc7617)</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Clone</span>, <span class="ident">Eq</span>, <span class="ident">Ord</span>, <span class="ident">PartialEq</span>, <span class="ident">PartialOrd</span>)]</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Clone</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>, <span class="ident">PartialOrd</span>, <span class="ident">Ord</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Basic</span> {
<span class="ident">user_id</span>: <span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span>,
<span class="ident">password</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -219,8 +219,7 @@
<span class="doccomment">/// Creates `Basic` credentials with provided `user_id` and optional</span>
<span class="doccomment">/// `password`.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web_httpauth::headers::authorization::Basic;</span>
<span class="doccomment">/// let credentials = Basic::new(&quot;Alladin&quot;, Some(&quot;open sesame&quot;));</span>
@@ -237,13 +236,13 @@
}
<span class="doccomment">/// Returns client&#39;s user-ID.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">user_id</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span> {
<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">user_id</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">user_id</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="ident">str</span> {
<span class="self">self</span>.<span class="ident">user_id</span>.<span class="ident">as_ref</span>()
}
<span class="doccomment">/// Returns client&#39;s password if provided.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">password</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">password</span>.<span class="ident">as_ref</span>()
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">password</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">password</span>.<span class="ident">as_deref</span>()
}
}
@@ -267,6 +266,7 @@
.<span class="ident">next</span>()
.<span class="ident">ok_or</span>(<span class="ident">ParseError::MissingField</span>(<span class="string">&quot;user_id&quot;</span>))
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">user_id</span><span class="op">|</span> <span class="ident">user_id</span>.<span class="ident">to_string</span>().<span class="ident">into</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">password</span> <span class="op">=</span> <span class="ident">credentials</span>
.<span class="ident">next</span>()
.<span class="ident">ok_or</span>(<span class="ident">ParseError::MissingField</span>(<span class="string">&quot;password&quot;</span>))
@@ -395,5 +395,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -141,19 +141,21 @@
<span id="135">135</span>
<span id="136">136</span>
<span id="137">137</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span id="138">138</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">borrow::Cow</span>, <span class="ident">fmt</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">InvalidHeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web::web</span>::{<span class="ident">BufMut</span>, <span class="ident">BytesMut</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">InvalidHeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>},
<span class="ident">web</span>::{<span class="ident">BufMut</span>, <span class="ident">BytesMut</span>},
};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization::errors::ParseError</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization::scheme::Scheme</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization</span>::{<span class="ident">errors::ParseError</span>, <span class="ident">scheme::Scheme</span>};
<span class="doccomment">/// Credentials for `Bearer` authentication scheme, defined in [RFC6750](https://tools.ietf.org/html/rfc6750)</span>
<span class="doccomment">/// Credentials for `Bearer` authentication scheme, defined in [RFC 6750].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Should be used in combination with</span>
<span class="doccomment">/// [`Authorization`](./struct.Authorization.html) header.</span>
<span class="doccomment">/// Should be used in combination with [`Authorization`](super::Authorization) header.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 6750]: https://tools.ietf.org/html/rfc6750</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Clone</span>, <span class="ident">Eq</span>, <span class="ident">Ord</span>, <span class="ident">PartialEq</span>, <span class="ident">PartialOrd</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Bearer</span> {
<span class="ident">token</span>: <span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span>,
@@ -162,8 +164,7 @@
<span class="kw">impl</span> <span class="ident">Bearer</span> {
<span class="doccomment">/// Creates new `Bearer` credentials with the token provided.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web_httpauth::headers::authorization::Bearer;</span>
<span class="doccomment">/// let credentials = Bearer::new(&quot;mF_9.B5f-4.1JqM&quot;);</span>
@@ -178,8 +179,8 @@
}
<span class="doccomment">/// Gets reference to the credentials token.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">token</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span> {
<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">token</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">token</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="ident">str</span> {
<span class="self">self</span>.<span class="ident">token</span>.<span class="ident">as_ref</span>()
}
}
@@ -191,8 +192,9 @@
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">parts</span> <span class="op">=</span> <span class="ident">header</span>.<span class="ident">to_str</span>()<span class="question-mark">?</span>.<span class="ident">splitn</span>(<span class="number">2</span>, <span class="string">&#39; &#39;</span>);
<span class="kw">match</span> <span class="ident">parts</span>.<span class="ident">next</span>() {
<span class="prelude-val">Some</span>(<span class="ident">scheme</span>) <span class="kw">if</span> <span class="ident">scheme</span> <span class="op">==</span> <span class="string">&quot;Bearer&quot;</span> =&gt; (),
<span class="prelude-val">Some</span>(<span class="ident">scheme</span>) <span class="kw">if</span> <span class="ident">scheme</span> <span class="op">==</span> <span class="string">&quot;Bearer&quot;</span> =&gt; {}
<span class="kw">_</span> =&gt; <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">ParseError::MissingScheme</span>),
}
@@ -279,5 +281,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -18,7 +18,6 @@
<span id="12">12</span>
<span id="13">13</span>
<span id="14">14</span>
<span id="15">15</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>::{<span class="ident">Debug</span>, <span class="ident">Display</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>};
@@ -28,12 +27,11 @@
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::headers::authorization::errors::ParseError</span>;
<span class="doccomment">/// Authentication scheme for [`Authorization`](./struct.Authorization.html)</span>
<span class="doccomment">/// header.</span>
<span class="doccomment">/// Authentication scheme for [`Authorization`](super::Authorization) header.</span>
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">Scheme</span>: <span class="ident">TryIntoHeaderValue</span> <span class="op">+</span> <span class="ident">Debug</span> <span class="op">+</span> <span class="ident">Display</span> <span class="op">+</span> <span class="ident">Clone</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Sync</span> {
<span class="doccomment">/// Try to parse the authentication scheme from the `Authorization` header.</span>
<span class="doccomment">/// Try to parse an authentication scheme from the `Authorization` header.</span>
<span class="kw">fn</span> <span class="ident">parse</span>(<span class="ident">header</span>: <span class="kw-2">&amp;</span><span class="ident">HeaderValue</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident">ParseError</span><span class="op">&gt;</span>;
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -8,10 +8,10 @@
<span id="2">2</span>
<span id="3">3</span>
<span id="4">4</span>
</pre><pre class="rust"><code><span class="doccomment">//! Typed HTTP headers</span>
</pre><pre class="rust"><code><span class="doccomment">//! Typed HTTP headers.</span>
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">authorization</span>;
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">www_authenticate</span>;
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -140,18 +140,14 @@
<span id="134">134</span>
<span id="135">135</span>
<span id="136">136</span>
<span id="137">137</span>
<span id="138">138</span>
<span id="139">139</span>
</pre><pre class="rust"><code><span class="doccomment">//! Challenge for the &quot;Basic&quot; HTTP Authentication Scheme</span>
</pre><pre class="rust"><code><span class="doccomment">//! Challenge for the &quot;Basic&quot; HTTP Authentication Scheme.</span>
<span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">std::default::Default</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">std::str</span>;
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">borrow::Cow</span>, <span class="ident">fmt</span>, <span class="ident">str</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">InvalidHeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web::web</span>::{<span class="ident">BufMut</span>, <span class="ident">Bytes</span>, <span class="ident">BytesMut</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">InvalidHeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>},
<span class="ident">web</span>::{<span class="ident">BufMut</span>, <span class="ident">Bytes</span>, <span class="ident">BytesMut</span>},
};
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::Challenge</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::utils</span>;
@@ -159,8 +155,7 @@
<span class="doccomment">/// Challenge for [`WWW-Authenticate`] header with HTTP Basic auth scheme,</span>
<span class="doccomment">/// described in [RFC 7617](https://tools.ietf.org/html/rfc7617)</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};</span>
<span class="doccomment">/// use actix_web_httpauth::headers::www_authenticate::basic::Basic;</span>
@@ -185,8 +180,7 @@
<span class="kw">impl</span> <span class="ident">Basic</span> {
<span class="doccomment">/// Creates new `Basic` challenge with an empty `realm` field.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web_httpauth::headers::www_authenticate::basic::Basic;</span>
<span class="doccomment">/// let challenge = Basic::new();</span>
@@ -197,7 +191,7 @@
<span class="doccomment">/// Creates new `Basic` challenge from the provided `realm` field value.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Examples</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web_httpauth::headers::www_authenticate::basic::Basic;</span>
@@ -283,5 +277,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -67,21 +67,29 @@
<span id="61">61</span>
<span id="62">62</span>
<span id="63">63</span>
<span id="64">64</span>
<span id="65">65</span>
<span id="66">66</span>
<span id="67">67</span>
<span id="68">68</span>
<span id="69">69</span>
<span id="70">70</span>
<span id="71">71</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="kw">super</span>::{<span class="ident">Bearer</span>, <span class="ident">Error</span>};
<span class="doccomment">/// Builder for the [`Bearer`] challenge.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// It is up to implementor to fill all required fields,</span>
<span class="doccomment">/// neither this `Builder` or [`Bearer`] does not provide any validation.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [`Bearer`]: struct.Bearer.html</span>
<span class="doccomment">/// It is up to implementor to fill all required fields, neither this `Builder` nor [`Bearer`]</span>
<span class="doccomment">/// provide any validation.</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Default</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">BearerBuilder</span>(<span class="ident">Bearer</span>);
<span class="kw">impl</span> <span class="ident">BearerBuilder</span> {
<span class="doccomment">/// Provides the `scope` attribute, as defined in [RFC6749, Section 3.3](https://tools.ietf.org/html/rfc6749#section-3.3)</span>
<span class="doccomment">/// Provides the `scope` attribute, as defined in [RFC 6749 §3.3].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 6749 §3.3]: https://tools.ietf.org/html/rfc6749#section-3.3</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">scope</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) -&gt; <span class="self">Self</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -90,7 +98,9 @@
<span class="self">self</span>
}
<span class="doccomment">/// Provides the `realm` attribute, as defined in [RFC2617](https://tools.ietf.org/html/rfc2617)</span>
<span class="doccomment">/// Provides the `realm` attribute, as defined in [RFC 2617].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 2617]: https://tools.ietf.org/html/rfc2617</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">realm</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) -&gt; <span class="self">Self</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -99,13 +109,17 @@
<span class="self">self</span>
}
<span class="doccomment">/// Provides the `error` attribute, as defined in [RFC6750, Section 3.1](https://tools.ietf.org/html/rfc6750#section-3.1)</span>
<span class="doccomment">/// Provides the `error` attribute, as defined in [RFC 6750, Section 3.1].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 6750 §3.1]: https://tools.ietf.org/html/rfc6750#section-3.1</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">error</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">Error</span>) -&gt; <span class="self">Self</span> {
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="self">self</span>
}
<span class="doccomment">/// Provides the `error_description` attribute, as defined in [RFC6750, Section 3](https://tools.ietf.org/html/rfc6750#section-3)</span>
<span class="doccomment">/// Provides the `error_description` attribute, as defined in [RFC 6750, Section 3].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 6750 §3]: https://tools.ietf.org/html/rfc6750#section-3</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">error_description</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) -&gt; <span class="self">Self</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -114,9 +128,11 @@
<span class="self">self</span>
}
<span class="doccomment">/// Provides the `error_uri` attribute, as defined in [RFC6750, Section 3](https://tools.ietf.org/html/rfc6750#section-3)</span>
<span class="doccomment">/// Provides the `error_uri` attribute, as defined in [RFC 6750 §3].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// It is up to implementor to provide properly-formed absolute URI.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 6750 §3](https://tools.ietf.org/html/rfc6750#section-3)</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">error_uri</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) -&gt; <span class="self">Self</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -131,5 +147,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -143,22 +143,23 @@
<span id="137">137</span>
<span id="138">138</span>
<span id="139">139</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">std::str</span>;
<span id="140">140</span>
<span id="141">141</span>
<span id="142">142</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">borrow::Cow</span>, <span class="ident">fmt</span>, <span class="ident">str</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">InvalidHeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web::web</span>::{<span class="ident">BufMut</span>, <span class="ident">Bytes</span>, <span class="ident">BytesMut</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">http::header</span>::{<span class="ident">HeaderValue</span>, <span class="ident">InvalidHeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>},
<span class="ident">web</span>::{<span class="ident">BufMut</span>, <span class="ident">Bytes</span>, <span class="ident">BytesMut</span>},
};
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::<span class="kw">super</span>::Challenge</span>;
<span class="kw">use</span> <span class="kw">super</span>::{<span class="ident">BearerBuilder</span>, <span class="ident">Error</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::utils</span>;
<span class="doccomment">/// Challenge for [`WWW-Authenticate`] header with HTTP Bearer auth scheme,</span>
<span class="doccomment">/// described in [RFC 6750](https://tools.ietf.org/html/rfc6750#section-3)</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">/// Challenge for [`WWW-Authenticate`] header with HTTP Bearer auth scheme, described in [RFC 6750].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};</span>
<span class="doccomment">/// use actix_web_httpauth::headers::www_authenticate::bearer::{</span>
@@ -181,8 +182,9 @@
<span class="doccomment">/// }</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [`WWW-Authenticate`]: ../struct.WwwAuthenticate.html</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Eq</span>, <span class="ident">PartialEq</span>, <span class="ident">Ord</span>, <span class="ident">PartialOrd</span>, <span class="ident">Hash</span>, <span class="ident">Debug</span>, <span class="ident">Default</span>, <span class="ident">Clone</span>)]</span>
<span class="doccomment">/// [`WWW-Authenticate`]: crate::headers::www_authenticate::WwwAuthenticate</span>
<span class="doccomment">/// [RFC 6750]: https://tools.ietf.org/html/rfc6750#section-3</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Default</span>, <span class="ident">Clone</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>, <span class="ident">PartialOrd</span>, <span class="ident">Ord</span>, <span class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Bearer</span> {
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="ident">scope</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="ident">realm</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Cow</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="ident">str</span><span class="op">&gt;</span><span class="op">&gt;</span>,
@@ -194,8 +196,7 @@
<span class="kw">impl</span> <span class="ident">Bearer</span> {
<span class="doccomment">/// Creates the builder for `Bearer` challenge.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// ## Example</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web_httpauth::headers::www_authenticate::bearer::{Bearer};</span>
<span class="doccomment">/// let challenge = Bearer::build()</span>
@@ -216,10 +217,12 @@
.<span class="ident">as_ref</span>()
.<span class="ident">map_or</span>(<span class="number">0</span>, <span class="op">|</span><span class="ident">desc</span><span class="op">|</span> <span class="ident">desc</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">20</span>)
<span class="op">+</span> <span class="self">self</span>.<span class="ident">error_uri</span>.<span class="ident">as_ref</span>().<span class="ident">map_or</span>(<span class="number">0</span>, <span class="op">|</span><span class="ident">url</span><span class="op">|</span> <span class="ident">url</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">12</span>);
<span class="kw">let</span> <span class="ident">capacity</span> <span class="op">=</span> <span class="number">6</span>
<span class="op">+</span> <span class="self">self</span>.<span class="ident">realm</span>.<span class="ident">as_ref</span>().<span class="ident">map_or</span>(<span class="number">0</span>, <span class="op">|</span><span class="ident">realm</span><span class="op">|</span> <span class="ident">realm</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">9</span>)
<span class="op">+</span> <span class="self">self</span>.<span class="ident">scope</span>.<span class="ident">as_ref</span>().<span class="ident">map_or</span>(<span class="number">0</span>, <span class="op">|</span><span class="ident">scope</span><span class="op">|</span> <span class="ident">scope</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">9</span>)
<span class="op">+</span> <span class="ident">desc_uri_required</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buffer</span> <span class="op">=</span> <span class="ident">BytesMut::with_capacity</span>(<span class="ident">capacity</span>);
<span class="ident">buffer</span>.<span class="ident">put</span>(<span class="kw-2">&amp;</span><span class="string">b&quot;Bearer&quot;</span>[..]);
@@ -239,9 +242,11 @@
<span class="kw">let</span> <span class="ident">error_repr</span> <span class="op">=</span> <span class="ident">error</span>.<span class="ident">as_str</span>();
<span class="kw">let</span> <span class="ident">remaining</span> <span class="op">=</span> <span class="ident">buffer</span>.<span class="ident">remaining_mut</span>();
<span class="kw">let</span> <span class="ident">required</span> <span class="op">=</span> <span class="ident">desc_uri_required</span> <span class="op">+</span> <span class="ident">error_repr</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">9</span>; <span class="comment">// 9 is for `&quot; error=\&quot;\&quot;&quot;`</span>
<span class="kw">if</span> <span class="ident">remaining</span> <span class="op">&lt;</span> <span class="ident">required</span> {
<span class="ident">buffer</span>.<span class="ident">reserve</span>(<span class="ident">required</span>);
}
<span class="ident">buffer</span>.<span class="ident">put</span>(<span class="kw-2">&amp;</span><span class="string">b&quot; error=\&quot;&quot;</span>[..]);
<span class="ident">utils::put_quoted</span>(<span class="kw-2">&amp;mut</span> <span class="ident">buffer</span>, <span class="ident">error_repr</span>);
<span class="ident">buffer</span>.<span class="ident">put_u8</span>(<span class="string">b&#39;&quot;&#39;</span>)
@@ -266,6 +271,7 @@
<span class="kw">impl</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">Bearer</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">fmt::Error</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">to_bytes</span>();
<span class="kw">let</span> <span class="ident">repr</span> <span class="op">=</span> <span class="ident">str::from_utf8</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>)
<span class="comment">// Should not happen since challenges are crafted manually</span>
<span class="comment">// from `&amp;&#39;static str`&#39;s and Strings</span>
@@ -283,5 +289,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -54,26 +54,24 @@
<span id="48">48</span>
<span id="49">49</span>
<span id="50">50</span>
<span id="51">51</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::StatusCode</span>;
<span class="doccomment">/// Bearer authorization error types, described in [RFC 6750](https://tools.ietf.org/html/rfc6750#section-3.1)</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Copy</span>, <span class="ident">Clone</span>, <span class="ident">Eq</span>, <span class="ident">PartialEq</span>, <span class="ident">Ord</span>, <span class="ident">PartialOrd</span>, <span class="ident">Hash</span>, <span class="ident">Debug</span>)]</span>
<span class="doccomment">/// Bearer authorization error types, described in [RFC 6750].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 6750]: https://tools.ietf.org/html/rfc6750#section-3.1</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>, <span class="ident">Copy</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>, <span class="ident">PartialOrd</span>, <span class="ident">Ord</span>, <span class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Error</span> {
<span class="doccomment">/// The request is missing a required parameter, includes an unsupported</span>
<span class="doccomment">/// parameter or parameter value, repeats the same parameter, uses more</span>
<span class="doccomment">/// than one method for including an access token, or is otherwise</span>
<span class="doccomment">/// malformed.</span>
<span class="doccomment">/// The request is missing a required parameter, includes an unsupported parameter or parameter</span>
<span class="doccomment">/// value, repeats the same parameter, uses more than one method for including an access token,</span>
<span class="doccomment">/// or is otherwise malformed.</span>
<span class="ident">InvalidRequest</span>,
<span class="doccomment">/// The access token provided is expired, revoked, malformed, or invalid</span>
<span class="doccomment">/// for other reasons.</span>
<span class="doccomment">/// The access token provided is expired, revoked, malformed, or invalid for other reasons.</span>
<span class="ident">InvalidToken</span>,
<span class="doccomment">/// The request requires higher privileges than provided by the access</span>
<span class="doccomment">/// token.</span>
<span class="doccomment">/// The request requires higher privileges than provided by the access token.</span>
<span class="ident">InsufficientScope</span>,
}
@@ -107,5 +105,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -16,7 +16,22 @@
<span id="10">10</span>
<span id="11">11</span>
<span id="12">12</span>
</pre><pre class="rust"><code><span class="doccomment">//! Challenge for the &quot;Bearer&quot; HTTP Authentication Scheme</span>
<span id="13">13</span>
<span id="14">14</span>
<span id="15">15</span>
<span id="16">16</span>
<span id="17">17</span>
<span id="18">18</span>
<span id="19">19</span>
<span id="20">20</span>
<span id="21">21</span>
<span id="22">22</span>
<span id="23">23</span>
<span id="24">24</span>
<span id="25">25</span>
<span id="26">26</span>
<span id="27">27</span>
</pre><pre class="rust"><code><span class="doccomment">//! Challenge for the &quot;Bearer&quot; HTTP Authentication Scheme.</span>
<span class="kw">mod</span> <span class="ident">builder</span>;
<span class="kw">mod</span> <span class="ident">challenge</span>;
@@ -27,7 +42,22 @@
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::errors::Error</span>;
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span>;
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">to_bytes</span>() {
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> <span class="ident">Bearer::build</span>()
.<span class="ident">error</span>(<span class="ident">Error::InvalidToken</span>)
.<span class="ident">error_description</span>(<span class="string">&quot;Subject 8740827c-2e0a-447b-9716-d73042e4039d not found&quot;</span>)
.<span class="ident">finish</span>();
<span class="macro">assert_eq!</span>(
<span class="string">&quot;Bearer error=\&quot;invalid_token\&quot; error_description=\&quot;Subject 8740827c-2e0a-447b-9716-d73042e4039d not found\&quot;&quot;</span>,
<span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">b</span>)
);
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -29,5 +29,5 @@
<span class="kw">fn</span> <span class="ident">to_bytes</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">Bytes</span>;
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -37,6 +37,8 @@
<span id="31">31</span>
<span id="32">32</span>
<span id="33">33</span>
<span id="34">34</span>
<span id="35">35</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">error::ParseError</span>,
<span class="ident">http::header</span>::{<span class="ident">Header</span>, <span class="ident">HeaderName</span>, <span class="ident">HeaderValue</span>, <span class="ident">TryIntoHeaderValue</span>, <span class="ident">WWW_AUTHENTICATE</span>},
@@ -45,15 +47,17 @@
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::Challenge</span>;
<span class="doccomment">/// `WWW-Authenticate` header, described in [RFC 7235](https://tools.ietf.org/html/rfc7235#section-4.1)</span>
<span class="doccomment">/// `WWW-Authenticate` header, described in [RFC 7235].</span>
<span class="doccomment">///</span>
<span class="doccomment">/// This header is generic over [Challenge](./trait.Challenge.html) trait,</span>
<span class="doccomment">/// see [Basic](./basic/struct.Basic.html) and</span>
<span class="doccomment">/// [Bearer](./bearer/struct.Bearer.html) challenges for details.</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Eq</span>, <span class="ident">PartialEq</span>, <span class="ident">Ord</span>, <span class="ident">PartialOrd</span>, <span class="ident">Hash</span>, <span class="ident">Debug</span>, <span class="ident">Default</span>, <span class="ident">Clone</span>)]</span>
<span class="doccomment">/// This header is generic over the [`Challenge`] trait, see [`Basic`](super::basic::Basic) and</span>
<span class="doccomment">/// [`Bearer`](super::bearer::Bearer) challenges for details.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// [RFC 7235]: https://tools.ietf.org/html/rfc7235#section-4.1</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Default</span>, <span class="ident">Clone</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>, <span class="ident">PartialOrd</span>, <span class="ident">Ord</span>, <span class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">WwwAuthenticate</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span><span class="op">&gt;</span>(<span class="kw">pub</span> <span class="ident">C</span>);
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span><span class="op">&gt;</span> <span class="ident">Header</span> <span class="kw">for</span> <span class="ident">WwwAuthenticate</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="attribute">#[<span class="ident">inline</span>]</span>
<span class="kw">fn</span> <span class="ident">name</span>() -&gt; <span class="ident">HeaderName</span> {
<span class="ident">WWW_AUTHENTICATE</span>
}
@@ -71,5 +75,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -11,17 +11,13 @@
<span id="5">5</span>
<span id="6">6</span>
<span id="7">7</span>
<span id="8">8</span>
<span id="9">9</span>
</pre><pre class="rust"><code><span class="doccomment">//! `WWW-Authenticate` header and various auth challenges</span>
</pre><pre class="rust"><code><span class="doccomment">//! `WWW-Authenticate` header and various auth challenges.</span>
<span class="kw">mod</span> <span class="ident">challenge</span>;
<span class="kw">mod</span> <span class="ident">header</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::challenge::basic</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::challenge::bearer</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::challenge::Challenge</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::challenge</span>::{<span class="ident">basic</span>, <span class="ident">bearer</span>, <span class="ident">Challenge</span>};
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::header::WwwAuthenticate</span>;
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -28,8 +28,7 @@
<span id="22">22</span>
<span id="23">23</span>
<span id="24">24</span>
<span id="25">25</span>
</pre><pre class="rust"><code><span class="doccomment">//! HTTP authentication schemes for [actix-web](https://actix.rs).</span>
</pre><pre class="rust"><code><span class="doccomment">//! HTTP authentication schemes for [Actix Web](https://actix.rs).</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! Provides:</span>
<span class="doccomment">//! - Typed [Authorization] and [WWW-Authenticate] headers</span>
@@ -37,14 +36,13 @@
<span class="doccomment">//! - [Middleware] for easier authorization checking</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! ## Supported schemes</span>
<span class="doccomment">//! - `Bearer` as defined in [RFC 6750](https://tools.ietf.org/html/rfc6750).</span>
<span class="doccomment">//! - `Basic` as defined in [RFC 7617](https://tools.ietf.org/html/rfc7617).</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! - `Basic`, as defined in [RFC7617](https://tools.ietf.org/html/rfc7617)</span>
<span class="doccomment">//! - `Bearer`, as defined in [RFC6750](https://tools.ietf.org/html/rfc6750)</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! [Authorization]: `crate::headers::authorization::Authorization`</span>
<span class="doccomment">//! [WWW-Authenticate]: `crate::headers::www_authenticate::WwwAuthenticate`</span>
<span class="doccomment">//! [Extractors]: https://actix.rs/docs/extractors/</span>
<span class="doccomment">//! [Middleware]: ./middleware</span>
<span class="doccomment">//! [Authorization]: `self::headers::authorization::Authorization`</span>
<span class="doccomment">//! [WWW-Authenticate]: `self::headers::www_authenticate::WwwAuthenticate`</span>
<span class="doccomment">//! [Extractors]: https://actix.rs/docs/extractors</span>
<span class="doccomment">//! [Middleware]: self::middleware</span>
<span class="attribute">#![<span class="ident">forbid</span>(<span class="ident">unsafe_code</span>)]</span>
<span class="attribute">#![<span class="ident">deny</span>(<span class="ident">rust_2018_idioms</span>, <span class="ident">nonstandard_style</span>)]</span>
@@ -55,5 +53,5 @@
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">middleware</span>;
<span class="kw">mod</span> <span class="ident">utils</span>;
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -420,6 +420,8 @@
<span id="414">414</span>
<span id="415">415</span>
<span id="416">416</span>
<span id="417">417</span>
<span id="418">418</span>
</pre><pre class="rust"><code><span class="doccomment">//! HTTP Authentication middleware.</span>
<span class="kw">use</span> <span class="ident">std</span>::{
@@ -434,12 +436,12 @@
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">body</span>::{<span class="ident">EitherBody</span>, <span class="ident">MessageBody</span>},
<span class="ident">dev</span>::{<span class="ident">Service</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>, <span class="ident">Transform</span>},
<span class="ident">Error</span>,
<span class="ident">Error</span>, <span class="ident">FromRequest</span>,
};
<span class="kw">use</span> <span class="ident">futures_core::ready</span>;
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="self">self</span>, <span class="ident">FutureExt</span> <span class="kw">as</span> <span class="kw">_</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">TryFutureExt</span> <span class="kw">as</span> <span class="kw">_</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::extractors</span>::{<span class="ident">basic</span>, <span class="ident">bearer</span>, <span class="ident">AuthExtractor</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::extractors</span>::{<span class="ident">basic</span>, <span class="ident">bearer</span>};
<span class="doccomment">/// Middleware for checking HTTP authentication.</span>
<span class="doccomment">///</span>
@@ -451,7 +453,7 @@
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">HttpAuthentication</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">F</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">AuthExtractor</span>,
<span class="ident">T</span>: <span class="ident">FromRequest</span>,
{
<span class="ident">process_fn</span>: <span class="ident">Arc</span><span class="op">&lt;</span><span class="ident">F</span><span class="op">&gt;</span>,
<span class="ident">_extractor</span>: <span class="ident">PhantomData</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>,
@@ -459,7 +461,7 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">F</span>, <span class="ident">O</span><span class="op">&gt;</span> <span class="ident">HttpAuthentication</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">F</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">AuthExtractor</span>,
<span class="ident">T</span>: <span class="ident">FromRequest</span>,
<span class="ident">F</span>: <span class="ident">Fn</span>(<span class="ident">ServiceRequest</span>, <span class="ident">T</span>) -&gt; <span class="ident">O</span>,
<span class="ident">O</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, (<span class="ident">Error</span>, <span class="ident">ServiceRequest</span>)<span class="op">&gt;</span><span class="op">&gt;</span>,
{
@@ -480,12 +482,10 @@
{
<span class="doccomment">/// Construct `HttpAuthentication` middleware for the HTTP &quot;Basic&quot; authentication scheme.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web::Error;</span>
<span class="doccomment">/// # use actix_web::dev::ServiceRequest;</span>
<span class="doccomment">/// # use actix_web_httpauth::middleware::HttpAuthentication;</span>
<span class="doccomment">/// # use actix_web_httpauth::extractors::basic::BasicAuth;</span>
<span class="doccomment">/// # use actix_web::{Error, dev::ServiceRequest};</span>
<span class="doccomment">/// # use actix_web_httpauth::{extractors::basic::BasicAuth, middleware::HttpAuthentication};</span>
<span class="doccomment">/// // In this example validator returns immediately, but since it is required to return</span>
<span class="doccomment">/// // anything that implements `IntoFuture` trait, it can be extended to query database or to</span>
<span class="doccomment">/// // do something else in a async manner.</span>
@@ -511,20 +511,23 @@
{
<span class="doccomment">/// Construct `HttpAuthentication` middleware for the HTTP &quot;Bearer&quot; authentication scheme.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// # use actix_web::Error;</span>
<span class="doccomment">/// # use actix_web::dev::ServiceRequest;</span>
<span class="doccomment">/// # use actix_web_httpauth::middleware::HttpAuthentication;</span>
<span class="doccomment">/// # use actix_web_httpauth::extractors::bearer::{Config, BearerAuth};</span>
<span class="doccomment">/// # use actix_web_httpauth::extractors::{AuthenticationError, AuthExtractorConfig};</span>
<span class="doccomment">/// async fn validator(req: ServiceRequest, credentials: BearerAuth) -&gt; Result&lt;ServiceRequest, (Error, ServiceRequest)&gt; {</span>
<span class="doccomment">/// # use actix_web::{Error, dev::ServiceRequest};</span>
<span class="doccomment">/// # use actix_web_httpauth::{</span>
<span class="doccomment">/// # extractors::{AuthenticationError, AuthExtractorConfig, bearer::{self, BearerAuth}},</span>
<span class="doccomment">/// # middleware::HttpAuthentication,</span>
<span class="doccomment">/// # };</span>
<span class="doccomment">/// async fn validator(</span>
<span class="doccomment">/// req: ServiceRequest,</span>
<span class="doccomment">/// credentials: BearerAuth</span>
<span class="doccomment">/// ) -&gt; Result&lt;ServiceRequest, (Error, ServiceRequest)&gt; {</span>
<span class="doccomment">/// if credentials.token() == &quot;mF_9.B5f-4.1JqM&quot; {</span>
<span class="doccomment">/// Ok(req)</span>
<span class="doccomment">/// } else {</span>
<span class="doccomment">/// let config = req.app_data::&lt;Config&gt;()</span>
<span class="doccomment">/// .map(|data| data.clone())</span>
<span class="doccomment">/// .unwrap_or_else(Default::default)</span>
<span class="doccomment">/// let config = req.app_data::&lt;bearer::Config&gt;()</span>
<span class="doccomment">/// .cloned()</span>
<span class="doccomment">/// .unwrap_or_default()</span>
<span class="doccomment">/// .scope(&quot;urn:example:channel=HBO&amp;urn:example:rating=G,PG-13&quot;);</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Err((AuthenticationError::from(config).into(), req))</span>
@@ -544,7 +547,7 @@
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">F</span>: <span class="ident">Fn</span>(<span class="ident">ServiceRequest</span>, <span class="ident">T</span>) -&gt; <span class="ident">O</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">O</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, (<span class="ident">Error</span>, <span class="ident">ServiceRequest</span>)<span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">T</span>: <span class="ident">AuthExtractor</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">T</span>: <span class="ident">FromRequest</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">B</span>: <span class="ident">MessageBody</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">EitherBody</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>;
@@ -565,7 +568,7 @@
<span class="attribute">#[<span class="ident">doc</span>(<span class="ident">hidden</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">AuthenticationMiddleware</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">F</span>, <span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">AuthExtractor</span>,
<span class="ident">T</span>: <span class="ident">FromRequest</span>,
{
<span class="ident">service</span>: <span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>,
<span class="ident">process_fn</span>: <span class="ident">Arc</span><span class="op">&lt;</span><span class="ident">F</span><span class="op">&gt;</span>,
@@ -578,18 +581,17 @@
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">F</span>: <span class="ident">Fn</span>(<span class="ident">ServiceRequest</span>, <span class="ident">T</span>) -&gt; <span class="ident">O</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">O</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, (<span class="ident">Error</span>, <span class="ident">ServiceRequest</span>)<span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">T</span>: <span class="ident">AuthExtractor</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">T</span>: <span class="ident">FromRequest</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">B</span>: <span class="ident">MessageBody</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">EitherBody</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S::Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Response</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="macro">actix_service::forward_ready!</span>(<span class="ident">service</span>);
<span class="macro">actix_web::dev::forward_ready!</span>(<span class="ident">service</span>);
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) -&gt; <span class="ident"><span class="self">Self</span>::Future</span> {
<span class="kw">let</span> <span class="ident">process_fn</span> <span class="op">=</span> <span class="ident">Arc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">process_fn</span>);
<span class="kw">let</span> <span class="ident">service</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>);
<span class="kw">async</span> <span class="kw">move</span> {
@@ -615,7 +617,7 @@
<span class="kw">struct</span> <span class="ident">Extract</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="ident">req</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span><span class="op">&gt;</span>,
<span class="ident">f</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">fut</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">_extractor</span>: <span class="ident">PhantomData</span><span class="op">&lt;</span><span class="kw">fn</span>() -&gt; <span class="ident">T</span><span class="op">&gt;</span>,
}
@@ -623,7 +625,7 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">req</span>: <span class="ident">ServiceRequest</span>) -&gt; <span class="self">Self</span> {
<span class="ident">Extract</span> {
<span class="ident">req</span>: <span class="prelude-val">Some</span>(<span class="ident">req</span>),
<span class="ident">f</span>: <span class="prelude-val">None</span>,
<span class="ident">fut</span>: <span class="prelude-val">None</span>,
<span class="ident">_extractor</span>: <span class="ident">PhantomData</span>,
}
}
@@ -631,25 +633,25 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="ident">Future</span> <span class="kw">for</span> <span class="ident">Extract</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">AuthExtractor</span>,
<span class="ident">T</span>: <span class="ident">FromRequest</span>,
<span class="ident">T::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">T::Error</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(<span class="ident">ServiceRequest</span>, <span class="ident">T</span>), (<span class="ident">Error</span>, <span class="ident">ServiceRequest</span>)<span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">poll</span>(<span class="kw-2">mut</span> <span class="self">self</span>: <span class="ident">Pin</span><span class="op">&lt;</span><span class="kw-2">&amp;mut</span> <span class="self">Self</span><span class="op">&gt;</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;mut</span> <span class="ident">Context</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) -&gt; <span class="ident">Poll</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Output</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">f</span>.<span class="ident">is_none</span>() {
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">req</span>.<span class="ident">as_ref</span>().<span class="ident">expect</span>(<span class="string">&quot;Extract future was polled twice!&quot;</span>);
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">T::from_service_request</span>(<span class="ident">req</span>).<span class="ident">map_err</span>(<span class="ident">Into::into</span>);
<span class="self">self</span>.<span class="ident">f</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">f</span>.<span class="ident">boxed_local</span>());
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">fut</span>.<span class="ident">is_none</span>() {
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">req</span>.<span class="ident">as_mut</span>().<span class="ident">expect</span>(<span class="string">&quot;Extract future was polled twice!&quot;</span>);
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">extract</span>::<span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>().<span class="ident">map_err</span>(<span class="ident">Into::into</span>);
<span class="self">self</span>.<span class="ident">fut</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">fut</span>.<span class="ident">boxed_local</span>());
}
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="self">self</span>
.<span class="ident">f</span>
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="self">self</span>
.<span class="ident">fut</span>
.<span class="ident">as_mut</span>()
.<span class="ident">expect</span>(<span class="string">&quot;Extraction future should be initialized at this point&quot;</span>);
<span class="kw">let</span> <span class="ident">credentials</span> <span class="op">=</span> <span class="macro">ready!</span>(<span class="ident">f</span>.<span class="ident">as_mut</span>().<span class="ident">poll</span>(<span class="ident">ctx</span>)).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">credentials</span> <span class="op">=</span> <span class="macro">ready!</span>(<span class="ident">fut</span>.<span class="ident">as_mut</span>().<span class="ident">poll</span>(<span class="ident">ctx</span>)).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> {
(
<span class="ident">err</span>,
<span class="comment">// returning request allows a proper error response to be created</span>
@@ -664,15 +666,17 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="ident">actix_service</span>::{<span class="ident">into_service</span>, <span class="ident">Service</span>};
<span class="kw">use</span> <span class="ident">actix_web::error::ErrorForbidden</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::StatusCode</span>;
<span class="kw">use</span> <span class="ident">actix_web::test::TestRequest</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">error</span>, <span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">HttpResponse</span>};
<span class="kw">use</span> <span class="ident">actix_service::into_service</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev::Service</span>,
<span class="ident">error</span>::{<span class="self">self</span>, <span class="ident">ErrorForbidden</span>},
<span class="ident">http::StatusCode</span>,
<span class="ident">test::TestRequest</span>,
<span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">HttpResponse</span>,
};
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::extractors::basic::BasicAuth</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::extractors::bearer::BearerAuth</span>;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::extractors</span>::{<span class="ident">basic::BasicAuth</span>, <span class="ident">bearer::BearerAuth</span>};
<span class="doccomment">/// This is a test for https://github.com/actix/actix-extras/issues/10</span>
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
@@ -765,7 +769,7 @@
<span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">ServiceResponse</span>, <span class="kw">_</span><span class="op">&gt;</span>(<span class="ident">req</span>.<span class="ident">into_response</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()))
})),
<span class="ident">process_fn</span>: <span class="ident">Arc::new</span>(
<span class="op">|</span><span class="ident">req</span>, <span class="ident">auth</span>: <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">BearerAuth</span>, <span class="op">&lt;</span><span class="ident">BearerAuth</span> <span class="kw">as</span> <span class="ident">AuthExtractor</span><span class="op">&gt;</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">|</span> {
<span class="op">|</span><span class="ident">req</span>, <span class="ident">auth</span>: <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">BearerAuth</span>, <span class="op">&lt;</span><span class="ident">BearerAuth</span> <span class="kw">as</span> <span class="ident">FromRequest</span><span class="op">&gt;</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">|</span> {
<span class="macro">assert!</span>(<span class="ident">auth</span>.<span class="ident">is_err</span>());
<span class="kw">async</span> { <span class="prelude-val">Ok</span>(<span class="ident">req</span>) }
},
@@ -837,5 +841,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>

View File

@@ -115,6 +115,7 @@
<span id="109">109</span>
<span id="110">110</span>
<span id="111">111</span>
<span id="112">112</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::str</span>;
<span class="kw">use</span> <span class="ident">actix_web::web::BytesMut</span>;
@@ -144,12 +145,13 @@
<span class="kw">fn</span> <span class="ident">next</span>(<span class="kw-2">&amp;mut</span> <span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Item</span><span class="op">&gt;</span> {
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">state</span> {
<span class="ident">State::YieldStr</span> =&gt; <span class="kw">match</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">next</span>() {
<span class="prelude-val">Some</span>(<span class="ident">s</span>) =&gt; {
<span class="prelude-val">Some</span>(<span class="ident">val</span>) =&gt; {
<span class="self">self</span>.<span class="ident">state</span> <span class="op">=</span> <span class="ident">State::YieldQuote</span>;
<span class="prelude-val">Some</span>(<span class="ident">s</span>)
<span class="prelude-val">Some</span>(<span class="ident">val</span>)
}
<span class="prelude-val">None</span> =&gt; <span class="prelude-val">None</span>,
},
<span class="ident">State::YieldQuote</span> =&gt; <span class="kw">match</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">peek</span>() {
<span class="prelude-val">Some</span>(<span class="kw">_</span>) =&gt; {
<span class="self">self</span>.<span class="ident">state</span> <span class="op">=</span> <span class="ident">State::YieldStr</span>;
@@ -161,9 +163,9 @@
}
}
<span class="doccomment">/// Tries to quote the quotes in the passed `value`</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">put_quoted</span>(<span class="ident">buf</span>: <span class="kw-2">&amp;mut</span> <span class="ident">BytesMut</span>, <span class="ident">value</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) {
<span class="kw">for</span> <span class="ident">part</span> <span class="kw">in</span> <span class="ident">Quoted::new</span>(<span class="ident">value</span>) {
<span class="doccomment">/// Escapes the quotes in `val`.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">put_quoted</span>(<span class="ident">buf</span>: <span class="kw-2">&amp;mut</span> <span class="ident">BytesMut</span>, <span class="ident">val</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) {
<span class="kw">for</span> <span class="ident">part</span> <span class="kw">in</span> <span class="ident">Quoted::new</span>(<span class="ident">val</span>) {
<span class="ident">buf</span>.<span class="ident">extend_from_slice</span>(<span class="ident">part</span>.<span class="ident">as_bytes</span>());
}
}
@@ -227,5 +229,5 @@
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (9a7b7d5e5 2022-07-19)" ></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (d68e7ebc3 2022-07-20)" ></div>
</body></html>