Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ exclude: |
^shopinvader_api_wishlist/|
^shopinvader_delivery_state/|
^shopinvader_fastapi_auth_jwt/|
^shopinvader_fastapi_auth_partner/|
^shopinvader_sale_cart/|
^shopinvader_sale_cart_anonymous_partner/|
^shopinvader_sale_state/|
Expand Down
11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

45 changes: 24 additions & 21 deletions shopinvader_fastapi_auth_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ Shopinvader Auth Partner authentication for FastAPI endpoints
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github
:target: https://github.com/shopinvader/odoo-shopinvader/tree/16.0/shopinvader_fastapi_auth_partner
:target: https://github.com/shopinvader/odoo-shopinvader/tree/18.0/shopinvader_fastapi_auth_partner
:alt: shopinvader/odoo-shopinvader

|badge1| |badge2| |badge3|

This module provides the ``auth_jwt_authenticated_or_anonymous_partner`` and
``auth_jwt_authenticated_or_anonymous_partner_auto_create`` FastAPI dependencies.
This module provides the ``auth_jwt_authenticated_or_anonymous_partner``
and ``auth_jwt_authenticated_or_anonymous_partner_auto_create`` FastAPI
dependencies.

**Table of contents**

Expand All @@ -37,26 +38,28 @@ This module provide the following FastAPI dependencies:

``def auth_jwt_authenticated_or_anonymous_partner() -> Partner``

This dependency returns the authenticated partner from ``fast_api_auth_jwt``
``auth_jwt_optionally_authenticated_partner``. If not authenticated or no partner is
found, look for the ``shopinvader_anonymous_partner`` cookie in the request and return
the corresponding partner.
This dependency returns the authenticated partner from
``fast_api_auth_jwt`` ``auth_jwt_optionally_authenticated_partner``.
If not authenticated or no partner is found, look for the
``shopinvader_anonymous_partner`` cookie in the request and return
the corresponding partner.

If not partner is found, raise a 401 (unauthorized).
If not partner is found, raise a 401 (unauthorized).

``def auth_jwt_authenticated_or_anonymous_partner_auto_create() -> Partner``

This dependency returns the authenticated partner from ``fast_api_auth_jwt``
``auth_jwt_optionally_authenticated_partner``. If not authenticated or no partner is
found, look for the ``shopinvader_anonymous_partner`` cookie in the request and return
the corresponding partner.
This dependency returns the authenticated partner from
``fast_api_auth_jwt`` ``auth_jwt_optionally_authenticated_partner``.
If not authenticated or no partner is found, look for the
``shopinvader_anonymous_partner`` cookie in the request and return
the corresponding partner.

If no partner is found, create an anonymous partner, set the corresponding cookie and
return the newly created partner.
If no partner is found, create an anonymous partner, set the
corresponding cookie and return the newly created partner.

The record sets returned from these functions are bound either to the Odoo user defined
on the JWT validaator (if authenticated), or to the Odoo user defined on the FastAPI
endpoint.
The record sets returned from these functions are bound either to the
Odoo user defined on the JWT validaator (if authenticated), or to the
Odoo user defined on the FastAPI endpoint.

These dependencies are suitable and intended to override the
``odoo.addon.fastapi.dependencies.authenticated_partner_impl``.
Expand All @@ -67,21 +70,21 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/odoo-shopinvader/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/shopinvader/odoo-shopinvader/issues/new?body=module:%20shopinvader_fastapi_auth_partner%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/shopinvader/odoo-shopinvader/issues/new?body=module:%20shopinvader_fastapi_auth_partner%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~
-------

* Akretion

Maintainers
~~~~~~~~~~~
-----------

This module is part of the `shopinvader/odoo-shopinvader <https://github.com/shopinvader/odoo-shopinvader/tree/16.0/shopinvader_fastapi_auth_partner>`_ project on GitHub.
This module is part of the `shopinvader/odoo-shopinvader <https://github.com/shopinvader/odoo-shopinvader/tree/18.0/shopinvader_fastapi_auth_partner>`_ project on GitHub.

You are welcome to contribute.
14 changes: 8 additions & 6 deletions shopinvader_fastapi_auth_partner/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
{
"name": "Shopinvader Auth Partner authentication for FastAPI endpoints",
"summary": """
Provide Partner and Anonymous Partner authentication to FastAPI routes.""",
"version": "16.0.1.0.0",
Provide Partner and Anonymous Partner authentication to FastAPI routes.
""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Akretion",
"maintainers": [],
"website": "https://github.com/shopinvader/odoo-shopinvader",
"depends": ["fastapi_auth_partner", "shopinvader_anonymous_partner"],
"data": [],
"demo": [],
'installable': False,
"depends": [
"fastapi_auth_partner",
"shopinvader_anonymous_partner",
],
"installable": True,
}
7 changes: 1 addition & 6 deletions shopinvader_fastapi_auth_partner/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


import logging
import sys
from typing import Annotated

from fastapi import Depends, HTTPException, Request, Response, status

Expand All @@ -16,11 +16,6 @@
auth_partner_optionally_authenticated_partner,
)

if sys.version_info >= (3, 9):
from typing import Annotated
else:
from typing_extensions import Annotated

_logger = logging.getLogger(__name__)


Expand Down
3 changes: 3 additions & 0 deletions shopinvader_fastapi_auth_partner/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions shopinvader_fastapi_auth_partner/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module provides the `auth_jwt_authenticated_or_anonymous_partner`
and `auth_jwt_authenticated_or_anonymous_partner_auto_create` FastAPI
dependencies.
2 changes: 0 additions & 2 deletions shopinvader_fastapi_auth_partner/readme/DESCRIPTION.rst

This file was deleted.

29 changes: 29 additions & 0 deletions shopinvader_fastapi_auth_partner/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
This module provide the following FastAPI dependencies:

`def auth_jwt_authenticated_or_anonymous_partner() -> Partner`

> This dependency returns the authenticated partner from
> `fast_api_auth_jwt` `auth_jwt_optionally_authenticated_partner`. If
> not authenticated or no partner is found, look for the
> `shopinvader_anonymous_partner` cookie in the request and return the
> corresponding partner.
>
> If not partner is found, raise a 401 (unauthorized).

`def auth_jwt_authenticated_or_anonymous_partner_auto_create() -> Partner`

> This dependency returns the authenticated partner from
> `fast_api_auth_jwt` `auth_jwt_optionally_authenticated_partner`. If
> not authenticated or no partner is found, look for the
> `shopinvader_anonymous_partner` cookie in the request and return the
> corresponding partner.
>
> If no partner is found, create an anonymous partner, set the
> corresponding cookie and return the newly created partner.

The record sets returned from these functions are bound either to the
Odoo user defined on the JWT validaator (if authenticated), or to the
Odoo user defined on the FastAPI endpoint.

These dependencies are suitable and intended to override the
`odoo.addon.fastapi.dependencies.authenticated_partner_impl`.
27 changes: 0 additions & 27 deletions shopinvader_fastapi_auth_partner/readme/USAGE.rst

This file was deleted.

Loading
Loading