Skip to content

Commit

Permalink
[17.0][FIX] auth_jwt: cleaning up for migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kobros-tech authored and dnplkndll committed Jan 16, 2025
1 parent 7f7dd09 commit 5b14de5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
29 changes: 15 additions & 14 deletions auth_jwt/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ Odoo controller routes.

To use it, you must:

- Create an ``auth.jwt.validator`` record to configure how the JWT
token will be validated.
- Add an ``auth="jwt_{validator-name}"`` or
``auth="public_or_jwt_{validator-name}"`` attribute to the routes you
want to protect where ``{validator-name}`` corresponds to the name
attribute of the JWT validator record.
- Create an ``auth.jwt.validator`` record to configure how the JWT token
will be validated.
- Add an ``auth="jwt_{validator-name}"`` or
``auth="public_or_jwt_{validator-name}"`` attribute to the routes you
want to protect where ``{validator-name}`` corresponds to the name
attribute of the JWT validator record.

The ``auth_jwt_demo`` module provides examples.

The JWT validator can be configured with the following properties:

- ``name``: the validator name, to match the
``auth="jwt_{validator-name}"`` route property.
- ``audience``: a comma-separated list of allowed audiences, used to
validate the ``aud`` claim.
- ``issuer``: used to validate the ``iss`` claim.
- Signature type (secret or public key), algorithm, secret and JWK URI
are used to validate the token signature.
- ``name``: the validator name, to match the
``auth="jwt_{validator-name}"`` route property.
- ``audience``: a comma-separated list of allowed audiences, used to
validate the ``aud`` claim.
- ``issuer``: used to validate the ``iss`` claim.
- Signature type (secret or public key), algorithm, secret and JWK URI
are used to validate the token signature.

In addition, the ``exp`` claim is validated to reject expired tokens.

Expand Down Expand Up @@ -135,7 +135,8 @@ Authors
Contributors
------------

- Stéphane Bidoul <[email protected]>
- Stéphane Bidoul <[email protected]>
- Mohamed Alkobrosli <[email protected]>

Maintainers
-----------
Expand Down
1 change: 1 addition & 0 deletions auth_jwt/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Stéphane Bidoul \<<[email protected]>\>
- Mohamed Alkobrosli \<<[email protected]>\>
5 changes: 3 additions & 2 deletions auth_jwt/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
Odoo controller routes.</p>
<p>To use it, you must:</p>
<ul class="simple">
<li>Create an <tt class="docutils literal">auth.jwt.validator</tt> record to configure how the JWT
token will be validated.</li>
<li>Create an <tt class="docutils literal">auth.jwt.validator</tt> record to configure how the JWT token
will be validated.</li>
<li>Add an <tt class="docutils literal"><span class="pre">auth=&quot;jwt_{validator-name}&quot;</span></tt> or
<tt class="docutils literal"><span class="pre">auth=&quot;public_or_jwt_{validator-name}&quot;</span></tt> attribute to the routes you
want to protect where <tt class="docutils literal"><span class="pre">{validator-name}</span></tt> corresponds to the name
Expand Down Expand Up @@ -473,6 +473,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
<li>Mohamed Alkobrosli &lt;<a class="reference external" href="mailto:malkobrosly&#64;kencove.com">malkobrosly&#64;kencove.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
2 changes: 1 addition & 1 deletion auth_jwt/tests/test_auth_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_auth_method_invalid_token_on_chain(self):
self.assertEqual(
str(composite_error.exception),
"401 Unauthorized: "
+ "Multiple errors occurred during JWT chain validation:\n"
"Multiple errors occurred during JWT chain validation:\n"
"validator: 401 Unauthorized: "
"The server could not verify that you are authorized to "
"access the URL requested. You either supplied the wrong "
Expand Down

0 comments on commit 5b14de5

Please sign in to comment.