Browse Source

[MIG] 13.0 initial working version for openid_connect

13.0
Nicolas JEUDY 5 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. 35
      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") dependency_checks = fields.Text(compute="_compute_dependency_checks")
@api.one
def _compute_dependency_checks(self): def _compute_dependency_checks(self):
checks = dependencies.get_checks_for_module_recursive(self) checks = dependencies.get_checks_for_module_recursive(self)
self.dependency_checks = json.dumps(display_data(self.env, checks)) 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 system_checks
from . import api from . import api
from .hooks import init_keys

3
galicea_openid_connect/__manifest__.py

@ -12,7 +12,7 @@
"security/security.xml", "security/security.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
# 'security/init.yml', # 'security/init.yml',
"security/init.xml",
# "security/init.xml",
"views/views.xml", "views/views.xml",
"views/templates.xml", "views/templates.xml",
], ],
@ -28,6 +28,7 @@
] ]
} }
}, },
"post_init_hook": "init_keys",
"images": [ "images": [
"static/description/images/master_screenshot.png", "static/description/images/master_screenshot.png",
"static/description/images/client_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: try:
from jwcrypto import jwk from jwcrypto import jwk
@ -6,7 +7,8 @@ except ImportError:
pass pass
def init_keys(IrConfigParameter):
def init_keys(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
keys = { keys = {
"galicea_openid_connect.authorization_code_jwk": lambda: jwk.JWK.generate( "galicea_openid_connect.authorization_code_jwk": lambda: jwk.JWK.generate(
kty="oct", kty="oct",
@ -24,14 +26,8 @@ def init_keys(IrConfigParameter):
).export(), ).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 values["system_user_id"] = system_user.id
return super(Client, self).create(values) return super(Client, self).create(values)
@api.multi
def write(selfs, values): def write(selfs, values):
super(Client, selfs).write(values) super(Client, selfs).write(values)
if "name" in values: if "name" in values:
@ -63,7 +62,6 @@ class Client(models.Model):
) )
return True return True
@api.multi
def unlink(selfs): def unlink(selfs):
users_to_unlink = selfs.mapped(lambda client: client.system_user_id) users_to_unlink = selfs.mapped(lambda client: client.system_user_id)
ret = super(Client, selfs).unlink() 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)

35
galicea_openid_connect/views/views.xml

@ -5,11 +5,11 @@
<field name="model_id" ref="model_galicea_openid_connect_client"/> <field name="model_id" ref="model_galicea_openid_connect_client"/>
<field name="code"> <field name="code">
action = { action = {
"type": "ir.actions.act_window",
"view_mode": "form",
"view_id": obj.env.ref('galicea_openid_connect.client_view_form_secret').id,
"res_model": "galicea_openid_connect.client",
"res_id": obj.id
"type": "ir.actions.act_window",
"view_mode": "form",
"view_id": obj.env.ref('galicea_openid_connect.client_view_form_secret').id,
"res_model": "galicea_openid_connect.client",
"res_id": obj.id
} }
</field> </field>
</record> </record>
@ -23,9 +23,8 @@
<field name="name" /> <field name="name" />
<field name="create_date" invisible="1" /> <field name="create_date" invisible="1" />
<field name="client_id" <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" />
attrs="{'invisible':[('create_date', '==', False)]}" />
<field name="secret" class="oe_read_only" string="Client Secret" />
<field name="auth_redirect_uri" /> <field name="auth_redirect_uri" />
<field name="allow_password_grant" /> <field name="allow_password_grant" />
</group> </group>
@ -33,18 +32,6 @@
</field> </field>
</record> </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"> <record id="client_view_tree" model="ir.ui.view">
<field name="model">galicea_openid_connect.client</field> <field name="model">galicea_openid_connect.client</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@ -57,10 +44,10 @@
</record> </record>
<act_window id="client_action" <act_window id="client_action"
name="OpenID Clients"
res_model="galicea_openid_connect.client" />
name="OpenID Clients"
res_model="galicea_openid_connect.client" />
<menuitem name="OpenID Connect Provider" id="client_menu"
parent="galicea_base.galicea_admin_menu" action="client_action" />
<menuitem name="OpenID Connect Provider" id="client_menu"
parent="galicea_base.galicea_admin_menu" action="client_action" />
</data> </data>
</odoo> </odoo>
Loading…
Cancel
Save