diff --git a/README.md b/README.md index e5e6468434..0a2f4cc066 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,13 @@ addon | version | maintainers | summary --- | --- | --- | --- [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.1 | | Authenticate http requests from an API key +[auth_api_key](auth_api_key/) | 17.0.1.1.2 | | Authenticate http requests from an API key [auth_api_key_group](auth_api_key_group/) | 17.0.1.0.1 | simahawk | 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_api_key_server_env](auth_api_key_server_env/) | 17.0.1.0.0 | | Configure api keys via server env. This can be very useful to avoid mixing your keys between your various environments when restoring databases. All you have to do is to add a new section to your configuration file according to the following convention: [auth_jwt](auth_jwt/) | 17.0.1.0.0 | sbidoul | JWT bearer token authentication. [auth_ldaps](auth_ldaps/) | 17.0.1.0.0 | | Allows to use LDAP over SSL authentication -[auth_oauth_multi_token](auth_oauth_multi_token/) | 17.0.1.0.0 | | Allow multiple connection with the same OAuth account +[auth_oauth_autologin](auth_oauth_autologin/) | 17.0.1.0.0 | sbidoul | Automatically redirect to the OAuth provider for login +[auth_oauth_multi_token](auth_oauth_multi_token/) | 17.0.1.1.1 | | Allow multiple connection with the same OAuth account [auth_oidc](auth_oidc/) | 17.0.1.1.0 | sbidoul | Allow users to login through OpenID Connect Provider [auth_saml](auth_saml/) | 17.0.1.0.3 | vincent-hatakeyama | SAML2 Authentication [auth_session_timeout](auth_session_timeout/) | 17.0.1.0.1 | | This module disable all inactive sessions since a given delay diff --git a/auth_api_key/README.rst b/auth_api_key/README.rst index 5914929d36..bb6b6a414c 100644 --- a/auth_api_key/README.rst +++ b/auth_api_key/README.rst @@ -1,3 +1,7 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + ============ Auth Api Key ============ @@ -7,13 +11,13 @@ Auth Api Key !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:ae78e8c4442001a4d138783fb1c46e4ad153932b5b8ca56333b08e21cdfbeaef + !! source digest: sha256:d0607031c656dbf2cfe791045d9458ad6601fbf39ccbeff50c72f9e5772db083 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status :alt: Production/Stable -.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/license-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%2Fserver--auth-lightgray.png?logo=github @@ -45,11 +49,11 @@ Odoo allows users to authenticate ``XMLRPC/JSONRPC`` calls using their API key instead of a password by native API keys (``res.users.apikey``). However, ``auth_api_key`` has some special features of its own such as: -- API keys remain usable even when the user is inactive, if enabled via - settings (e.g., for system users in a shopinvader case). -- Supports dual authentication via Basic Auth and API_KEY in separate - HTTP headers. -- Admins can manage API keys for all users +- API keys remain usable even when the user is inactive, if enabled via + settings (e.g., for system users in a shopinvader case). +- Supports dual authentication via Basic Auth and API_KEY in separate + HTTP headers. +- Admins can manage API keys for all users Given these advantages, particularly in use case like system user authentication, we have decided to keep the ``auth_api_key`` module @@ -105,11 +109,11 @@ Authors Contributors ------------ -- Denis Robinet -- Laurent Mignon -- Quentin Groulard -- Sébastien Beau -- Chafique Delli +- Denis Robinet +- Laurent Mignon +- Quentin Groulard +- Sébastien Beau +- Chafique Delli Maintainers ----------- diff --git a/auth_api_key/__manifest__.py b/auth_api_key/__manifest__.py index 2aca21667d..48a7139fa3 100644 --- a/auth_api_key/__manifest__.py +++ b/auth_api_key/__manifest__.py @@ -5,7 +5,7 @@ "name": "Auth Api Key", "summary": """ Authenticate http requests from an API key""", - "version": "17.0.1.1.1", + "version": "17.0.1.1.2", "license": "LGPL-3", "author": "ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/server-auth", diff --git a/auth_api_key/models/ir_http.py b/auth_api_key/models/ir_http.py index 7b02f0c39c..c4959103d0 100644 --- a/auth_api_key/models/ir_http.py +++ b/auth_api_key/models/ir_http.py @@ -5,8 +5,9 @@ import logging +from werkzeug.exceptions import Unauthorized + from odoo import models -from odoo.exceptions import AccessDenied from odoo.http import request _logger = logging.getLogger(__name__) @@ -33,4 +34,4 @@ def _auth_method_api_key(cls): request.auth_api_key_id = auth_api_key.id return True _logger.error("Wrong HTTP_API_KEY, access denied") - raise AccessDenied() + raise Unauthorized() diff --git a/auth_api_key/static/description/index.html b/auth_api_key/static/description/index.html index 278ee21300..927f8f7425 100644 --- a/auth_api_key/static/description/index.html +++ b/auth_api_key/static/description/index.html @@ -3,7 +3,7 @@ -Auth Api Key +README.rst -
-

