Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4031f95
Add endpoint_auth_api_key
simahawk Sep 24, 2021
0219476
[ADD] icon.png
OCA-git-bot Nov 2, 2021
bdcb591
endpoint_auth_api_key: add btn to manage groups
simahawk Nov 12, 2021
61c6d01
endpoint_auth_api_key: show group mgmt btn if needed
simahawk Dec 28, 2021
769d45f
endpoint_auth_api_key 14.0.1.1.0
OCA-git-bot Jan 12, 2022
6c2df40
Misc fix of authorship name
simahawk Jan 14, 2022
1743fcb
endpoint_auth_api_key 14.0.1.1.1
OCA-git-bot Jan 14, 2022
3182e67
[FIX] Fix access right issues when using actions
Jan 31, 2022
b49c2bb
endpoint_auth_api_key 14.0.1.1.2
OCA-git-bot Jan 31, 2022
73137a2
endpoint_auth_api_key: move to OCA/web-api
simahawk Aug 1, 2022
82ef342
endpoint_auth_api_key: adapt to new sync behavior
simahawk Feb 16, 2023
5ad379e
[MIG] endpoint_auth_api_key: Migrate to version 16.0
Dec 26, 2023
34bac5e
[UPD] Update endpoint_auth_api_key.pot
Mar 27, 2024
05be37b
Added translation using Weblate (Italian)
mymage Apr 2, 2024
e2eecda
Translated using Weblate (Italian)
mymage Apr 2, 2024
2e2af19
endpoint: add basic mixin view
simahawk Jul 23, 2024
2a7422f
[UPD] Update endpoint_auth_api_key.pot
Jul 26, 2024
3484345
[BOT] post-merge updates
OCA-git-bot Jul 26, 2024
28de82e
Update translation files
weblate Jul 26, 2024
02ae28b
endpoint_*: fix mixin view override
simahawk Aug 8, 2024
602d9e3
[BOT] post-merge updates
OCA-git-bot Aug 8, 2024
64a7da8
[IMP] endpoint_auth_api_key: pre-commit auto fixes
SilvioC2C Mar 18, 2025
69e6906
[MIG] endpoint_auth_api_key: Migrate to version 17.0
SilvioC2C Mar 18, 2025
5a7b8b8
[UPD] Update endpoint_auth_api_key.pot
Mar 19, 2025
14b810b
[BOT] post-merge updates
OCA-git-bot Mar 19, 2025
0f97483
Added translation using Weblate (Chinese (Simplified) (zh_CN))
xtanuiha Apr 4, 2025
0f4e39d
Translated using Weblate (Chinese (Simplified) (zh_CN))
xtanuiha Apr 4, 2025
6ff6429
[IMP] endpoint_auth_api_key: pre-commit auto fixes
simahawk Jun 9, 2025
4b9f220
endpoint_auth_api_key: migrate to v18
simahawk Jun 9, 2025
f782f55
endpoint_auth_api_key: mute http logger to avoid warning
simahawk Jun 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions endpoint_auth_api_key/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
=====================
Endpoint Auth API key
=====================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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-OCA%2Fweb--api-lightgray.png?logo=github
:target: https://github.com/OCA/web-api/tree/17.0/endpoint_auth_api_key
:alt: OCA/web-api
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-api-17-0/web-api-17-0-endpoint_auth_api_key
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web-api&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Provide API key auth for endpoints.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web-api/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/OCA/web-api/issues/new?body=module:%20endpoint_auth_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
-------

* Camptocamp

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

- Simone Orsi <simone.orsi@camptocamp.com>

- `Trobz <https://trobz.com>`__:

- Son Ho <sonhd@trobz.com>

Other credits
-------------

The migration of this module from 14.0 to 16.0 was financially supported
by Camptocamp

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px
:target: https://github.com/simahawk
:alt: simahawk

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-simahawk|

