|
| 1 | +==================== |
| 2 | +Fastapi Auth API Key |
| 3 | +==================== |
| 4 | + |
| 5 | +.. |
| 6 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 7 | + !! This file is generated by oca-gen-addon-readme !! |
| 8 | + !! changes will be overwritten. !! |
| 9 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 10 | + !! source digest: sha256:a1a8681b1c3e7a13dc83e2e61a1d78ad8c8da1ddb684c8cf563607e96cf4f7e7 |
| 11 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 12 | +
|
| 13 | +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png |
| 14 | + :target: https://odoo-community.org/page/development-status |
| 15 | + :alt: Beta |
| 16 | +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png |
| 17 | + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
| 18 | + :alt: License: AGPL-3 |
| 19 | +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github |
| 20 | + :target: https://github.com/OCA/rest-framework/tree/18.0/fastapi_auth_api_key |
| 21 | + :alt: OCA/rest-framework |
| 22 | +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
| 23 | + :target: https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-fastapi_auth_api_key |
| 24 | + :alt: Translate me on Weblate |
| 25 | +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png |
| 26 | + :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=18.0 |
| 27 | + :alt: Try me on Runboat |
| 28 | + |
| 29 | +|badge1| |badge2| |badge3| |badge4| |badge5| |
| 30 | + |
| 31 | +Provides FastAPI dependencies for Api Key authentication. |
| 32 | + |
| 33 | +**Table of contents** |
| 34 | + |
| 35 | +.. contents:: |
| 36 | + :local: |
| 37 | + |
| 38 | +Usage |
| 39 | +===== |
| 40 | + |
| 41 | +Getting an odoo environment |
| 42 | +--------------------------- |
| 43 | + |
| 44 | +If you need to get an odoo env based on the provided api key, you can |
| 45 | +use authenticated_env_by_auth_api_key. |
| 46 | + |
| 47 | +.. code:: python |
| 48 | +
|
| 49 | + @router.get("/example_with_authenticated_env") |
| 50 | + def example_with_authenticated_env( |
| 51 | + env: Annotated[Environment, Depends(authenticated_env_by_auth_api_key)], |
| 52 | + ) -> None: |
| 53 | + # env.user is the user attached to the provided key |
| 54 | + pass |
| 55 | +
|
| 56 | +Getting the authenticated partner |
| 57 | +--------------------------------- |
| 58 | + |
| 59 | +If want to get the partned related to the the provided api key, you can |
| 60 | +use authenticated_partner_by_api_key |
| 61 | + |
| 62 | +.. code:: python |
| 63 | +
|
| 64 | + @router.get("/example_with_authenticated_partner") |
| 65 | + def example_with_authenticated_partner( |
| 66 | + partner: Annotated[Partner, Depends(authenticated_partner_by_api_key)], |
| 67 | + ) -> None: |
| 68 | + # partner is the partner related to the provided key key.user_id.partner_id |
| 69 | + pass |
| 70 | +
|
| 71 | +Configuration |
| 72 | +------------- |
| 73 | + |
| 74 | +For this to work, the api key must be defined on the Endpoint. A new |
| 75 | +field auth_api_key_group_id has been added to the Endpoint model. |
| 76 | + |
| 77 | +Bug Tracker |
| 78 | +=========== |
| 79 | + |
| 80 | +Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_. |
| 81 | +In case of trouble, please check there if your issue has already been reported. |
| 82 | +If you spotted it first, help us to smash it by providing a detailed and welcomed |
| 83 | +`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi_auth_api_key%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
| 84 | + |
| 85 | +Do not contact contributors directly about support or help with technical issues. |
| 86 | + |
| 87 | +Credits |
| 88 | +======= |
| 89 | + |
| 90 | +Authors |
| 91 | +------- |
| 92 | + |
| 93 | +* Camptocamp |
| 94 | + |
| 95 | +Contributors |
| 96 | +------------ |
| 97 | + |
| 98 | +- Matthieu Méquignon <matthieu.mequignon@camptocamp.com> |
| 99 | +- Son Ho <sonhd@trobz.com> |
| 100 | + |
| 101 | +Other credits |
| 102 | +------------- |
| 103 | + |
| 104 | +The migration of this module from 17.0 to 18.0 was financially supported |
| 105 | +by Camptocamp |
| 106 | + |
| 107 | +Maintainers |
| 108 | +----------- |
| 109 | + |
| 110 | +This module is maintained by the OCA. |
| 111 | + |
| 112 | +.. image:: https://odoo-community.org/logo.png |
| 113 | + :alt: Odoo Community Association |
| 114 | + :target: https://odoo-community.org |
| 115 | + |
| 116 | +OCA, or the Odoo Community Association, is a nonprofit organization whose |
| 117 | +mission is to support the collaborative development of Odoo features and |
| 118 | +promote its widespread use. |
| 119 | + |
| 120 | +.. |maintainer-mmequignon| image:: https://github.com/mmequignon.png?size=40px |
| 121 | + :target: https://github.com/mmequignon |
| 122 | + :alt: mmequignon |
| 123 | + |
| 124 | +Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: |
| 125 | + |
| 126 | +|maintainer-mmequignon| |
| 127 | + |
| 128 | +This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/18.0/fastapi_auth_api_key>`_ project on GitHub. |
| 129 | + |
| 130 | +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
0 commit comments