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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[auth_api_key](auth_api_key/) | 19.0.1.0.3 | | Authenticate http requests from an API key
[auth_api_key](auth_api_key/) | 19.0.1.1.0 | | Authenticate http requests from an API key
[auth_api_key_group](auth_api_key_group/) | 19.0.1.0.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Allow grouping API keys together. Grouping per se does nothing. This feature is supposed to be used by other modules to limit access to services or records based on groups of keys.
[auth_oauth_multi_token](auth_oauth_multi_token/) | 19.0.1.0.0 | | Allow multiple connection with the same OAuth account
[auth_oidc](auth_oidc/) | 19.0.1.0.0 | <a href='https://github.com/sbidoul'><img src='https://github.com/sbidoul.png' width='32' height='32' style='border-radius:50%;' alt='sbidoul'/></a> | Allow users to login through OpenID Connect Provider
Expand Down
7 changes: 6 additions & 1 deletion auth_api_key/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Auth Api Key
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:13e40ab685d9417f6461852e3c3c37fec5967c3a7a956fdb54b3fcc5f1b42115
!! source digest: sha256:e7679893d3301998264999e637352ed54ac21f411be14f01b7f8b2ab102b3b50
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down Expand Up @@ -70,6 +70,11 @@ The api key menu is available into Settings > Technical in debug mode.
By default, when you create an API key, the key is saved into the
database.

When you create an API key, a random key is generated automatically. You
can replace it manually, or use the Generate Random Token button if an
existing record has no key. The key field is masked by default, and the
password widget provides a button to reveal the value when needed.

When a database is neutralized, stored API key values are cleared.

If you want to manage them via serve environment settings use
Expand Down
2 changes: 1 addition & 1 deletion auth_api_key/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Auth Api Key",
"summary": """
Authenticate http requests from an API key""",
"version": "19.0.1.0.3",
"version": "19.0.1.1.0",
"license": "LGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-auth",
Expand Down
5 changes: 5 additions & 0 deletions auth_api_key/i18n/auth_api_key.pot
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ msgstr ""
msgid "Display Name"
msgstr ""

#. module: auth_api_key
#: model_terms:ir.ui.view,arch_db:auth_api_key.auth_api_key_form_view
msgid "Generate Random Token"
msgstr ""

#. module: auth_api_key
#: model:ir.model,name:auth_api_key.model_ir_http
msgid "HTTP Routing"
Expand Down
7 changes: 6 additions & 1 deletion auth_api_key/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2026-07-20 08:46+0000\n"
"PO-Revision-Date: 2026-07-27 11:46+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
Expand Down Expand Up @@ -81,6 +81,11 @@ msgstr "Disabilita la chiave API quando si archivia un utente"
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: auth_api_key
#: model_terms:ir.ui.view,arch_db:auth_api_key.auth_api_key_form_view
msgid "Generate Random Token"
msgstr "Genera token casuale"

#. module: auth_api_key
#: model:ir.model,name:auth_api_key.model_ir_http
msgid "HTTP Routing"
Expand Down
5 changes: 5 additions & 0 deletions auth_api_key/i18n/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ msgstr ""
msgid "Display Name"
msgstr ""

#. module: auth_api_key
#: model_terms:ir.ui.view,arch_db:auth_api_key.auth_api_key_form_view
msgid "Generate Random Token"
msgstr ""

#. module: auth_api_key
#: model:ir.model,name:auth_api_key.model_ir_http
msgid "HTTP Routing"
Expand Down
5 changes: 5 additions & 0 deletions auth_api_key/i18n/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ msgstr ""
msgid "Display Name"
msgstr ""

#. module: auth_api_key
#: model_terms:ir.ui.view,arch_db:auth_api_key.auth_api_key_form_view
msgid "Generate Random Token"
msgstr ""

#. module: auth_api_key
#: model:ir.model,name:auth_api_key.model_ir_http
msgid "HTTP Routing"
Expand Down
25 changes: 25 additions & 0 deletions auth_api_key/models/auth_api_key.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2018 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import secrets

from odoo import api, fields, models, tools
from odoo.exceptions import AccessError, ValidationError
from odoo.tools import consteq
Expand All @@ -12,6 +14,7 @@ class AuthApiKey(models.Model):

name = fields.Char(required=True)
key = fields.Char(
default=lambda self: self._generate_random_key_value(),
help="""The API key. Enter a dummy value in this field if it is
obtained from the server environment configuration.""",
)
Expand All @@ -36,6 +39,28 @@ def _check_key_required(self):
if not api_key.key:
raise ValidationError(self.env._("The API key is required."))

@api.model
def _generate_random_key_value(self):
"""Return a random API key value.

The token is generated by the Odoo server instance so XML data and the
UI button can create a secret without storing any default value in the
module sources.
"""
return secrets.token_urlsafe(32)

def generate_random_key(self, api_key_ids=None):
"""Generate a key for records that do not have one yet.

:param list api_key_ids: optional record IDs, mainly used by XML data
function calls where the method is invoked on the model.
:return: True when the operation completed.
"""
api_keys = self.browse(api_key_ids) if api_key_ids else self
for api_key in api_keys.filtered(lambda record: not record.key):
api_key.key = api_key._generate_random_key_value()
return True

@api.model
def _retrieve_api_key(self, key):
return self.browse(self._retrieve_api_key_id(key))
Expand Down
5 changes: 5 additions & 0 deletions auth_api_key/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ The api key menu is available into Settings \> Technical in debug mode.
By default, when you create an API key, the key is saved into the
database.

