Skip to content
Open
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
120 changes: 120 additions & 0 deletions auth_oauth_autologin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
====================
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/licence-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/18.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-18-0/server-auth-18-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=18.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 <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:%20auth_oauth_autologin%0Aversion:%2018.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
-------

* ACSONE SA/NV

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

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

- Tuan Nguyen <tuanna@trobz.com>

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbidoul|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions auth_oauth_autologin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
16 changes: 16 additions & 0 deletions auth_oauth_autologin/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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": "18.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": [],
}
1 change: 1 addition & 0 deletions auth_oauth_autologin/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
33 changes: 33 additions & 0 deletions auth_oauth_autologin/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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()
def web_login(self, *args, **kw):
# Odoo 18 uses deep links, so the full URL path is available to the server.
# We can perform a server-side redirect if autologin is enabled.
if request.httprequest.method == "GET" and not self._autologin_disabled(
request.httprequest.url
):
auth_link = self._autologin_link()
if auth_link:
return request.redirect(auth_link, 303, local=False)
return super().web_login(*args, **kw)
33 changes: 33 additions & 0 deletions auth_oauth_autologin/i18n/auth_oauth_autologin.pot
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:
# * auth_oauth_autologin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-11-21 04:41+0000\n"
"PO-Revision-Date: 2025-11-21 04:41+0000\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 ""
35 changes: 35 additions & 0 deletions auth_oauth_autologin/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * auth_oauth_autologin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-11-21 04:32+0000\n"
"PO-Revision-Date: 2025-11-21 04:32+0000\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 "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 "Fornitore OAuth2"
1 change: 1 addition & 0 deletions auth_oauth_autologin/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import auth_oauth_provider
16 changes: 16 additions & 0 deletions auth_oauth_autologin/models/auth_oauth_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 ACSONE SA/NV <https://acsone.eu>
# 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."
),
)
3 changes: 3 additions & 0 deletions auth_oauth_autologin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
20 changes: 20 additions & 0 deletions auth_oauth_autologin/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions auth_oauth_autologin/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Trobz](https://trobz.com):
- Tuan Nguyen \<<tuanna@trobz.com>\>
4 changes: 4 additions & 0 deletions auth_oauth_autologin/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions auth_oauth_autologin/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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`.
Loading