Implemented, tested non-PKCE flow. Fixes #1

This commit is contained in:
Barnaby Walters
2021-06-18 00:39:21 +02:00
parent ce541c3607
commit 1af270b42f
31 changed files with 1691 additions and 1263 deletions

View File

@@ -115,21 +115,21 @@
<dt class="phpdocumentor-table-of-contents__entry -function -">
<a href="namespaces/taproot-indieauth.html#function_generateRandomString">generateRandomString()</a>
<span>
&nbsp;: mixed </span>
&nbsp;: string </span>
</dt>
<dd></dd>
<dt class="phpdocumentor-table-of-contents__entry -function -">
<a href="namespaces/taproot-indieauth.html#function_generateRandomPrintableAsciiString">generateRandomPrintableAsciiString()</a>
<span>
&nbsp;: mixed </span>
&nbsp;: string </span>
</dt>
<dd></dd>
<dt class="phpdocumentor-table-of-contents__entry -function -">
<a href="namespaces/taproot-indieauth.html#function_generatePKCECodeChallenge">generatePKCECodeChallenge()</a>
<span>
&nbsp;: mixed </span>
&nbsp;: string </span>
</dt>
<dd></dd>
@@ -185,7 +185,7 @@
<dt class="phpdocumentor-table-of-contents__entry -function -">
<a href="namespaces/taproot-indieauth.html#function_appendQueryParams">appendQueryParams()</a>
<span>
&nbsp;: mixed </span>
&nbsp;: string </span>
</dt>
<dd>Append Query Parameters</dd>
@@ -261,14 +261,14 @@
<code class="phpdocumentor-code phpdocumentor-signature ">
<span class="phpdocumentor-signature__visibility"></span>
<span class="phpdocumentor-signature__name">generateRandomString</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">mixed&nbsp;</span><span class="phpdocumentor-signature__argument__name">$numBytes</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
<span class="phpdocumentor-signature__name">generateRandomString</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$numBytes</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string</span></code>
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
<dl class="phpdocumentor-argument-list">
<dt class="phpdocumentor-argument-list__entry">
<span class="phpdocumentor-signature__argument__name">$numBytes</span>
: <span class="phpdocumentor-signature__argument__return-type">mixed</span>
: <span class="phpdocumentor-signature__argument__return-type">int</span>
</dt>
<dd class="phpdocumentor-argument-list__definition">
@@ -293,7 +293,7 @@
<code class="phpdocumentor-code phpdocumentor-signature ">
<span class="phpdocumentor-signature__visibility"></span>
<span class="phpdocumentor-signature__name">generateRandomPrintableAsciiString</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$length</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
<span class="phpdocumentor-signature__name">generateRandomPrintableAsciiString</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$length</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string</span></code>
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
@@ -325,14 +325,14 @@
<code class="phpdocumentor-code phpdocumentor-signature ">
<span class="phpdocumentor-signature__visibility"></span>
<span class="phpdocumentor-signature__name">generatePKCECodeChallenge</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">mixed&nbsp;</span><span class="phpdocumentor-signature__argument__name">$plaintext</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
<span class="phpdocumentor-signature__name">generatePKCECodeChallenge</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$plaintext</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string</span></code>
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
<dl class="phpdocumentor-argument-list">
<dt class="phpdocumentor-argument-list__entry">
<span class="phpdocumentor-signature__argument__name">$plaintext</span>
: <span class="phpdocumentor-signature__argument__return-type">mixed</span>
: <span class="phpdocumentor-signature__argument__return-type">string</span>
</dt>
<dd class="phpdocumentor-argument-list__definition">
@@ -389,7 +389,7 @@
<code class="phpdocumentor-code phpdocumentor-signature ">
<span class="phpdocumentor-signature__visibility"></span>
<span class="phpdocumentor-signature__name">hashAuthorizationRequestParameters</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$request</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$secret</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">string|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$algo</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">null</span><span> ]</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$hashedParameters</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">null</span><span> ]</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string|null</span></code>
<span class="phpdocumentor-signature__name">hashAuthorizationRequestParameters</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$request</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$secret</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">string|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$algo</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">null</span><span> ]</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$hashedParameters</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">null</span><span> ]</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">bool&nbsp;</span><span class="phpdocumentor-signature__argument__name">$requirePkce</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">true</span><span> ]</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string|null</span></code>
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
@@ -421,6 +421,13 @@
= <span class="phpdocumentor-signature__argument__default-value">null</span> </dt>
<dd class="phpdocumentor-argument-list__definition">
</dd>
<dt class="phpdocumentor-argument-list__entry">
<span class="phpdocumentor-signature__argument__name">$requirePkce</span>
: <span class="phpdocumentor-signature__argument__return-type">bool</span>
= <span class="phpdocumentor-signature__argument__default-value">true</span> </dt>
<dd class="phpdocumentor-argument-list__definition">
</dd>
</dl>
@@ -436,7 +443,7 @@
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">60</span>
<span class="phpdocumentor-element-found-in__line">64</span>
</aside>
@@ -468,7 +475,7 @@
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">66</span>
<span class="phpdocumentor-element-found-in__line">70</span>
</aside>
@@ -507,7 +514,7 @@
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">72</span>
<span class="phpdocumentor-element-found-in__line">76</span>
</aside>
@@ -539,7 +546,7 @@
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">78</span>
<span class="phpdocumentor-element-found-in__line">82</span>
</aside>
@@ -571,7 +578,7 @@
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">86</span>
<span class="phpdocumentor-element-found-in__line">90</span>
</aside>
@@ -617,14 +624,14 @@
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">110</span>
<span class="phpdocumentor-element-found-in__line">114</span>
</aside>
<p class="phpdocumentor-summary">Append Query Parameters</p>
<code class="phpdocumentor-code phpdocumentor-signature ">
<span class="phpdocumentor-signature__visibility"></span>
<span class="phpdocumentor-signature__name">appendQueryParams</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$uri</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$queryParams</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
<span class="phpdocumentor-signature__name">appendQueryParams</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$uri</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$queryParams</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string</span></code>
<section class="phpdocumentor-description"><p>Converts <code class="prettyprint">$queryParams</code> into a query string, then checks <code class="prettyprint">$uri</code> for an
existing query string. Then appends the newly generated query string
@@ -661,7 +668,7 @@ with either ? or &amp; as appropriate.</p>
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">127</span>
<span class="phpdocumentor-element-found-in__line">134</span>
</aside>
<p class="phpdocumentor-summary">Try setLogger</p>
@@ -693,6 +700,30 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
</dl>
<h5 class="phpdocumentor-tag-list__heading" id="tags">
Tags
<a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
</h5>
<dl class="phpdocumentor-tag-list">
<dt class="phpdocumentor-tag-list__entry">
<span class="phpdocumentor-tag__name">psalm-suppress</span>
</dt>
<dd class="phpdocumentor-tag-list__definition">
<section class="phpdocumentor-description"><p>MissingReturnType</p>
</section>
</dd>
<dt class="phpdocumentor-tag-list__entry">
<span class="phpdocumentor-tag__name">psalm-suppress</span>
</dt>
<dd class="phpdocumentor-tag-list__definition">
<section class="phpdocumentor-description"><p>MissingParamType</p>
</section>
</dd>
</dl>
</article>
@@ -704,7 +735,7 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">134</span>
<span class="phpdocumentor-element-found-in__line">141</span>
</aside>
@@ -743,7 +774,7 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">159</span>
<span class="phpdocumentor-element-found-in__line">166</span>
</aside>
<p class="phpdocumentor-summary">Check if a provided string matches the IndieAuth criteria for a Client Identifier.</p>
@@ -794,7 +825,7 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">183</span>
<span class="phpdocumentor-element-found-in__line">190</span>
</aside>
<p class="phpdocumentor-summary">Check if a provided string matches the IndieAuth criteria for a User Profile URL.</p>
@@ -845,7 +876,7 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">202</span>
<span class="phpdocumentor-element-found-in__line">209</span>
</aside>
<p class="phpdocumentor-summary">OAuth 2.0 limits what values are valid for state.</p>
@@ -895,7 +926,7 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">211</span>
<span class="phpdocumentor-element-found-in__line">218</span>
</aside>
<p class="phpdocumentor-summary">IndieAuth requires PKCE. This implementation supports only S256 for hashing.</p>
@@ -944,7 +975,7 @@ to <code class="prettyprint">$logger</code>. Returns <code class="prettyprint">$
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/functions.php"><a href="files/src-functions.html"><abbr title="src/functions.php">functions.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">219</span>
<span class="phpdocumentor-element-found-in__line">226</span>
</aside>
<p class="phpdocumentor-summary">OAuth 2.0 limits what values are valid for scope.</p>