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

  1. from odoo import api, SUPERUSER_ID
  2. from . import random_tokens
  3. try:
  4. from jwcrypto import jwk
  5. except ImportError:
  6. pass
  7. def init_keys(cr, registry):
  8. env = api.Environment(cr, SUPERUSER_ID, {})
  9. keys = {
  10. "galicea_openid_connect.authorization_code_jwk": lambda: jwk.JWK.generate(
  11. kty="oct",
  12. size=256,
  13. kid=random_tokens.alpha_numeric(16),
  14. use="sig",
  15. alg="HS256",
  16. ).export(),
  17. "galicea_openid_connect.id_token_jwk": lambda: jwk.JWK.generate(
  18. kty="RSA",
  19. size=2054,
  20. kid=random_tokens.alpha_numeric(16),
  21. use="sig",
  22. alg="RS256",
  23. ).export(),
  24. }
  25. for key, gen in keys.items():
  26. if not env["ir.config_parameter"].search([("key", "=", key)]):
  27. env["ir.config_parameter"].create(
  28. {"key": key, "value": gen(),}
  29. )