Skip to main content

Auhentication for FastApi using Odoo's built in apikeys

Project description

Beta License: AGPL-3 sygel-technology/sy-rest-framework

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

Authors

  • Sygel

Contributors

  • Sygel:

    • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file odoo_addon_fastapi_auth_odoo_api_key-17.0.1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_addon_fastapi_auth_odoo_api_key-17.0.1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e2ea8bf58a40dbc602f724e6c9c1ed9b15051e26421a46ba24f2feadfccf807
MD5 cdf0b95e0414bc6d00ef13e2c3b8c6ec
BLAKE2b-256 f09a06dc827af55384f141e22f2b8dcf7c7848e31bd4d9e29b3baa6b28f79b14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page