Metadata-Version: 2.1
Name: odoo-addon-fastapi_auth_odoo_api_key
Version: 17.0.1.1.0
Requires-Python: >=3.10
Requires-Dist: odoo-addon-apikey_scope_editable>=17.0dev,<17.1dev
Requires-Dist: odoo-addon-fastapi>=17.0dev,<17.1dev
Requires-Dist: odoo>=17.0a,<17.1dev
Summary: Auhentication for FastApi using Odoo's built in apikeys
Home-page: https://github.com/sygel-technology/sy-rest-framework
License: AGPL-3
Author: Sygel, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 17.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/x-rst

=========================
Fastapi Auth Odoo Api Key
=========================

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

.. |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-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-sygel--technology%2Fsy--rest--framework-lightgray.png?logo=github
    :target: https://github.com/sygel-technology/sy-rest-framework/tree/17.0/fastapi_auth_odoo_api_key
    :alt: sygel-technology/sy-rest-framework

|badge1| |badge2| |badge3|

This module provides ``FastAPI`` ``Depends`` to allow authentication
with `Odoo's API
Keys <https://www.odoo.com/documentation/master/developer/reference/external_api.html#api-keys>`__.

**Table of contents**

.. contents::
   :local:

Usage
=====

FastAPI API Key Dependencies
----------------------------

The following FastAPI dependencies are provided and importable from
``odoo.addons.fastapi_auth_odoo_api_key.dependencies``:

``def apikey_authenticated_partner_impl() -> Partner``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return the authenticated partner based on the provided API key. Raise a
401 (unauthorized) if the API key is invalid or the partner could not be
found. Also validates that the user associated with the API key matches
the endpoint’s expected user, if specified.

``def apikey_optionally_authenticated_partner_impl() -> Partner | None``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return the authenticated partner based on the provided API key, or an
empty recordset if the key is valid but doesn't match the expected user.
Returns ``None`` if authentication fails silently.

``def apikey_authenticated_partner_env() -> Environment``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return an Odoo environment bound to the authenticated partner. The
partner must be authenticated using
``apikey_authenticated_partner_impl``. Raise a 401 if authentication
fails.

``def apikey_authenticated_partner() -> Partner``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return the authenticated partner bound to the correct Odoo environment.
This function uses the partner returned by
``apikey_authenticated_partner_impl`` and binds it to the environment
returned by ``apikey_authenticated_partner_env``.

``def apikey_optionally_authenticated_partner_env() -> Environment``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return an Odoo environment bound to the optionally authenticated
partner, or a default environment if the partner could not be
authenticated.

``def optionally_authenticated_partner() -> Partner | None``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return the optionally authenticated partner bound to the appropriate
environment, or ``None`` if no valid API key was provided.

Known issues / Roadmap
======================

- Unit tests of the connection and authorization should be added

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/sygel-technology/sy-rest-framework/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/sygel-technology/sy-rest-framework/issues/new?body=module:%20fastapi_auth_odoo_api_key%0Aversion:%2017.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
-------

* Sygel

Contributors
------------

- `Sygel <https://www.sygel.es>`__:

  - Alberto Martínez
  - Valentin Vinagre
  - Harald Panten

Maintainers
-----------

This module is part of the `sygel-technology/sy-rest-framework <https://github.com/sygel-technology/sy-rest-framework/tree/17.0/fastapi_auth_odoo_api_key>`_ project on GitHub.

You are welcome to contribute.
