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.

23 lines
843 B

  1. # -*- coding: utf-8 -*-
  2. from .. import random_tokens
  3. try:
  4. from jwcrypto import jwk
  5. except ImportError:
  6. pass
  7. def init_keys(IrConfigParameter):
  8. keys = {
  9. 'galicea_openid_connect.authorization_code_jwk': lambda: \
  10. jwk.JWK.generate(kty='oct', size=256, kid=random_tokens.alpha_numeric(16), use='sig', alg='HS256').export(),
  11. 'galicea_openid_connect.id_token_jwk': lambda: \
  12. jwk.JWK.generate(kty='RSA', size=2054, kid=random_tokens.alpha_numeric(16), use='sig', alg='RS256').export()
  13. }
  14. for key, gen in keys.iteritems():
  15. if not IrConfigParameter.search([('key', '=', key)]):
  16. IrConfigParameter.create({
  17. 'key': key,
  18. 'value': gen(),
  19. 'group_ids': [(4, IrConfigParameter.env.ref('base.group_erp_manager').id)]
  20. })