Auth Api Key

+
+ + +Odoo Community Association + +
+

Auth Api Key

-

Production/Stable License: LGPL-3 OCA/server-auth Translate me on Weblate Try me on Runboat

+

Production/Stable License: LGPL-3 OCA/server-auth Translate me on Weblate Try me on Runboat

Authenticate http requests from an API key.

API keys are codes passed in (in the http header API-KEY) by programs calling an API in order to identify -in this case- the calling program’s @@ -406,7 +411,7 @@

Auth Api Key

-

Configuration

+

Configuration

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.

@@ -414,20 +419,20 @@

Configuration

auth_api_key_server_env.

-

Usage

+

Usage

To apply this authentication system to your http request you must set ‘api_key’ as value for the ‘auth’ parameter of your route definition into your controller.

-class MyController(Controller):
+class MyController(Controller):
 
     @route('/my_service', auth='api_key', ...)
-    def my_service(self, *args, **kwargs):
+    def my_service(self, *args, **kwargs):
         pass
 
-

Bug Tracker

+

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 @@ -435,15 +440,15 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • ACSONE SA/NV
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -466,5 +471,6 @@

Maintainers

+
diff --git a/auth_oauth_autologin/README.rst b/auth_oauth_autologin/README.rst new file mode 100644 index 0000000000..a04e1069c1 --- /dev/null +++ b/auth_oauth_autologin/README.rst @@ -0,0 +1,117 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +==================== +Auth Oauth Autologin +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:435818516444b963cf87e2c9fdb478ece9d33f578cde5960255b34cb5ffd84cd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/auth_oauth_autologin + :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-auth_oauth_autologin + :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 modules implements an automatic redirection to the configured OAuth +provider login page, if there is one and only one enabled. This +effectively makes the regular Odoo login screen invisible in normal +circumstances. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Configure OAuth providers in Settings > Users and Companies, and make +sure there is one and only one that has both the enabled and automatic +login flags set. + +When this is done, users visiting the login page (/web/login), or being +redirected to it because they are not authenticated yet, will be +redirected to the identity provider login page instead of the regular +Odoo login page. + +Be aware that this module does not actively prevent users from +authenticating with an login and password stored in the Odoo database. +In some unusual circumstances (such as identity provider errors), the +regular Odoo login may still be displayed. Securely disabling Odoo login +and password, if needed, should be the topic of another module. + +Also be aware that this has a possibly surprising effect on the logout +menu item. When the user logs out of Odoo, a redirect to the login page +happens. The login page in turn redirects to the identity provider, +which, if the user is already authenticated there, automatically logs +the user back in Odoo, in a fresh session. + +Usage +===== + +When configured, the Odoo login page redirects to the OAuth identify +provider for authentication and login in Odoo. To access the regular +Odoo login page, visit ``/web/login?no_autologin``. + +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 +------- + +* ACSONE SA/NV + +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-sbidoul| image:: https://github.com/sbidoul.png?size=40px + :target: https://github.com/sbidoul + :alt: sbidoul + +Current `maintainer `__: + +|maintainer-sbidoul| + +This module is part of the `OCA/server-auth `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auth_oauth_autologin/__init__.py b/auth_oauth_autologin/__init__.py new file mode 100644 index 0000000000..91c5580fed --- /dev/null +++ b/auth_oauth_autologin/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/auth_oauth_autologin/__manifest__.py b/auth_oauth_autologin/__manifest__.py new file mode 100644 index 0000000000..aefba6dc31 --- /dev/null +++ b/auth_oauth_autologin/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2021 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Auth Oauth Autologin", + "summary": """ + Automatically redirect to the OAuth provider for login""", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "maintainers": ["sbidoul"], + "website": "https://github.com/OCA/server-auth", + "depends": ["auth_oauth"], + "data": ["views/auth_oauth_provider.xml"], + "demo": [], + "assets": {"web.assets_frontend": ["auth_oauth_autologin/static/src/js/*.js"]}, +} diff --git a/auth_oauth_autologin/controllers/__init__.py b/auth_oauth_autologin/controllers/__init__.py new file mode 100644 index 0000000000..12a7e529b6 --- /dev/null +++ b/auth_oauth_autologin/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/auth_oauth_autologin/controllers/main.py b/auth_oauth_autologin/controllers/main.py new file mode 100644 index 0000000000..2bc8aafa61 --- /dev/null +++ b/auth_oauth_autologin/controllers/main.py @@ -0,0 +1,34 @@ +# Copyright 2021 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from urllib.parse import parse_qsl, urlparse + +from odoo import http +from odoo.http import request + +from odoo.addons.auth_oauth.controllers.main import OAuthLogin + + +class OAuthAutoLogin(OAuthLogin): + def _autologin_disabled(self, redirect): + url = urlparse(redirect) + params = dict(parse_qsl(url.query, keep_blank_values=True)) + return "no_autologin" in params or "oauth_error" in params or "error" in params + + def _autologin_link(self): + providers = [p for p in self.list_providers() if p.get("autologin")] + if len(providers) == 1: + return providers[0].get("auth_link") + + @http.route( + "/auth/auto_login_redirect_link", + type="json", + auth="none", + ) + def auto_login_redirect_link(self, *args, **kwargs): + redirect = kwargs.get("redirect") + if self._autologin_disabled(redirect): + return False + request.params["redirect"] = redirect + auth_link = self._autologin_link() + return auth_link diff --git a/auth_oauth_autologin/i18n/auth_oauth_autologin.pot b/auth_oauth_autologin/i18n/auth_oauth_autologin.pot new file mode 100644 index 0000000000..a5f8d1b71e --- /dev/null +++ b/auth_oauth_autologin/i18n/auth_oauth_autologin.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_oauth_autologin +# +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: auth_oauth_autologin +#: model:ir.model.fields,field_description:auth_oauth_autologin.field_auth_oauth_provider__autologin +msgid "Automatic Login" +msgstr "" + +#. module: auth_oauth_autologin +#: model:ir.model.fields,help:auth_oauth_autologin.field_auth_oauth_provider__autologin +msgid "" +"If exactly one enabled provider has this checked, the login screen redirects" +" to the OAuth provider." +msgstr "" + +#. module: auth_oauth_autologin +#: model:ir.model,name:auth_oauth_autologin.model_auth_oauth_provider +msgid "OAuth2 provider" +msgstr "" diff --git a/auth_oauth_autologin/i18n/it.po b/auth_oauth_autologin/i18n/it.po new file mode 100644 index 0000000000..139e57c479 --- /dev/null +++ b/auth_oauth_autologin/i18n/it.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_oauth_autologin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-06-17 08:26+0000\n" +"Last-Translator: mymage \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 5.10.4\n" + +#. module: auth_oauth_autologin +#: model:ir.model.fields,field_description:auth_oauth_autologin.field_auth_oauth_provider__autologin +msgid "Automatic Login" +msgstr "Accesso automatico" + +#. module: auth_oauth_autologin +#: model:ir.model.fields,help:auth_oauth_autologin.field_auth_oauth_provider__autologin +msgid "" +"If exactly one enabled provider has this checked, the login screen redirects" +" to the OAuth provider." +msgstr "" +"Se un solo provider abilitato ha selezionato questa opzione, la schermata di " +"accesso reindirizza al provider OAuth." + +#. module: auth_oauth_autologin +#: model:ir.model,name:auth_oauth_autologin.model_auth_oauth_provider +msgid "OAuth2 provider" +msgstr "Provider OAuth2" diff --git a/auth_oauth_autologin/models/__init__.py b/auth_oauth_autologin/models/__init__.py new file mode 100644 index 0000000000..4bc62d3ab5 --- /dev/null +++ b/auth_oauth_autologin/models/__init__.py @@ -0,0 +1 @@ +from . import auth_oauth_provider diff --git a/auth_oauth_autologin/models/auth_oauth_provider.py b/auth_oauth_autologin/models/auth_oauth_provider.py new file mode 100644 index 0000000000..6abefad5e9 --- /dev/null +++ b/auth_oauth_autologin/models/auth_oauth_provider.py @@ -0,0 +1,16 @@ +# Copyright 2021 ACSONE SA/NV +# License: AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class AuthOauthProvider(models.Model): + _inherit = "auth.oauth.provider" + + autologin = fields.Boolean( + string="Automatic Login", + help=( + "If exactly one enabled provider has this checked, " + "the login screen redirects to the OAuth provider." + ), + ) diff --git a/auth_oauth_autologin/pyproject.toml b/auth_oauth_autologin/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/auth_oauth_autologin/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/auth_oauth_autologin/readme/CONFIGURE.md b/auth_oauth_autologin/readme/CONFIGURE.md new file mode 100644 index 0000000000..7a720b57dc --- /dev/null +++ b/auth_oauth_autologin/readme/CONFIGURE.md @@ -0,0 +1,20 @@ +Configure OAuth providers in Settings \> Users and Companies, and make +sure there is one and only one that has both the enabled and automatic +login flags set. + +When this is done, users visiting the login page (/web/login), or being +redirected to it because they are not authenticated yet, will be +redirected to the identity provider login page instead of the regular +Odoo login page. + +Be aware that this module does not actively prevent users from +authenticating with an login and password stored in the Odoo database. +In some unusual circumstances (such as identity provider errors), the +regular Odoo login may still be displayed. Securely disabling Odoo login +and password, if needed, should be the topic of another module. + +Also be aware that this has a possibly surprising effect on the logout +menu item. When the user logs out of Odoo, a redirect to the login page +happens. The login page in turn redirects to the identity provider, +which, if the user is already authenticated there, automatically logs +the user back in Odoo, in a fresh session. diff --git a/auth_oauth_autologin/readme/DESCRIPTION.md b/auth_oauth_autologin/readme/DESCRIPTION.md new file mode 100644 index 0000000000..415e3f901e --- /dev/null +++ b/auth_oauth_autologin/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This modules implements an automatic redirection to the configured OAuth +provider login page, if there is one and only one enabled. This +effectively makes the regular Odoo login screen invisible in normal +circumstances. diff --git a/auth_oauth_autologin/readme/USAGE.md b/auth_oauth_autologin/readme/USAGE.md new file mode 100644 index 0000000000..06f26e76c8 --- /dev/null +++ b/auth_oauth_autologin/readme/USAGE.md @@ -0,0 +1,3 @@ +When configured, the Odoo login page redirects to the OAuth identify +provider for authentication and login in Odoo. To access the regular +Odoo login page, visit `/web/login?no_autologin`. diff --git a/auth_oauth_autologin/static/description/icon.png b/auth_oauth_autologin/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/auth_oauth_autologin/static/description/icon.png differ diff --git a/auth_oauth_autologin/static/description/index.html b/auth_oauth_autologin/static/description/index.html new file mode 100644 index 0000000000..b1e9666db4 --- /dev/null +++ b/auth_oauth_autologin/static/description/index.html @@ -0,0 +1,455 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Auth Oauth Autologin

