-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by rousseldenis
- Loading branch information
Showing
22 changed files
with
893 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/shopfloor_mobile_base_auth_api_key/odoo/addons/shopfloor_mobile_base_auth_api_key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../shopfloor_mobile_base_auth_api_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
7
shopfloor_mobile_base_auth_api_key/demo/auth_api_key_demo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
15 changes: 15 additions & 0 deletions
15
shopfloor_mobile_base_auth_api_key/demo/auth_api_key_group_demo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
shopfloor_mobile_base_auth_api_key/demo/shopfloor_app_demo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
54 changes: 54 additions & 0 deletions
54
shopfloor_mobile_base_auth_api_key/i18n/shopfloor_mobile_base_auth_api_key.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import shopfloor_app |
29 changes: 29 additions & 0 deletions
29
shopfloor_mobile_base_auth_api_key/models/shopfloor_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**Financial support** | ||
|
||
* Camptocamp R&D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Provide Shopfloor mobile base authentication via API key. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
"API key not allowed on app '%s'", self.collection.tech_name | ||
) | ||
raise Forbidden() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.