Auhentication for FastApi using Odoo's built in apikeys
Project description
This module provides FastAPI Depends to allow authentication with Odoo’s API Keys.
Table of contents
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. 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.
Do not contact contributors directly about support or help with technical issues.
Credits
Contributors
-
Alberto Martínez
Valentin Vinagre
Harald Panten
Maintainers
This module is part of the sygel-technology/sy-rest-framework project on GitHub.
You are welcome to contribute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odoo_addon_fastapi_auth_odoo_api_key-17.0.1.0.0.1-py3-none-any.whl.
File metadata
- Download URL: odoo_addon_fastapi_auth_odoo_api_key-17.0.1.0.0.1-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0b0a8b05eef4253c06f479b56c4aeaa8896f327ccbbae5faf5c253e757df627
|
|
| MD5 |
5ad6b58b070c0cd94330f62eca17bb5c
|
|
| BLAKE2b-256 |
c9932acb0a15ea3f2ddf8ef9b3b5fae0955b9aa514f320e1df2efad3c1b203d7
|