+ +

Beta License: AGPL-3 OCA/server-auth Translate me on Weblate Try me on Runboat

+

This modules implements an automatic redirection to the configured OAuth +provider login page, if there is one and only one enabled. This +effectively makes the regular Odoo login screen invisible in normal +circumstances.

+

Table of contents

+ +
+

Configuration

+

Configure OAuth providers in Settings > Users and Companies, and make +sure there is one and only one that has both the enabled and automatic +login flags set.

+

When this is done, users visiting the login page (/web/login), or being +redirected to it because they are not authenticated yet, will be +redirected to the identity provider login page instead of the regular +Odoo login page.

+

Be aware that this module does not actively prevent users from +authenticating with an login and password stored in the Odoo database. +In some unusual circumstances (such as identity provider errors), the +regular Odoo login may still be displayed. Securely disabling Odoo login +and password, if needed, should be the topic of another module.

+

Also be aware that this has a possibly surprising effect on the logout +menu item. When the user logs out of Odoo, a redirect to the login page +happens. The login page in turn redirects to the identity provider, +which, if the user is already authenticated there, automatically logs +the user back in Odoo, in a fresh session.

+
+
+

Usage

+

When configured, the Odoo login page redirects to the OAuth identify +provider for authentication and login in Odoo. To access the regular +Odoo login page, visit /web/login?no_autologin.

+
+
+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

sbidoul

+

This module is part of the OCA/server-auth project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/auth_oauth_autologin/static/src/js/web_login.esm.js b/auth_oauth_autologin/static/src/js/web_login.esm.js new file mode 100644 index 0000000000..e58bc5298a --- /dev/null +++ b/auth_oauth_autologin/static/src/js/web_login.esm.js @@ -0,0 +1,26 @@ +/** @odoo-module **/ + +import publicWidget from "@web/legacy/js/public/public_widget"; + +publicWidget.registry.login.include({ + selector: ".oe_login_form", + init() { + this._super(...arguments); + this._rpc = this.bindService("rpc"); + }, + + start: async function () { + const def = this._super.apply(this, arguments); + let url = window.location.href; + if (url.includes("/web/login")) { + url = url.replace("/web/login", "/web"); + } + this._result = await this._rpc("/auth/auto_login_redirect_link", { + redirect: url, + }); + if (this._result) { + window.location = this._result; + } + return def; + }, +}); diff --git a/auth_oauth_autologin/views/assets.xml b/auth_oauth_autologin/views/assets.xml new file mode 100644 index 0000000000..5cbe87c2c9 --- /dev/null +++ b/auth_oauth_autologin/views/assets.xml @@ -0,0 +1,15 @@ + + +