Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[apikey_scope_editable](apikey_scope_editable/) | 17.0.1.0.0 | | Set the API Key scope at creation
[auth_admin_passkey](auth_admin_passkey/) | 17.0.1.0.0 | | Allows system administrator to authenticate with any account
[auth_admin_passkey_totp_mail_enforce](auth_admin_passkey_totp_mail_enforce/) | 17.0.1.0.0 | | Disable 2FA if Passkey is being used
[auth_api_key](auth_api_key/) | 17.0.1.1.2 | | Authenticate http requests from an API key
Expand Down
99 changes: 99 additions & 0 deletions apikey_scope_editable/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================
API Key Scope Editable
======================

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

.. |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/license-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-OCA%2Fserver--auth-lightgray.png?logo=github
:target: https://github.com/OCA/server-auth/tree/17.0/apikey_scope_editable
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-apikey_scope_editable
: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/server-auth&target_branch=17.0
:alt: Try me on Runboat

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

This module extends the built-in `Odoo API
Keys <https://www.odoo.com/documentation/17.0/developer/reference/external_api.html#api-keys>`__
by allowing you to define a scope at the moment of creation.

With scopes, you can restrict an API Key so that it only grants access
to a specific application, model, or functional area of the system.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Click on your user icon and then "Preferences"
2. Go to the "Account Security" tab, and then click the "New Api Key"
button.
3. Fill the data, a new field will appear to set the key scope.

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

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

This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/apikey_scope_editable>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions apikey_scope_editable/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import wizards
19 changes: 19 additions & 0 deletions apikey_scope_editable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Alberto Martínez <alberto.martinez@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "API Key Scope Editable",
"summary": "Set the API Key scope at creation",
"version": "17.0.1.0.0",
"category": "Technical",
"website": "https://github.com/OCA/server-auth",
"author": "Sygel, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"base",
],
"data": [
"wizards/res_users_apikeys_description_views.xml",
],
}
71 changes: 71 additions & 0 deletions apikey_scope_editable/i18n/apikey_scope_editable.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * apikey_scope_editable
#
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: apikey_scope_editable
#: model:ir.model,name:apikey_scope_editable.model_res_users_apikeys_description
msgid "API Key Description"
msgstr ""

#. module: apikey_scope_editable
#: model_terms:ir.ui.view,arch_db:apikey_scope_editable.form_res_users_key_description
msgid "APIKey scope:"
msgstr ""

#. module: apikey_scope_editable
#: model:ir.model.fields,field_description:apikey_scope_editable.field_res_users_apikeys_description__custom_scope
msgid "Custom Scope"
msgstr ""

#. module: apikey_scope_editable
#: model_terms:ir.ui.view,arch_db:apikey_scope_editable.form_res_users_key_description
msgid ""
"Enter the optional scope for the key. If set, the key access would be "
"restricted."
msgstr ""

#. module: apikey_scope_editable
#: model:ir.model.fields,field_description:apikey_scope_editable.field_res_users_apikeys_description__has_custom_scope
msgid "Has Custom Scope"
msgstr ""

#. module: apikey_scope_editable
#: model_terms:ir.ui.view,arch_db:apikey_scope_editable.form_res_users_key_description
msgid "I want a custom scope"
msgstr ""

#. module: apikey_scope_editable
#: model_terms:ir.ui.view,arch_db:apikey_scope_editable.form_res_users_key_description
msgid "No scope"
msgstr ""

#. module: apikey_scope_editable
#: model:ir.model.fields,field_description:apikey_scope_editable.field_res_users_apikeys_description__scope
msgid "Scope"
msgstr ""

#. module: apikey_scope_editable
#: model:ir.model,name:apikey_scope_editable.model_res_users_apikeys
msgid "Users API Keys"
msgstr ""

#. module: apikey_scope_editable
#: model_terms:ir.ui.view,arch_db:apikey_scope_editable.form_res_users_key_description
msgid "What's the key scope?"
msgstr ""

#. module: apikey_scope_editable
#: model:ir.model.fields.selection,name:apikey_scope_editable.selection__res_users_apikeys_description__scope__rpc
msgid "rpc"
msgstr ""
3 changes: 3 additions & 0 deletions apikey_scope_editable/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import res_users_apikeys
13 changes: 13 additions & 0 deletions apikey_scope_editable/models/res_users_apikeys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2025 Alberto Martínez <alberto.martinez@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class APIKeys(models.Model):
_inherit = "res.users.apikeys"

def _generate(self, scope, name):
new_scope = self.env.context.get("apikey_scope")
scope = new_scope if new_scope else scope
return super()._generate(scope, name)
3 changes: 3 additions & 0 deletions apikey_scope_editable/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions apikey_scope_editable/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Sygel](https://www.sygel.es):
- Alberto Martínez
- Valentin Vinagre
- Harald Panten
3 changes: 3 additions & 0 deletions apikey_scope_editable/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module extends the built-in [Odoo API Keys](https://www.odoo.com/documentation/17.0/developer/reference/external_api.html#api-keys) by allowing you to define a scope at the moment of creation.

With scopes, you can restrict an API Key so that it only grants access to a specific application, model, or functional area of the system.
5 changes: 5 additions & 0 deletions apikey_scope_editable/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

1. Click on your user icon and then "Preferences"
2. Go to the "Account Security" tab, and then click the "New Api Key" button.
3. Fill the data, a new field will appear to set the key scope.
Binary file added apikey_scope_editable/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.
79 changes: 79 additions & 0 deletions apikey_scope_editable/static/description/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading