Metadata-Version: 2.1
Name: odoo-addon-shopinvader_fastapi_auth_partner
Version: 18.0.1.0.0.2
Requires-Python: >=3.10
Requires-Dist: odoo-addon-fastapi_auth_partner==18.0.*
Requires-Dist: odoo-addon-shopinvader_anonymous_partner==18.0.*
Requires-Dist: odoo==18.0.*
Summary: Provide Partner and Anonymous Partner authentication to FastAPI routes.
Home-page: https://github.com/shopinvader/odoo-shopinvader
License: AGPL-3
Author: Akretion
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 18.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

=============================================================
Shopinvader Auth Partner authentication for FastAPI endpoints
=============================================================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:bcadc4542cd5ecb27161416865070707b5aa0979bb98b666239934c48db1390e
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
    :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/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.

**Table of contents**

.. contents::
   :local:

Usage
=====

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``.

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:%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/18.0/shopinvader_fastapi_auth_partner>`_ project on GitHub.

You are welcome to contribute.
