Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] auth_oauth_multi_token: Migration to 18.0 #754

Open
wants to merge 21 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6ead629
[add] auth_oauth_multi_token
Jul 18, 2016
b50f2f8
[MIG+IMP][10.0] auth_oauth_multi_token
simahawk Oct 17, 2017
1de0588
[MIG][11.0] auth_oauth_multi_token
fmdl Apr 30, 2018
e808bcb
[MIG] auth_oauth_multi_token: Migration to 12.0
fmdl May 31, 2019
f874e9b
[IMP] auth_oauth_multi_token: black, isort, prettier
Sep 21, 2020
8e17d8b
[MIG] auth_oauth_multi_token: v13
Sep 21, 2020
a114407
auth_oauth_multi_token: index
sbidoul Apr 13, 2021
f554da0
auth_oauth_multi_token: cascade delete tokens
sbidoul Apr 13, 2021
5200433
auth_oauth_multi_token: reset main token on clear
sbidoul Apr 13, 2021
79a4e09
auth_oauth_multi_token: add contributor
sbidoul Apr 14, 2021
007ea5f
[IMP] auth_oauth_multi_token: preserve _oauth_clear_token method
sbidoul Apr 21, 2021
f6f51dd
[MIG] auth_oauth_multi_token: Migration to v14.0
sergio-teruel Feb 2, 2023
bc1ff12
[MIG] auth_oauth_multi_token: Migration to v15.0
Feb 2, 2023
33a5ded
[MIG] auth_oauth_multi_token: Migration to 16.0
May 12, 2023
92a2ec6
[UPD] Update auth_oauth_multi_token.pot
Mar 12, 2024
e1d0a0b
[BOT] post-merge updates
OCA-git-bot Mar 12, 2024
811a856
Added translation using Weblate (Italian)
mymage Mar 14, 2024
1181374
Translated using Weblate (Italian)
mymage Mar 14, 2024
1ae42e2
[17.0][MIG] auth_oauth_multi_token: Migration to 17.0
kobros-tech Dec 31, 2024
b14b991
[18.0][MIG] auth_oauth_multi_token: Migration to 18.0
kobros-tech Dec 31, 2024
ca2abb9
[FIX] auth_oauth_multi_token: Apply token version for being validated…
dnplkndll Jan 17, 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
96 changes: 96 additions & 0 deletions auth_oauth_multi_token/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
=================
OAuth Multi Token
=================

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

.. |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_multi_token
: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_multi_token
: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 module adds the possibility to connect with the same account on
more than one device at the same time.

All providers are supported (Google, Facebook, Odoo, etc).

**Table of contents**

.. contents::
:local:

Usage
=====

Nothing changes on login action: just select your provider and try to
log in.

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_multi_token%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
-------

* Florent de Labarre
* Camptocamp

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

- Florent de Labarre <[email protected]>
- Simone Orsi <[email protected]>
- `Tecnativa <https://www.tecnativa.com/>`__:

- Jairo Llopis
- Sergio Teruel