When you create an API key, a random key is generated automatically. You
can replace it manually, or use the Generate Random Token button if an
existing record has no key. The key field is masked by default, and the
password widget provides a button to reveal the value when needed.

When a database is neutralized, stored API key values are cleared.

If you want to manage them via serve environment settings use
Expand Down
6 changes: 5 additions & 1 deletion auth_api_key/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Auth Api Key</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:13e40ab685d9417f6461852e3c3c37fec5967c3a7a956fdb54b3fcc5f1b42115
!! source digest: sha256:e7679893d3301998264999e637352ed54ac21f411be14f01b7f8b2ab102b3b50
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/19.0/auth_api_key"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Authenticate http requests from an API key.</p>
Expand Down Expand Up @@ -416,6 +416,10 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>The api key menu is available into Settings &gt; Technical in debug mode.
By default, when you create an API key, the key is saved into the
database.</p>
<p>When you create an API key, a random key is generated automatically. You
can replace it manually, or use the Generate Random Token button if an
existing record has no key. The key field is masked by default, and the
password widget provides a button to reveal the value when needed.</p>
<p>When a database is neutralized, stored API key values are cleared.</p>
<p>If you want to manage them via serve environment settings use
auth_api_key_server_env.</p>
Expand Down
19 changes: 19 additions & 0 deletions auth_api_key/tests/test_auth_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ def setUpClass(cls, *args, **kwargs):
{"name": "good", "user_id": cls.demo_user.id, "key": "api_key"}
)

def test_create_without_key_generates_random_key(self):
"""Test API key creation generates an API key when no key is provided."""
api_key = self.AuthApiKey.create(
{"name": "generated", "user_id": self.demo_user.id}
)
self.assertTrue(api_key.key)
self.assertEqual(
self.AuthApiKey._retrieve_uid_from_api_key(api_key.key),
self.demo_user.id,
)

def test_generate_random_key_keeps_existing_key(self):
"""Test random key generation does not overwrite an existing key."""
api_key = self.AuthApiKey.create(
{"name": "existing", "user_id": self.demo_user.id, "key": "existing_key"}
)
api_key.generate_random_key()
self.assertEqual(api_key.key, "existing_key")

def test_lookup_key_from_db(self):
demo_user = self.demo_user
self.assertEqual(
Expand Down
13 changes: 12 additions & 1 deletion auth_api_key/views/auth_api_key.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@
</h1>
<group name="config" colspan="4" col="4">
<field name="user_id" colspan="4" />
<field name="key" colspan="4" password="True" />
<label for="key" />
<div class="o_row" colspan="3">
<!-- The password widget masks the key and provides a reveal button. -->
<field name="key" widget="password" required="1" />
<button
name="generate_random_key"
string="Generate Random Token"
type="object"
class="btn-secondary"
invisible="key"
/>
</div>
</group>
</sheet>
</form>
Expand Down
15 changes: 8 additions & 7 deletions auth_session_timeout/i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,32 @@ msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 11:14+0000\n"
"PO-Revision-Date: 2015-09-24 11:47+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"PO-Revision-Date: 2026-07-25 09:46+0000\n"
"Last-Translator: Matjaz Mozetic <matjaz@luxim.si>\n"
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-server-tools-8-0/"
"language/sl/)\n"
"Language: sl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
"%100==4 ? 2 : 3);\n"
"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || "
"n%100==4 ? 2 : 3;\n"
"X-Generator: Weblate 5.15.2\n"

#. module: auth_session_timeout
#: model:ir.model,name:auth_session_timeout.model_ir_http
msgid "HTTP Routing"
msgstr ""
msgstr "HTTP usmerjanje"

#. module: auth_session_timeout
#: model:ir.model,name:auth_session_timeout.model_ir_config_parameter
msgid "System Parameter"
msgstr ""
msgstr "Sistemski parameter"

#. module: auth_session_timeout
#: model:ir.model,name:auth_session_timeout.model_res_users
msgid "User"
msgstr ""
msgstr "Uporabnik"

#~ msgid "Users"
#~ msgstr "Uporabniki"
16 changes: 9 additions & 7 deletions auth_user_case_insensitive/i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,39 @@ msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-17 21:08+0000\n"
"PO-Revision-Date: 2017-05-17 21:08+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"PO-Revision-Date: 2026-07-25 09:46+0000\n"
"Last-Translator: Matjaz Mozetic <matjaz@luxim.si>\n"
"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n"
"Language: sl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
"%100==4 ? 2 : 3);\n"
"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || "
"n%100==4 ? 2 : 3;\n"
"X-Generator: Weblate 5.15.2\n"

#. module: auth_user_case_insensitive
#. odoo-python
#: code:addons/auth_user_case_insensitive/hooks.py:0
#, python-format
msgid "Conflicting user logins exist for `%s`"
msgstr ""
msgstr "Za `%s` obstajajo konfliktne uporabniške prijave"

#. module: auth_user_case_insensitive
#: model:ir.model.fields,field_description:auth_user_case_insensitive.field_res_users__login
msgid "Login"
msgstr ""
msgstr "Prijava"

#. module: auth_user_case_insensitive
#: model:ir.model.fields,help:auth_user_case_insensitive.field_res_users__login
msgid "Used to log into the system. Case insensitive."
msgstr ""
"Uporablja se za prijavo v sistem. Ne razlikuje med velikimi in malimi črkami."

#. module: auth_user_case_insensitive
#: model:ir.model,name:auth_user_case_insensitive.model_res_users
msgid "User"
msgstr ""
msgstr "Uporabnik"

#~ msgid "Users"
#~ msgstr "Uporabniki"
Loading