Browse Source

[MIG] 13.0 initial working version for openid_connect

13.0
Nicolas JEUDY 4 years ago
parent
commit
c6e30a34b5
  1. 1
      galicea_environment_checkup/models/ext_module.py
  2. 1
      galicea_openid_connect/__init__.py
  3. 3
      galicea_openid_connect/__manifest__.py
  4. 20
      galicea_openid_connect/hooks.py
  5. 2
      galicea_openid_connect/models/client.py
  6. 8
      galicea_openid_connect/security/init.xml
  7. 4
      galicea_openid_connect/security/init.yml
  8. 15
      galicea_openid_connect/views/views.xml

1
galicea_environment_checkup/models/ext_module.py

@ -10,7 +10,6 @@ class Module(models.Model):
dependency_checks = fields.Text(compute="_compute_dependency_checks")
@api.one
def _compute_dependency_checks(self):
checks = dependencies.get_checks_for_module_recursive(self)
self.dependency_checks = json.dumps(display_data(self.env, checks))

1
galicea_openid_connect/__init__.py

@ -3,3 +3,4 @@ from . import models
from . import system_checks
from . import api
from .hooks import init_keys

3
galicea_openid_connect/__manifest__.py

@ -12,7 +12,7 @@
"security/security.xml",
"security/ir.model.access.csv",
# 'security/init.yml',
"security/init.xml",
# "security/init.xml",
"views/views.xml",
"views/templates.xml",
],
@ -28,6 +28,7 @@
]
}
},
"post_init_hook": "init_keys",
"images": [
"static/description/images/master_screenshot.png",
"static/description/images/client_screenshot.png",

20
galicea_openid_connect/security/__init__.py → galicea_openid_connect/hooks.py

@ -1,4 +1,5 @@
from .. import random_tokens
from odoo import api, SUPERUSER_ID
from . import random_tokens
try:
from jwcrypto import jwk
@ -6,7 +7,8 @@ except ImportError:
pass
def init_keys(IrConfigParameter):
def init_keys(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
keys = {
"galicea_openid_connect.authorization_code_jwk": lambda: jwk.JWK.generate(
kty="oct",
@ -24,14 +26,8 @@ def init_keys(IrConfigParameter):
).export(),
}
for key, gen in keys.iteritems():
if not IrConfigParameter.search([("key", "=", key)]):
IrConfigParameter.create(
{
"key": key,
"value": gen(),
"group_ids": [
(4, IrConfigParameter.env.ref("base.group_erp_manager").id)
],
}
for key, gen in keys.items():
if not env["ir.config_parameter"].search([("key", "=", key)]):
env["ir.config_parameter"].create(
{"key": key, "value": gen(),}
)

2
galicea_openid_connect/models/client.py

@ -54,7 +54,6 @@ class Client(models.Model):
values["system_user_id"] = system_user.id
return super(Client, self).create(values)
@api.multi
def write(selfs, values):
super(Client, selfs).write(values)
if "name" in values:
@ -63,7 +62,6 @@ class Client(models.Model):
)
return True
@api.multi
def unlink(selfs):
users_to_unlink = selfs.mapped(lambda client: client.system_user_id)
ret = super(Client, selfs).unlink()

8
galicea_openid_connect/security/init.xml

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<function model="ir.config_parameter"
name="openid_init_keys"
/>
</data>
</odoo>

4
galicea_openid_connect/security/init.yml

@ -1,4 +0,0 @@
-
!python {model: ir.config_parameter}: |
from odoo.addons.galicea_openid_connect.security import init_keys
init_keys(self)

15
galicea_openid_connect/views/views.xml

@ -24,8 +24,7 @@
<field name="create_date" invisible="1" />
<field name="client_id"
attrs="{'invisible':[('create_date', '==', False)]}" />
<label for="secret" class="oe_read_only" string="Client Secret" />
<button class="oe_read_only" string="Show" type="action" name="%(client_action_secret)d" />
<field name="secret" class="oe_read_only" string="Client Secret" />
<field name="auth_redirect_uri" />
<field name="allow_password_grant" />
</group>
@ -33,18 +32,6 @@
</field>
</record>
<record id="client_view_form_secret" model="ir.ui.view">
<field name="inherit_id" ref="galicea_openid_connect.client_view_form" />
<field name="priority">99</field>
<field name="model">galicea_openid_connect.client</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<button name="%(client_action_secret)d" position="replace">
<field class="oe_read_only" name="secret" nolabel="1" />
</button>
</field>
</record>
<record id="client_view_tree" model="ir.ui.view">
<field name="model">galicea_openid_connect.client</field>
<field name="arch" type="xml">

Loading…
Cancel
Save