This module is part of the `OCA/web-api <https://github.com/OCA/web-api/tree/17.0/endpoint_auth_api_key>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions endpoint_auth_api_key/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions endpoint_auth_api_key/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Endpoint Auth API key",
"summary": """Provide API key auth for endpoints.""",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"development_status": "Alpha",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"website": "https://github.com/OCA/web-api",
"depends": ["endpoint", "auth_api_key_group"],
"demo": ["demo/api_key_demo.xml", "demo/endpoint_demo.xml"],
"data": ["views/endpoint_view.xml"],
}
20 changes: 20 additions & 0 deletions endpoint_auth_api_key/demo/api_key_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="auth_api_key_demo" model="auth.api.key">
<field name="name">Endpoint API key demo</field>
<field name="key">cZ6dF2UQwNcm</field>
<field name="user_id" ref="base.user_demo" />
</record>

<record id="auth_api_key_demo2" model="auth.api.key">
<field name="name">Endpoint API key demo 2</field>
<field name="key">kV47QyOTC5mS</field>
<field name="user_id" ref="base.user_demo" />
</record>

<record id="auth_api_key_group_demo" model="auth.api.key.group">
<field name="name">Demo Group 1</field>
<field name="code">demo_group1</field>
<field name="auth_api_key_ids" eval="[(4, ref('auth_api_key_demo'))]" />
</record>
</odoo>
17 changes: 17 additions & 0 deletions endpoint_auth_api_key/demo/endpoint_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="endpoint_demo_1" model="endpoint.endpoint">
<field name="name">Demo Endpoint - auth api key</field>
<field name="route">/demo/api/key</field>
<field name="request_method">GET</field>
<field name="auth_type">api_key</field>
<field
name="auth_api_key_group_ids"
eval="[(4, ref('auth_api_key_group_demo'))]"
/>
<field name="exec_mode">code</field>
<field name="code_snippet">
result = {"response": Response("ok")}
</field>
</record>
</odoo>
30 changes: 30 additions & 0 deletions endpoint_auth_api_key/i18n/endpoint_auth_api_key.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * endpoint_auth_api_key
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: endpoint_auth_api_key
#: model:ir.model.fields,field_description:endpoint_auth_api_key.field_endpoint_endpoint__auth_api_key_group_ids
#: model:ir.model.fields,field_description:endpoint_auth_api_key.field_endpoint_mixin__auth_api_key_group_ids
msgid "Allowed API key groups"
msgstr ""

#. module: endpoint_auth_api_key
#: model:ir.model,name:endpoint_auth_api_key.model_endpoint_mixin
msgid "Endpoint mixin"
msgstr ""

#. module: endpoint_auth_api_key
#: model_terms:ir.ui.view,arch_db:endpoint_auth_api_key.endpoint_mixin_form_view
msgid "Manage groups"
msgstr ""
33 changes: 33 additions & 0 deletions endpoint_auth_api_key/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * endpoint_auth_api_key
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-04-02 12:35+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: endpoint_auth_api_key
#: model:ir.model.fields,field_description:endpoint_auth_api_key.field_endpoint_endpoint__auth_api_key_group_ids
#: model:ir.model.fields,field_description:endpoint_auth_api_key.field_endpoint_mixin__auth_api_key_group_ids
msgid "Allowed API key groups"
msgstr "Consenti gruppi chiavi API"

#. module: endpoint_auth_api_key
#: model:ir.model,name:endpoint_auth_api_key.model_endpoint_mixin
msgid "Endpoint mixin"
msgstr "Mixin endpoint"

#. module: endpoint_auth_api_key
#: model_terms:ir.ui.view,arch_db:endpoint_auth_api_key.endpoint_mixin_form_view
msgid "Manage groups"
msgstr "Gestione gruppi"
33 changes: 33 additions & 0 deletions endpoint_auth_api_key/i18n/zh_CN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * endpoint_auth_api_key
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-04-04 06:06+0000\n"
"Last-Translator: xtanuiha <feihu.zhang@live.com>\n"
"Language-Team: none\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 5.10.2\n"

#. module: endpoint_auth_api_key
#: model:ir.model.fields,field_description:endpoint_auth_api_key.field_endpoint_endpoint__auth_api_key_group_ids
#: model:ir.model.fields,field_description:endpoint_auth_api_key.field_endpoint_mixin__auth_api_key_group_ids
msgid "Allowed API key groups"
msgstr "允许的API密钥组"

#. module: endpoint_auth_api_key
#: model:ir.model,name:endpoint_auth_api_key.model_endpoint_mixin
msgid "Endpoint mixin"
msgstr "端点混入类"

#. module: endpoint_auth_api_key
#: model_terms:ir.ui.view,arch_db:endpoint_auth_api_key.endpoint_mixin_form_view
msgid "Manage groups"
msgstr "管理组"
1 change: 1 addition & 0 deletions endpoint_auth_api_key/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import endpoint_mixin
40 changes: 40 additions & 0 deletions endpoint_auth_api_key/models/endpoint_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2021 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import werkzeug

from odoo import fields, models


class EndpointMixin(models.AbstractModel):
_inherit = "endpoint.mixin"

auth_api_key_group_ids = fields.Many2many(
comodel_name="auth.api.key.group",
string="Allowed API key groups",
)

def _selection_auth_type(self):
return super()._selection_auth_type() + [("api_key", "API key")]

def _validate_request(self, request):
super()._validate_request(request)
if self.auth_type == "api_key":
self._validate_api_key(request)
return

def _validate_api_key(self, request):
key_id = request.auth_api_key_id
if key_id not in self._allowed_api_key_ids():
self._logger.error("API key %s not allowed on %s", key_id, self.route)
raise werkzeug.exceptions.Forbidden()

def _allowed_api_key_ids(self):
return self.auth_api_key_group_ids.auth_api_key_ids.ids

def action_view_api_key_groups(self):
xmlid = "auth_api_key_group.auth_api_key_group_act_window"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action["domain"] = [("id", "in", self.auth_api_key_group_ids.ids)]
return action
3 changes: 3 additions & 0 deletions endpoint_auth_api_key/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions endpoint_auth_api_key/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Simone Orsi \<<simone.orsi@camptocamp.com>\>

- [Trobz](https://trobz.com):

> - Son Ho \<<sonhd@trobz.com>\>
2 changes: 2 additions & 0 deletions endpoint_auth_api_key/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The migration of this module from 14.0 to 16.0 was financially supported
by Camptocamp
1 change: 1 addition & 0 deletions endpoint_auth_api_key/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide API key auth for endpoints.
Binary file added endpoint_auth_api_key/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading