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

[16.0][MIG] - shopfloor_mobile_base_auth_api_key #701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
390dea4
Add sf_mobile_base_auth_api_key: decouple auth
simahawk Oct 14, 2021
0743024
sf_mobile_base: unify logged in check
simahawk Oct 26, 2021
37a8582
sf_mbl_base_auth_api_key: refactor api_key login logic
JuMiSanAr Oct 28, 2021
0003d3a
shopfloor_mobile_base_auth_api_key: add README
simahawk Nov 5, 2021
2cbcf62
[UPD] Update shopfloor_mobile_base_auth_api_key.pot
oca-travis Nov 5, 2021
2eea371
[UPD] README.rst
OCA-git-bot Nov 5, 2021
4a4e9a6
[ADD] icon.png
OCA-git-bot Nov 5, 2021
2a49437
sf_mobile_base*: improve auth handler init
simahawk Nov 18, 2021
45123ad
shopfloor_mobile_base_auth_api_key 14.0.1.0.1
OCA-git-bot Nov 18, 2021
9bbcc72
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago Dec 28, 2021
5213dac
shopfloor_base: get rid of static controller
simahawk Oct 26, 2021
c251903
shopfloor*_api_key: limit access to specific keys
simahawk Nov 2, 2021
b54fcba
sf_mobile_auth_api_key: ease access to groups
simahawk Nov 18, 2021
b57213b
sf_mobile_base_auth_api_key: add specific demo data
simahawk Nov 26, 2021
e6d0129
shopfloor_mobile_base_auth_api_key: dev status = Beta
simahawk Apr 4, 2022
f826ad1
shopfloor_mobile_base_auth_api_key: 14.0.1.1.0
simahawk Apr 4, 2022
89c9f30
[UPD] Update shopfloor_mobile_base_auth_api_key.pot
Apr 5, 2022
11a0761
[UPD] README.rst
OCA-git-bot Apr 5, 2022
b9879ea
Update translation files
oca-transbot Apr 6, 2022
fdbd11c
shopfloor_mobile_base_auth*: re-license as LGPL
simahawk May 9, 2022
3beedd3
shopfloor_mobile_base_auth_api_key 14.0.2.0.0
OCA-git-bot May 10, 2022
549536e
shopfloor_mobile_base_auth_api_key: fix login form security
jbaudoux May 11, 2022
0836e46
shopfloor_mobile_base_auth_api_key 14.0.2.1.0
OCA-git-bot Nov 23, 2022
0194333
[16.0][MIG] - shopfloor_mobile_base_auth_api_key
sbejaoui Aug 1, 2023
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
6 changes: 6 additions & 0 deletions setup/shopfloor_mobile_base_auth_api_key/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
84 changes: 84 additions & 0 deletions shopfloor_mobile_base_auth_api_key/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
======================================
Shopfloor Mobile Base auth via API key
======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8d2fe59374041f7c6dee89f0d3260999918aa16ea9a4ec72fd062551eae65d0d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-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%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/16.0/shopfloor_mobile_base_auth_api_key
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-shopfloor_mobile_base_auth_api_key
: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/wms&target_branch=16.0
:alt: Try me on Runboat

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

Provide Shopfloor mobile base authentication via API key.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/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/wms/issues/new?body=module:%20shopfloor_mobile_base_auth_api_key%0Aversion:%2016.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
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Simone Orsi <[email protected]>
* Juan Miguel Sánchez Arce <[email protected]>

Other credits
~~~~~~~~~~~~~

**Financial support**

* Camptocamp R&D

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/wms <https://github.com/OCA/wms/tree/16.0/shopfloor_mobile_base_auth_api_key>`_ 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 shopfloor_mobile_base_auth_api_key/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import services
25 changes: 25 additions & 0 deletions shopfloor_mobile_base_auth_api_key/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2021 Camptocamp SA (http://www.camptocamp.com)
# @author Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

{
"name": "Shopfloor Mobile Base auth via API key",
"summary": "Provides authentication via API key to Shopfloor base mobile app",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "Inventory",
"website": "https://github.com/OCA/wms",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainer": ["simahawk"],
"license": "LGPL-3",
"depends": [
"shopfloor_mobile_base",
"auth_api_key_group",
],
"data": ["templates/assets.xml", "views/shopfloor_app.xml"],
"demo": [
"demo/auth_api_key_demo.xml",
"demo/auth_api_key_group_demo.xml",
"demo/shopfloor_app_demo.xml",
],
}
7 changes: 7 additions & 0 deletions shopfloor_mobile_base_auth_api_key/demo/auth_api_key_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo noupdate="1">
<record id="api_key_demo" model="auth.api.key">
<field name="name">Shopfloor Demo</field>
<field name="user_id" ref="base.user_demo" />
<field name="key">72B044F7AC780DAC</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">

<record id="auth_api_key_group" model="auth.api.key.group">
<field name="name">Shopfloor Demo</field>
<field name="code">shopfloor_demo</field>
<field
name="auth_api_key_ids"
eval="[
(4, ref('api_key_demo')),
]"
/>
</record>

