@@ -17,19 +17,20 @@ FastAPI Auth JWT support
1717 :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818 :alt: License: LGPL-3
1919.. |badge3 | image :: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
20- :target: https://github.com/OCA/rest-framework/tree/16 .0/fastapi_auth_jwt
20+ :target: https://github.com/OCA/rest-framework/tree/17 .0/fastapi_auth_jwt
2121 :alt: OCA/rest-framework
2222.. |badge4 | image :: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23- :target: https://translation.odoo-community.org/projects/rest-framework-16 -0/rest-framework-16 -0-fastapi_auth_jwt
23+ :target: https://translation.odoo-community.org/projects/rest-framework-17 -0/rest-framework-17 -0-fastapi_auth_jwt
2424 :alt: Translate me on Weblate
2525.. |badge5 | image :: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26- :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=16 .0
26+ :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=17 .0
2727 :alt: Try me on Runboat
2828
2929|badge1 | |badge2 | |badge3 | |badge4 | |badge5 |
3030
31- This module provides ``FastAPI `` ``Depends `` to allow authentication with `auth_jwt
32- <https://github.com/OCA/server-auth/tree/16.0/auth_jwt> `_.
31+ This module provides ``FastAPI `` ``Depends `` to allow authentication
32+ with
33+ `auth_jwt <https://github.com/OCA/server-auth/tree/16.0/auth_jwt >`__.
3334
3435**Table of contents **
3536
@@ -39,83 +40,97 @@ This module provides ``FastAPI`` ``Depends`` to allow authentication with `auth_
3940Usage
4041=====
4142
42- The following FastAPI dependencies are provided and importable from
43+ The following FastAPI dependencies are provided and importable from
4344``odoo.addons.fastapi_auth_jwt.dependencies ``:
4445
4546``def auth_jwt_authenticated_payload() -> Payload ``
4647
47- Return the authenticated JWT payload. Raise a 401 (unauthorized) if absent or invalid.
48+ Return the authenticated JWT payload. Raise a 401 (unauthorized) if
49+ absent or invalid.
4850
4951``def auth_jwt_optionally_authenticated_payload() -> Payload | None ``
5052
51- Return the authenticated JWT payload, or ``None `` if the ``Authorization `` header and
52- cookie are absent. Raise a 401 (unauthorized) if present and invalid.
53+ Return the authenticated JWT payload, or ``None `` if the
54+ ``Authorization `` header and cookie are absent. Raise a 401
55+ (unauthorized) if present and invalid.
5356
5457``def auth_jwt_authenticated_partner() -> Partner ``
5558
56- Obtain the authenticated partner corresponding to the provided JWT token, according to
57- the partner strategy defined on the ``auth_jwt `` validator. Raise a 401 (unauthorized)
58- if the partner could not be determined for any reason.
59+ Obtain the authenticated partner corresponding to the provided JWT
60+ token, according to the partner strategy defined on the ``auth_jwt ``
61+ validator. Raise a 401 (unauthorized) if the partner could not be
62+ determined for any reason.
5963
60- This is function suitable and intended to override
61- ``odoo.addons.fastapi.dependencies.authenticated_partner_impl ``.
64+ This is function suitable and intended to override
65+ ``odoo.addons.fastapi.dependencies.authenticated_partner_impl ``.
6266
63- The partner record returned by this function is bound to an environment that uses the
64- Odoo user obtained from the user strategy defined on the ``auth_jwt `` validator. When
65- used ``authenticated_partner_impl `` this in turn ensures that
66- ``odoo.addons.fastapi.dependencies.authenticated_partner_env `` is also bound to the
67- correct Odoo user.
67+ The partner record returned by this function is bound to an
68+ environment that uses the Odoo user obtained from the user strategy
69+ defined on the ``auth_jwt `` validator. When used
70+ ``authenticated_partner_impl `` this in turn ensures that
71+ ``odoo.addons.fastapi.dependencies.authenticated_partner_env `` is
72+ also bound to the correct Odoo user.
6873
6974``def auth_jwt_optionally_authenticated_partner() -> Partner ``
7075
71- Same as ``auth_jwt_partner `` except it returns an empty recordset bound to the
72- ``public `` user if the ``Authorization `` header and cookie are absent, or if the JWT
73- validator could not find the partner and declares that the partner is not required.
76+ Same as ``auth_jwt_partner `` except it returns an empty recordset
77+ bound to the ``public `` user if the ``Authorization `` header and
78+ cookie are absent, or if the JWT validator could not find the partner
79+ and declares that the partner is not required.
7480
7581``def auth_jwt_authenticated_odoo_env() -> Environment ``
7682
77- Return an Odoo environment using the the Odoo user obtained from the user strategy
78- defined on the ``auth_jwt `` validator, if the request could be authenticated using a
79- JWT validator. Raise a 401 (unauthorized) otherwise.
83+ Return an Odoo environment using the the Odoo user obtained from the
84+ user strategy defined on the ``auth_jwt `` validator, if the request
85+ could be authenticated using a JWT validator. Raise a 401
86+ (unauthorized) otherwise.
8087
81- This is function suitable and intended to override
82- ``odoo.addons.fastapi.dependencies.authenticated_odoo_env_impl ``.
88+ This is function suitable and intended to override
89+ ``odoo.addons.fastapi.dependencies.authenticated_odoo_env_impl ``.
8390
8491``def auth_jwt_default_validator_name() -> str | None ``
8592
86- Return the name of the default JWT validator to use.
93+ Return the name of the default JWT validator to use.
8794
88- The default implementation returns ``None `` meaning only one active JWT validator is
89- allowed. This dependency is meant to be overridden.
95+ The default implementation returns ``None `` meaning only one active
96+ JWT validator is allowed. This dependency is meant to be overridden.
9097
9198``def auth_jwt_http_header_authorization() -> str | None ``
9299
93- By default, return the credentials part of the ``Authorization `` header, or ``None ``
94- if absent. This dependency is meant to be overridden, in particular with
95- ``fastapi.security.OAuth2AuthorizationCodeBearer `` to let swagger handle OAuth2
96- authorization (such override is only necessary for comfort when using the swagger
97- interface).
100+ By default, return the credentials part of the ``Authorization ``
101+ header, or ``None `` if absent. This dependency is meant to be
102+ overridden, in particular with
103+ ``fastapi.security.OAuth2AuthorizationCodeBearer `` to let swagger
104+ handle OAuth2 authorization (such override is only necessary for
105+ comfort when using the swagger interface).
98106
99107Bug Tracker
100108===========
101109
102110Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues >`_.
103111In case of trouble, please check there if your issue has already been reported.
104112If you spotted it first, help us to smash it by providing a detailed and welcomed
105- `feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi_auth_jwt%0Aversion:%2016 .0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior** >`_.
113+ `feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi_auth_jwt%0Aversion:%2017 .0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior** >`_.
106114
107115Do not contact contributors directly about support or help with technical issues.
108116
109117Credits
110118=======
111119
112120Authors
113- ~~~~~~~
121+ -------
114122
115123* ACSONE SA/NV
116124
125+ Contributors
126+ ------------
127+
128+ Antony Herrera <antonyht27@gmail.com>
129+
130+ Mohamed Alkobrosli <malkobrosly@kencove.com>
131+
117132Maintainers
118- ~~~~~~~~~~~
133+ -----------
119134
120135This module is maintained by the OCA.
121136
@@ -135,6 +150,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
135150
136151|maintainer-sbidoul |
137152
138- This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/16 .0/fastapi_auth_jwt >`_ project on GitHub.
153+ This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/17 .0/fastapi_auth_jwt >`_ project on GitHub.
139154
140155You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
0 commit comments