You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
919 B

from odoo import api, SUPERUSER_ID
from . import random_tokens
try:
from jwcrypto import jwk
except ImportError:
pass
def init_keys(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
keys = {
"galicea_openid_connect.authorization_code_jwk": lambda: jwk.JWK.generate(
kty="oct",
size=256,
kid=random_tokens.alpha_numeric(16),
use="sig",
alg="HS256",
).export(),
"galicea_openid_connect.id_token_jwk": lambda: jwk.JWK.generate(
kty="RSA",
size=2054,
kid=random_tokens.alpha_numeric(16),
use="sig",
alg="RS256",
).export(),
}
for key, gen in keys.items():
if not env["ir.config_parameter"].search([("key", "=", key)]):
env["ir.config_parameter"].create(
{"key": key, "value": gen(),}
)