</odoo>
14 changes: 14 additions & 0 deletions shopfloor_mobile_base_auth_api_key/demo/shopfloor_app_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<odoo noupdate="1">
<record id="app_demo1" model="shopfloor.app">
<field name="name">Shopfloor Demo (api key auth)</field>
<field name="short_name">demo api key</field>
<field name="tech_name">demo_api_key</field>
<field name="auth_type">api_key</field>
<field
name="auth_api_key_group_ids"
eval="[
(4, ref('auth_api_key_group')),
]"
/>
</record>
</odoo>
54 changes: 54 additions & 0 deletions shopfloor_mobile_base_auth_api_key/i18n/pt_BR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: pt_BR\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"

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model,name:shopfloor_mobile_base_auth_api_key.model_shopfloor_app
msgid "A Shopfloor application"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app__auth_api_key_group_ids
msgid "Allowed API key groups"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app__display_name
msgid "Display Name"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app__id
msgid "ID"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app____last_update
msgid "Last Modified on"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model_terms:ir.ui.view,arch_db:shopfloor_mobile_base_auth_api_key.shopfloor_app_form_view
msgid "Manage groups"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:shopfloor.app,name:shopfloor_mobile_base_auth_api_key.app_demo1
msgid "Shopfloor Demo (api key auth)"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:shopfloor.app,short_name:shopfloor_mobile_base_auth_api_key.app_demo1
msgid "demo api key"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * shopfloor_mobile_base_auth_api_key
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: shopfloor_mobile_base_auth_api_key
#: model:ir.model,name:shopfloor_mobile_base_auth_api_key.model_shopfloor_app
msgid "A Shopfloor application"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app__auth_api_key_group_ids
msgid "Allowed API key groups"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app__display_name
msgid "Display Name"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app__id
msgid "ID"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:ir.model.fields,field_description:shopfloor_mobile_base_auth_api_key.field_shopfloor_app____last_update
msgid "Last Modified on"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model_terms:ir.ui.view,arch_db:shopfloor_mobile_base_auth_api_key.shopfloor_app_form_view
msgid "Manage groups"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:shopfloor.app,name:shopfloor_mobile_base_auth_api_key.app_demo1
msgid "Shopfloor Demo (api key auth)"
msgstr ""

#. module: shopfloor_mobile_base_auth_api_key
#: model:shopfloor.app,short_name:shopfloor_mobile_base_auth_api_key.app_demo1
msgid "demo api key"
msgstr ""
1 change: 1 addition & 0 deletions shopfloor_mobile_base_auth_api_key/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import shopfloor_app
29 changes: 29 additions & 0 deletions shopfloor_mobile_base_auth_api_key/models/shopfloor_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2021 Camptcamp SA
# @author: Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models


class ShopfloorApp(models.Model):

# TODO: consider splitting this to new module shopfloor_base_auth_api_key
_inherit = "shopfloor.app"

def _selection_auth_type(self):
return super()._selection_auth_type() + [("api_key", "API key")]

# Borrowed from `endpoint_auth_api_key`: shall we define a mixin?
auth_api_key_group_ids = fields.Many2many(
comodel_name="auth.api.key.group",
string="Allowed API key groups",
)

def _allowed_api_key_ids(self):
return self.auth_api_key_group_ids.auth_api_key_ids.ids

Check warning on line 23 in shopfloor_mobile_base_auth_api_key/models/shopfloor_app.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_mobile_base_auth_api_key/models/shopfloor_app.py#L23

Added line #L23 was not covered by tests

def action_manage_api_key_groups(self):
xid = "auth_api_key_group.auth_api_key_group_act_window"
action = self.env["ir.actions.act_window"]._for_xml_id(xid)
action["domain"] = [("id", "in", self.auth_api_key_group_ids.ids)]
return action

Check warning on line 29 in shopfloor_mobile_base_auth_api_key/models/shopfloor_app.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_mobile_base_auth_api_key/models/shopfloor_app.py#L26-L29

Added lines #L26 - L29 were not covered by tests
2 changes: 2 additions & 0 deletions shopfloor_mobile_base_auth_api_key/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Simone Orsi <[email protected]>
* Juan Miguel Sánchez Arce <[email protected]>
3 changes: 3 additions & 0 deletions shopfloor_mobile_base_auth_api_key/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Financial support**

* Camptocamp R&D
1 change: 1 addition & 0 deletions shopfloor_mobile_base_auth_api_key/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide Shopfloor mobile base authentication via API key.
1 change: 1 addition & 0 deletions shopfloor_mobile_base_auth_api_key/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import service
31 changes: 31 additions & 0 deletions shopfloor_mobile_base_auth_api_key/services/service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2021 Camptocamp SA (http://www.camptocamp.com)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

import logging

from werkzeug.exceptions import Forbidden

from odoo.addons.component.core import AbstractComponent

_logger = logging.getLogger(__name__)


class BaseShopfloorService(AbstractComponent):
_inherit = "base.shopfloor.service"

def dispatch(self, method_name, *args, params=None):
self._validate_request(self.request)
return super().dispatch(method_name, *args, params=params)

def _validate_request(self, request):
if self.collection.auth_type == "api_key":
# request api key is already validated when we reach this point
# Now let's validate it at app level.
if (
self.request.auth_api_key_id
not in self.collection.sudo()._allowed_api_key_ids()
):
_logger.error(

Check warning on line 28 in shopfloor_mobile_base_auth_api_key/services/service.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_mobile_base_auth_api_key/services/service.py#L28

Added line #L28 was not covered by tests
"API key not allowed on app '%s'", self.collection.tech_name
)
raise Forbidden()

Check warning on line 31 in shopfloor_mobile_base_auth_api_key/services/service.py

View check run for this annotation

Codecov / codecov/patch

shopfloor_mobile_base_auth_api_key/services/service.py#L31

Added line #L31 was not covered by tests
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading