Metadata-Version: 2.1
Name: odoo-addon-shopinvader_fastapi_auth_jwt
Version: 16.0.1.0.3
Summary: Provide JWT and Anonymous Partner authentication to FastAPI routes.
Home-page: https://github.com/shopinvader/odoo-shopinvader
Author: ACSONE SA/NV
License: LGPL-3
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 16.0
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Requires-Python: >=3.10
Requires-Dist: odoo-addon-fastapi-auth-jwt<16.1dev,>=16.0dev
Requires-Dist: odoo-addon-shopinvader-anonymous-partner<16.1dev,>=16.0dev
Requires-Dist: odoo<16.1dev,>=16.0a

=========================================================
Shopinvader Auth JWT authentication for FastAPI endpoints
=========================================================

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

.. |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/licence-LGPL--3-blue.png
    :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
    :alt: License: LGPL-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_jwt
    :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 no 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 validator (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_jwt%0Aversion:%2016.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
~~~~~~~

* ACSONE SA/NV

Maintainers
~~~~~~~~~~~

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

You are welcome to contribute.
