Skip to content

Commit

Permalink
Add IP whitelisting functionality
Browse files Browse the repository at this point in the history
Restructure OAuth process
Fix lazy check and improve datastructure on rate limiting
  • Loading branch information
dormant-user committed Sep 18, 2024
1 parent 8d00d11 commit ff03fd3
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 85 deletions.
17 changes: 12 additions & 5 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ <h3>Navigation</h3>
<h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a>
<a href="#_"><strong>_</strong></a>
| <a href="#A"><strong>A</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#E"><strong>E</strong></a>
Expand All @@ -61,6 +62,14 @@ <h1 id="index">Index</h1>
| <a href="#W"><strong>W</strong></a>

</div>
<h2 id="_">_</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#vaultapi.rate_limit._get_identifier">_get_identifier() (in module vaultapi.rate_limit)</a>
</li>
</ul></td>
</tr></table>

<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down Expand Up @@ -131,8 +140,6 @@ <h2 id="E">E</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#vaultapi.main.enable_cors">enable_cors() (in module vaultapi.main)</a>
</li>
<li><a href="index.html#vaultapi.models.EnvConfig.endpoints">endpoints (vaultapi.models.EnvConfig attribute)</a>
</li>
<li><a href="index.html#vaultapi.models.env">env (in module vaultapi.models)</a>
</li>
Expand Down Expand Up @@ -271,11 +278,11 @@ <h2 id="M">M</h2>
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#vaultapi.models.EnvConfig.parse_allowed_origins">parse_allowed_origins() (vaultapi.models.EnvConfig class method)</a>
</li>
<li><a href="index.html#vaultapi.models.EnvConfig.parse_api_secret">parse_api_secret() (vaultapi.models.EnvConfig class method)</a>
</li>
<li><a href="index.html#vaultapi.models.EnvConfig.parse_apikey">parse_apikey() (vaultapi.models.EnvConfig class method)</a>
</li>
<li><a href="index.html#vaultapi.models.EnvConfig.parse_endpoints">parse_endpoints() (vaultapi.models.EnvConfig class method)</a>
</li>
<li><a href="index.html#vaultapi.models.EnvConfig.port">port (vaultapi.models.EnvConfig attribute)</a>
</li>
Expand Down
35 changes: 14 additions & 21 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,6 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"
<span class="sig-name descname"><span class="pre">database</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">Path</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Path</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#vaultapi.models.EnvConfig.database" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="vaultapi.models.EnvConfig.endpoints">
<span class="sig-name descname"><span class="pre">endpoints</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#vaultapi.models.EnvConfig.endpoints" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="vaultapi.models.EnvConfig.host">
<span class="sig-name descname"><span class="pre">host</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><a class="headerlink" href="#vaultapi.models.EnvConfig.host" title="Permalink to this definition"></a></dt>
Expand All @@ -350,7 +345,7 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

<dl class="py attribute">
<dt class="sig sig-object py" id="vaultapi.models.EnvConfig.allowed_origins">
<span class="sig-name descname"><span class="pre">allowed_origins</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#vaultapi.models.EnvConfig.allowed_origins" title="Permalink to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">allowed_origins</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#vaultapi.models.EnvConfig.allowed_origins" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
Expand All @@ -359,9 +354,9 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"
<dd></dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="vaultapi.models.EnvConfig.parse_endpoints">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_endpoints</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#vaultapi.models.EnvConfig.parse_endpoints" title="Permalink to this definition"></a></dt>
<dd><p>Validate endpoints to enable CORS policy.</p>
<dt class="sig sig-object py" id="vaultapi.models.EnvConfig.parse_allowed_origins">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_allowed_origins</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Union</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#vaultapi.models.EnvConfig.parse_allowed_origins" title="Permalink to this definition"></a></dt>
<dd><p>Validate allowed origins to enable CORS policy.</p>
</dd></dl>

<dl class="py method">
Expand All @@ -372,8 +367,8 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

<dl class="py method">
<dt class="sig sig-object py" id="vaultapi.models.EnvConfig.parse_api_secret">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_api_secret</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span></span><a class="headerlink" href="#vaultapi.models.EnvConfig.parse_api_secret" title="Permalink to this definition"></a></dt>
<dd><p>Parse API secret to validate complexity.</p>
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_api_secret</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#vaultapi.models.EnvConfig.parse_api_secret" title="Permalink to this definition"></a></dt>
<dd><p>Parse API secret to Fernet compatible.</p>
</dd></dl>

<dl class="py method">
Expand Down Expand Up @@ -419,16 +414,8 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"
<hr class="docutils" />
<span class="target" id="module-vaultapi.models"></span><dl class="py function">
<dt class="sig sig-object py" id="vaultapi.models.complexity_checker">
<span class="sig-prename descclassname"><span class="pre">vaultapi.models.</span></span><span class="sig-name descname"><span class="pre">complexity_checker</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">secret</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">simple</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#vaultapi.models.complexity_checker" title="Permalink to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">vaultapi.models.</span></span><span class="sig-name descname"><span class="pre">complexity_checker</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">secret</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#vaultapi.models.complexity_checker" title="Permalink to this definition"></a></dt>
<dd><p>Verifies the strength of a secret.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>secret</strong> – Value of the secret.</p></li>
<li><p><strong>simple</strong> – Boolean flag to increase complexity.</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>A secret is considered strong if it at least has:</p>
Expand Down Expand Up @@ -526,10 +513,16 @@ <h1>Payload<a class="headerlink" href="#payload" title="Permalink to this headin
</section>
<section id="module-vaultapi.rate_limit">
<span id="ratelimit"></span><h1>RateLimit<a class="headerlink" href="#module-vaultapi.rate_limit" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="vaultapi.rate_limit._get_identifier">
<span class="sig-prename descclassname"><span class="pre">vaultapi.rate_limit.</span></span><span class="sig-name descname"><span class="pre">_get_identifier</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">request</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Request</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#vaultapi.rate_limit._get_identifier" title="Permalink to this definition"></a></dt>
<dd><p>Generate a unique identifier for the request.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="vaultapi.rate_limit.RateLimiter">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">vaultapi.rate_limit.</span></span><span class="sig-name descname"><span class="pre">RateLimiter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rps</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#vaultapi.models.RateLimit" title="vaultapi.models.RateLimit"><span class="pre">RateLimit</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#vaultapi.rate_limit.RateLimiter" title="Permalink to this definition"></a></dt>
<dd><p>Object that implements the <code class="docutils literal notranslate"><span class="pre">RateLimiter</span></code> functionality.</p>
<dd><p>Rate limiter for incoming requests.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">RateLimiter</span>
</pre></div>
</div>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
Loading

0 comments on commit ff03fd3

Please sign in to comment.