Skip to content

Commit 97201f8

Browse files
authored
Merge pull request #39 from OCA/18.0
Syncing from upstream OCA/rest-framework (18.0)
2 parents 5212537 + 8c6bdc7 commit 97201f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2416
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ addon | version | maintainers | summary
3030
[fastapi](fastapi/) | 18.0.1.3.2 | <a href='https://github.com/lmignon'><img src='https://github.com/lmignon.png' width='32' height='32' style='border-radius:50%;' alt='lmignon'/></a> | Odoo FastAPI endpoint
3131
[fastapi_auth_api_key](fastapi_auth_api_key/) | 18.0.1.0.0 | <a href='https://github.com/mmequignon'><img src='https://github.com/mmequignon.png' width='32' height='32' style='border-radius:50%;' alt='mmequignon'/></a> | Fastapi Auth API Key
3232
[fastapi_auth_jwt](fastapi_auth_jwt/) | 18.0.1.0.0 | <a href='https://github.com/sbidoul'><img src='https://github.com/sbidoul.png' width='32' height='32' style='border-radius:50%;' alt='sbidoul'/></a> | JWT bearer token authentication for FastAPI.
33+
[fastapi_auth_partner](fastapi_auth_partner/) | 18.0.1.0.0 | | This provides an implementation of auth_partner for FastAPI
3334
[fastapi_endpoint_context](fastapi_endpoint_context/) | 18.0.1.0.0 | <a href='https://github.com/paradoxxxzero'><img src='https://github.com/paradoxxxzero.png' width='32' height='32' style='border-radius:50%;' alt='paradoxxxzero'/></a> | Provides an overridable request context for FastAPI endpoints
3435
[pydantic](pydantic/) | 18.0.1.1.0 | <a href='https://github.com/lmignon'><img src='https://github.com/lmignon.png' width='32' height='32' style='border-radius:50%;' alt='lmignon'/></a> | Utility addon to ease mapping between Pydantic and Odoo models
3536
[rest_log](rest_log/) | 18.0.1.0.1 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Track REST API calls into DB

base_rest/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Base Rest
1111
!! This file is generated by oca-gen-addon-readme !!
1212
!! changes will be overwritten. !!
1313
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14-
!! source digest: sha256:4bac77b10863d37a6d94d450ac1584accce5be4a436a7a839f8035d8cab1729d
14+
!! source digest: sha256:25cd8c40026a737b1bedc8d9b51867a5be4866256a570f3363f939584faece0d
1515
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1616
1717
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