- Stéphane Bidoul <[email protected]>
- Dan Tillinghast
- Miku Laitinen
- Mohamed Alkobrosli <[email protected]>

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/18.0/auth_oauth_multi_token>`_ 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 auth_oauth_multi_token/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions auth_oauth_multi_token/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2016 Florent de Labarre
# Copyright 2017 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "OAuth Multi Token",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Florent de Labarre, Camptocamp, Odoo Community Association (OCA)",
"summary": """Allow multiple connection with the same OAuth account""",
"category": "Tool",
"website": "https://github.com/OCA/server-auth",
"depends": ["auth_oauth"],
"data": [
"security/ir.model.access.csv",
"views/auth_oauth_multi_token.xml",
"views/res_users.xml",
],
"installable": True,
}
90 changes: 90 additions & 0 deletions auth_oauth_multi_token/i18n/auth_oauth_multi_token.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * auth_oauth_multi_token
#
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_multi_token
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
msgid "Clear Tokens"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_uid
msgid "Created by"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_date
msgid "Created on"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__display_name
msgid "Display Name"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__id
msgid "ID"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token____last_update
msgid "Last Modified on"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_uid
msgid "Last Updated by"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_date
msgid "Last Updated on"
msgstr ""

#. module: auth_oauth_multi_token
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
msgid "Latest Tokens"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_master_uuid
msgid "Master UUID"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_max_token
msgid "Max Number of Simultaneous Connections"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__oauth_access_token
msgid "OAuth Access Token"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_token_ids
msgid "OAuth Tokens"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model,name:auth_oauth_multi_token.model_auth_oauth_multi_token
msgid "OAuth2 Token"
msgstr ""

#. module: auth_oauth_multi_token
#: model:ir.model,name:auth_oauth_multi_token.model_res_users
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__user_id
msgid "User"
msgstr ""
93 changes: 93 additions & 0 deletions auth_oauth_multi_token/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * auth_oauth_multi_token
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-03-14 15:38+0000\n"
"Last-Translator: mymage <[email protected]>\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: auth_oauth_multi_token
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
msgid "Clear Tokens"
msgstr "Pulisci token"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_uid
msgid "Created by"
msgstr "Creato da"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_date
msgid "Created on"
msgstr "Creato il"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__id
msgid "ID"
msgstr "ID"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_uid
msgid "Last Updated by"
msgstr "Ultimo aggiornamento di"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_date
msgid "Last Updated on"
msgstr "Ultimo aggiornamento il"

#. module: auth_oauth_multi_token
#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form
msgid "Latest Tokens"
msgstr "Ulrimi token"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_master_uuid
msgid "Master UUID"
msgstr "UUID master"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_max_token
msgid "Max Number of Simultaneous Connections"
msgstr "Numero massimo di connessioni simultanee"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__oauth_access_token
msgid "OAuth Access Token"
msgstr "Token accesso OAuth"

#. module: auth_oauth_multi_token
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_token_ids
msgid "OAuth Tokens"
msgstr "Token OAuth"

#. module: auth_oauth_multi_token
#: model:ir.model,name:auth_oauth_multi_token.model_auth_oauth_multi_token
msgid "OAuth2 Token"
msgstr "Token OAuth"

#. module: auth_oauth_multi_token
#: model:ir.model,name:auth_oauth_multi_token.model_res_users
#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__user_id
msgid "User"
msgstr "Utente"
2 changes: 2 additions & 0 deletions auth_oauth_multi_token/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import auth_oauth_multi_token
from . import res_users
54 changes: 54 additions & 0 deletions auth_oauth_multi_token/models/auth_oauth_multi_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2016 Florent de Labarre
# Copyright 2017 Camptocamp
# Copyright 2021 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import api, fields, models


class AuthOauthMultiToken(models.Model):
"""Define a set of tokens."""

_name = "auth.oauth.multi.token"
_description = "OAuth2 Token"
_order = "id desc"

oauth_access_token = fields.Char(
string="OAuth Access Token", readonly=True, copy=False
)
user_id = fields.Many2one(
comodel_name="res.users",
string="User",
required=True,
readonly=True,
index=True,
ondelete="cascade",
)

@api.model_create_multi
def create(self, vals_list):
"""Override to validate tokens."""
tokens = super().create(vals_list)
tokens._oauth_validate_multi_token()
return tokens

@api.model
def _oauth_user_tokens(self, user_id):
"""Retrieve tokens for given user.

:param user_id: Odoo ID of the user
"""
return self.search([("user_id", "=", user_id)])

def _oauth_validate_multi_token(self):
"""Check current user's token and clear them if max number reached."""
for token in self:
user_tokens = self._oauth_user_tokens(token.user_id.id)
max_token = token.user_id.oauth_access_max_token
if user_tokens and len(user_tokens) > max_token:
# clear last token
user_tokens[max_token - 1]._oauth_clear_token()

def _oauth_clear_token(self):
"""Disable current token records."""
self.unlink()
Loading
Loading