base_rest/__manifest__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"version": "18.0.1.1.2",
1010
"development_status": "Beta",
1111
"license": "LGPL-3",
12-
"author": "ACSONE SA/NV, " "Odoo Community Association (OCA)",
12+
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
1313
"maintainers": [],
1414
"website": "https://github.com/OCA/rest-framework",
1515
"depends": ["component", "web"],
@@ -20,8 +20,7 @@
2020
"assets": {
2121
"web.assets_frontend": [
2222
"base_rest/static/src/scss/base_rest.scss",
23-
"base_rest/static/src/js/swagger_ui.js",
24-
"base_rest/static/src/js/swagger.js",
23+
"base_rest/static/src/js/components/swagger_ui.js",
2524
],
2625
},
2726
"external_dependencies": {

base_rest/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ <h1>Base Rest</h1>
372372
!! This file is generated by oca-gen-addon-readme !!
373373
!! changes will be overwritten. !!
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375-
!! source digest: sha256:4bac77b10863d37a6d94d450ac1584accce5be4a436a7a839f8035d8cab1729d
375+
!! source digest: sha256:25cd8c40026a737b1bedc8d9b51867a5be4866256a570f3363f939584faece0d
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377377
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/18.0/base_rest"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-base_rest"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This addon is deprecated and not fully supported anymore from Odoo 16.

fastapi/i18n/fastapi.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ msgstr ""
4747

4848
#. module: fastapi
4949
#: model:ir.model.fields,field_description:fastapi.field_fastapi_endpoint__demo_auth_method
50-
msgid "Authenciation method"
50+
msgid "Authentication method"
5151
msgstr ""
5252

5353
#. module: fastapi

fastapi/i18n/it.po

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ msgstr "In archivio"
5050

5151
#. module: fastapi
5252
#: model:ir.model.fields,field_description:fastapi.field_fastapi_endpoint__demo_auth_method
53-
msgid "Authenciation method"
54-
msgstr "Metodo autenticazione"
53+
msgid "Authentication method"
54+
msgstr ""
5555

5656
#. module: fastapi
5757
#: model:ir.model.fields,field_description:fastapi.field_fastapi_endpoint__company_id
@@ -258,5 +258,8 @@ msgstr ""
258258
msgid "`%(name)s` uses a blacklisted root_path = `%(root_path)s`"
259259
msgstr "`%(name)s` utilizza un root_path bloccato = `%(root_path)s`"
260260

261+
#~ msgid "Authenciation method"
262+
#~ msgstr "Metodo autenticazione"
263+
261264
#~ msgid "Last Modified on"
262265
#~ msgstr "Ultima modifica il"

fastapi_auth_partner/README.rst

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
5+
====================
6+
Fastapi Auth Partner
7+
====================
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:959857e48fbc660ca7012f4a8364b02247c1622d785239a293e7fd4d69e474cc
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Beta
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
22+
:alt: License: AGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
24+
:target: https://github.com/OCA/rest-framework/tree/18.0/fastapi_auth_partner
25+
:alt: OCA/rest-framework
26+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27+
:target: https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-fastapi_auth_partner
28+
:alt: Translate me on Weblate
29+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=18.0
31+
:alt: Try me on Runboat
32+
33+
|badge1| |badge2| |badge3| |badge4| |badge5|
34+
35+
This module is the FastAPI implementation of
36+
`auth_partner <../auth_partner>`__ it provides all the routes to manage
37+
the authentication of partners.
38+
39+
**Table of contents**
40+
41+
.. contents::
42+
:local:
43+
44+
Usage
45+
=====
46+
47+
First you have to add the auth router to your FastAPI endpoint and the
48+
authentication dependency to your app dependencies:
49+
50+
.. code:: python
51+
52+
from odoo.addons.fastapi import dependencies
53+
from odoo.addons.fastapi_auth_partner.dependencies import (
54+
auth_partner_authenticated_partner,
55+
)
56+
from odoo.addons.fastapi_auth_partner.routers.auth import auth_router
57+
58+
class FastapiEndpoint(models.Model):
59+
_inherit = "fastapi.endpoint"
60+
61+
def _get_fastapi_routers(self):
62+
if self.app == "myapp":
63+
return [
64+
auth_router,
65+
]
66+
return super()._get_fastapi_routers()
67+
68+
def _get_app_dependencies_overrides(self):
69+
res = super()._get_app_dependencies_overrides()
70+
if self.app == "myapp":
71+
res.update(
72+
{
73+
dependencies.authenticated_partner_impl: auth_partner_authenticated_partner,
74+
}
75+
)
76+
return res
77+
78+
Next you can manage your authenticable partners and directories in the
79+
Odoo interface:
80+
81+
FastAPI > Authentication > Partner
82+
83+
and
84+
85+
FastAPI > Authentication > Directory
86+
87+
Next you must set the directory used for the authentication in the
88+
FastAPI endpoint:
89+
90+
FastAPI > FastAPI Endpoint > myapp > Directory
91+
92+
Then you can use the auth router to authenticate your requests:
93+
94+
- POST /auth/register to register a partner
95+
- POST /auth/login to authenticate a partner
96+
- POST /auth/logout to unauthenticate a partner
97+
- POST /auth/validate_email to validate a partner email
98+
- POST /auth/request_reset_password to request a password reset
99+
- POST /auth/set_password to set a new password
100+
- GET /auth/profile to get the partner profile
101+
- GET /auth/impersonate to impersonate a partner
102+
103+
Bug Tracker
104+
===========
105+
106+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
107+
In case of trouble, please check there if your issue has already been reported.
108+
If you spotted it first, help us to smash it by providing a detailed and welcomed
109+
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi_auth_partner%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
110+
111+
Do not contact contributors directly about support or help with technical issues.
112+
113+
Credits
114+
=======
115+
116+
Authors
117+
-------
118+
119+
* Akretion
120+
121+
Contributors
122+
------------
123+
124+
- `Akretion <https://www.akretion.com>`__:
125+
126+
- Sébastien Beau
127+
- Florian Mounier
128+
129+
Maintainers
130+
-----------
131+
132+
This module is maintained by the OCA.
133+
134+
.. image:: https://odoo-community.org/logo.png
135+
:alt: Odoo Community Association
136+
:target: https://odoo-community.org
137+
138+
OCA, or the Odoo Community Association, is a nonprofit organization whose
139+
mission is to support the collaborative development of Odoo features and
140+
promote its widespread use.
141+
142+
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/18.0/fastapi_auth_partner>`_ project on GitHub.
143+
144+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

fastapi_auth_partner/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from . import models
2+
from . import routers
3+
from . import schemas
4+
from . import wizards
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2024 Akretion (http://www.akretion.com).
2+
# @author Sébastien BEAU <sebastien.beau@akretion.com>
3+
# @author Florian Mounier <florian.mounier@akretion.com>
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
5+
6+
{
7+
"name": "Fastapi Auth Partner",
8+
"summary": """This provides an implementation of auth_partner for FastAPI""",
9+
"version": "18.0.1.0.0",
10+
"license": "AGPL-3",
11+
"author": "Akretion,Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/rest-framework",
13+
"depends": [
14+
"extendable_fastapi",
15+
"auth_partner",
16+
],
17+
"data": [
18+
"security/res_group.xml",
19+
"security/ir_rule.xml",
20+
"security/ir.model.access.csv",
21+
"views/auth_partner_view.xml",
22+
"views/auth_directory_view.xml",
23+
"views/fastapi_endpoint_view.xml",
24+
"wizards/wizard_auth_partner_impersonate_view.xml",
25+
"wizards/wizard_auth_partner_reset_password_view.xml",
26+
],
27+
"demo": [
28+
"demo/fastapi_endpoint_demo.xml",
29+
],
30+
"external_dependencies": {
31+
"python": ["itsdangerous"],
32+
},
33+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record model="fastapi.endpoint" id="fastapi_endpoint_demo">
4+
<field name="name">Fastapi Auth Partner Demo Endpoint</field>
5+
<field
6+
name="description"
7+
><![CDATA[
8+
# A Dummy FastApi Partner Auth Demo
9+
10+
This demo endpoint has been created by inhering from "fastapi.endpoint", registering
11+
a new app into the app selection field and implementing the `_get_fastapi_routers`
12+
methods. See documentation to learn more about how to create a new app.
13+
]]></field>
14+
<field name="app">demo</field>
15+
<field name="root_path">/fastapi_auth_partner_demo</field>
16+
<field name="demo_auth_method">auth_partner</field>
17+
<field name="user_id" ref="fastapi.my_demo_app_user" />
18+
<field name="directory_id" ref="auth_partner.demo_directory" />
19+
<field name="public_api_url">https://api.example.com/</field>
20+
<field name="public_url">https://www.example.com/</field>
21+
</record>
22+
23+
<record id="fastapi.my_demo_app_user" model="res.users">
24+
<field
25+
name="groups_id"
26+
eval="[(4, ref('auth_partner.group_auth_partner_api'))]"
27+
/>
28+
</record>
29+
</odoo>

0 commit comments

Comments
 (0)