Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Keycloak Authentication on v12

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
8 Respuestas
16926 Vistas
Avatar
Karim Gillani

Using: Odoo 12.0-20190128 (Community Edition)

am trying to get Keycloak working on Odoo using the base OAUTH2 setup.  I am getting an access denied.  In my keycloak server, I see the user in the session.  I suspect the mapping is not correct.  Any suggestions would be appreciated...

Errors in log:

2019-03-03 22:43:11,701 1 ERROR db odoo.addons.auth_oauth.controllers.main: OAuth2: Expecting value: line 1 column 1 (char 0) 

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/controllers/main.py", line 142, in signin

    credentials = env['res.users'].sudo().auth_oauth(provider, kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 96, in auth_oauth

    validation = self._auth_oauth_validate(provider, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 34, in _auth_oauth_validate

    validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 28, in _auth_oauth_rpc

    return requests.get(endpoint, params={'access_token': access_token}).json()

  File "/usr/lib/python3/dist-packages/requests/models.py", line 850, in json

    return complexjson.loads(self.text, **kwargs)

  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads

    return _default_decoder.decode(s)

  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode

    raise JSONDecodeError("Expecting value", s, err.value) from None

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

2019-03-03 22:43:11,704 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:11] "GET /auth_oauth/signin?state={%22r%22%3A+%22https%253A%252F%252Fodoo.pathfinder.gov.bc.ca%252Fweb%22%2C+%22p%22%3A+7%2C+%22d%22%3A+%22db%22}&session_state=4946aea0-1a42-4809-a10b-030aaba4c50f&access_token=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI1NXhiZzcyaml6NWQ3cEtkbzdwNFhLdTB2VFA2UXMtemthZzFaY1ZKWTZVIn0.eyJqdGkiOiIzNTRkY2EzYi0wMWE4LTRmM2EtODdkZC1iOWZkZThjMzc2YTkiLCJleHAiOjE1NTE2NTM4ODYsIm5iZiI6MCwiaWF0IjoxNTUxNjUyOTg2LCJpc3MiOiJodHRwczovL3Nzby10ZXN0LnBhdGhmaW5kZXIuZ292LmJjLmNhL2F1dGgvcmVhbG1zL3NiYyIsImF1ZCI6Ik9kb28iLCJzdWIiOiI0YjZjODM5YS03NjA0LTRiMzYtOGE1My1lNzI1Mjg5ZGZjNzkiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJPZG9vIiwiYXV0aF90aW1lIjoxNTUxNjQ1MTg3LCJzZXNzaW9uX3N0YXRlIjoiNDk0NmFlYTAtMWE0Mi00ODA5LWExMGItMDMwYWFiYTRjNTBmIiwiYWNyIjoiMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJpZGlyIiwib2ZmbGluZV9hY2Nlc3MiLCJhZG1pbiIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsicmVhbG0tbWFuYWdlbWVudCI6eyJyb2xlcyI6WyJ2aWV3LXJlYWxtIiwidmlldy1pZGVudGl0eS1wcm92aWRlcnMiLCJtYW5hZ2UtaWRlbnRpdHktcHJvdmlkZXJzIiwiaW1wZXJzb25hdGlvbiIsInJlYWxtLWFkbWluIiwiY3JlYXRlLWNsaWVudCIsIm1hbmFnZS11c2VycyIsInF1ZXJ5LXJlYWxtcyIsInZpZXctYXV0aG9yaXphdGlvbiIsInF1ZXJ5LWNsaWVudHMiLCJxdWVyeS11c2VycyIsIm1hbmFnZS1ldmVudHMiLCJtYW5hZ2UtcmVhbG0iLCJ2aWV3LWV2ZW50cyIsInZpZXctdXNlcnMiLCJ2aWV3LWNsaWVudHMiLCJtYW5hZ2UtYXV0aG9yaXphdGlvbiIsIm1hbmFnZS1jbGllbnRzIiwicXVlcnktZ3JvdXBzIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJuYW1lIjoiR2lsbGFuaSwgS2FyaW0gQ0lUWjpFWCIsInByZWZlcnJlZF91c2VybmFtZSI6ImlkaXIva2dpbGxhbmkiLCJnaXZlbl9uYW1lIjoiR2lsbGFuaSwgS2FyaW0gQ0lUWjpFWCIsImVtYWlsIjoia2FyaW0uZ2lsbGFuaUBnb3YuYmMuY2EifQ.MFfD0se0hcI-l6oxL7gJ_RFEDosYBKDZNO3VEVLUyPjhjN8xkK5rGycK_ZyE_D9OFbCBX8E8c9qnQWDrik7i43sfBt6luPKs7TkLQJZHtfOt6ASYsAVKJyJxjZRBm_Pume98MXEBiMEhVCU3Un5V94k3f7ae_lTnE1Vqx-t2QtMeA-KDAFz9m8mL2PbFyOnDnfeb2ar_vjHkPkMxf1iruglSj8-xHYUQ8qMATX6WsxEPLBMlFuRoGdnWstSzz_tzAmQ7sAVY0lY2oWeQVbA5Fj3_oCOMSnwYxhtpaabTPosZs1y9nvTHtBRReKgt88p0dW3FqWWzSWefCD7Lzwho1g&token_type=bearer&expires_in=900&not-before-policy=1548956992 HTTP/1.1" 303 - 2 0.002 5.174

2019-03-03 22:43:11,861 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:11] "GET /web/login?oauth_error=2 HTTP/1.1" 200 - 11 0.029 0.065

2019-03-03 22:43:12,172 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:12] "GET /web/webclient/qweb?mods= HTTP/1.1" 200 - 1 0.001 0.007

2019-03-03 22:43:12,174 1 INFO db werkzeug: 172.51.20.1 - - [03/Mar/2019 22:43:12] "POST /web/webclient/bootstrap_translations HTTP/1.1" 200 - 1 0.001


I also tried to install the Keycloak auth app (v10) but received errors:

Error:

Odoo Server Error


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 573, in _tag_record

    model = self.env[rec_model]

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 821, in __getitem__

    return self.registry[model_name]._browse((), self)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 176, in __getitem__

    return self.models[model_name]

KeyError: 'ir.values'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 654, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise

    raise value

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in dispatch

    result = self._call_function(**self.params)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper

    return f(dbname, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call

    result = self.endpoint(*a, **kw)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in __call__

    return self.method(*args, **kw)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap

    response = f(*args, **kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 966, in call_button

    action = self._call_kw(model, method, args, {})

  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 749, in call_kw

    return _call_kw_multi(method, model, args, kwargs)

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 736, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "<decorator-gen-61>", line 2, in button_immediate_install

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 73, in check_and_log

    return method(self, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 444, in button_immediate_install

    return self._button_immediate_function(type(self).button_install)

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 553, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 86, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 421, in load_modules

    loaded_modules, update_module, models_to_check)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 313, in load_marked_modules

    perform_checks=perform_checks, models_to_check=models_to_check

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph

    load_data(cr, idref, mode, kind='data', package=package, report=report)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 68, in load_data

    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 801, in convert_file

    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 864, in convert_xml_import

    obj.parse(doc.getroot(), mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 763, in parse

    exc_info[2]

  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 573, in _tag_record

    model = self.env[rec_model]

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 821, in __getitem__

    return self.registry[model_name]._browse((), self)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 176, in __getitem__

    return self.models[model_name]

odoo.tools.convert.ParseError: "ir.values" while parsing /mnt/extra-addons/auth_keycloak/wizard/keycloak_create_wiz.xml:55, near

<record id="action_purge_model_line_value" model="ir.values">

    <field name="name">Push users to Keycloak</field>

    <field name="key">action</field>

    <field name="key2">client_action_multi</field>

    <field name="model">res.users</field>

    <field name="value" eval="'ir.actions.act_window,%d' % ref('auth_keycloak.keycloak_create_users')"/>

  </record>

1
Avatar
Descartar
Avatar
Hideyuki Otokawa
Mejor respuesta

I've also tried to use odoo with keycloak and met with same thing. After some investigation  I've made a small patch for auth_oauth. In my environemnt, in which the docker conatiner of official image runs, its working..

These are the necessary settings.


Making OAuth provider of keycloak as below;

  •  client id should be specified the one assinged for client in keycloak realm

  •  keycloak checkbox should be marked; it's the new one which I added.

  • auth URL should be specified the endpoint of keycloak ended with 'auth'

  • validation URL should be spefied the endpoint of keycloak ended with 'userinfo

  • scope and data URL are blank.

Next, settings for user accounts by which you'd like to sign-in with keycloak

  • OAtuth provider should be selected the one which you made for keycloak

  • OAuth user id shoud be input email address of the keycloak user accout

Finally, necessary setting of keycloak

  • Creating the mapping from 'email' to 'user_id' in the client mapper.

If everything is okay, then you can sign-in through keycloak as me..

Sorry. I did not put my patch. Please apply this.

diff -c -r -x '*.po' ./models/auth_oauth.py /home/s111403/work/auth_oauth/models/auth_oauth.py
*** ./models/auth_oauth.py2019-03-15 00:52:47.824000000 +0000
--- /home/s111403/work/auth_oauth/models/auth_oauth.py2019-03-14 14:22:21.964000000 +0000
***************
*** 18,23 ****
--- 18,24 ----
      validation_endpoint = fields.Char(string='Validation URL', required=True)  # OAuth provider URL to validate tokens
      data_endpoint = fields.Char(string='Data URL')
      enabled = fields.Boolean(string='Allowed')
+     keycloak = fields.Boolean(string='Keycloak')
      css_class = fields.Char(string='CSS class', default='fa fa-fw fa-sign-in text-primary')
      body = fields.Char(required=True)
      sequence = fields.Integer()
diff -c -r -x '*.po' ./models/res_users.py /home/s111403/work/auth_oauth/models/res_users.py
*** ./models/res_users.py2019-03-15 00:52:47.824000000 +0000
--- /home/s111403/work/auth_oauth/models/res_users.py2019-03-14 15:07:20.572000000 +0000
***************
*** 24,41 ****
      ]
      @api.model
!     def _auth_oauth_rpc(self, endpoint, access_token):
!         return requests.get(endpoint, params={'access_token': access_token}).json()
      @api.model
      def _auth_oauth_validate(self, provider, access_token):
          """ return the validation data corresponding to the access token """
          oauth_provider = self.env['auth.oauth.provider'].browse(provider)
!         validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token)
          if validation.get("error"):
              raise Exception(validation['error'])
          if oauth_provider.data_endpoint:
!             data = self._auth_oauth_rpc(oauth_provider.data_endpoint, access_token)
              validation.update(data)
          return validation
--- 27,48 ----
      ]
      @api.model
!     def _auth_oauth_rpc(self, endpoint, access_token, provider):
!         oauth_provider = self.env['auth.oauth.provider'].browse(provider)
!         if oauth_provider.keycloak:
!           return requests.get(endpoint, headers={'Authorization': 'bearer ' + access_token}).json()
!         else:
!           return requests.get(endpoint, params={'access_token': access_token}).json()
      @api.model
      def _auth_oauth_validate(self, provider, access_token):
          """ return the validation data corresponding to the access token """
          oauth_provider = self.env['auth.oauth.provider'].browse(provider)
!         validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token, provider)
          if validation.get("error"):
              raise Exception(validation['error'])
          if oauth_provider.data_endpoint:
!             data = self._auth_oauth_rpc(oauth_provider.data_endpoint, access_token, provider)
              validation.update(data)
          return validation
diff -c -r -x '*.po' ./views/auth_oauth_views.xml /home/s111403/work/auth_oauth/views/auth_oauth_views.xml
*** ./views/auth_oauth_views.xml2019-03-15 00:52:47.824000000 +0000
--- /home/s111403/work/auth_oauth/views/auth_oauth_views.xml2019-03-14 14:28:01.508000000 +0000
***************
*** 10,15 ****
--- 10,16 ----
                              <field name="name" />
                              <field name="client_id" />
                              <field name="enabled" />
+                             <field name="keycloak" />
                              <field name="body" />
                          </group>
                          <group>
***************
*** 30,35 ****
--- 31,37 ----
                      <field name="name" />
                      <field name="client_id" />
                      <field name="enabled" />
+                     <field name="keycloak" />
                  </tree>
              </field>
          </record>


2
Avatar
Descartar
Avatar
Kirubanidhi Rajarathinam
Mejor respuesta

Dear,
I am using odoo15 version,
Keycloak version 20.0.1

I Have create a oauth provider from odoo,
Here what i did for use the autherication url like
http://localhost:8080/realms/master/account/#/

Under user form, selected the provider name and choose the realm user id.



Please explain what are the steps i have to follow this.

1
Avatar
Descartar
Avatar
slaiem
Mejor respuesta

it work for me but i when i logout from odoo server the session of keycloak still open is there a solution ?

Thanks again for this app.

0
Avatar
Descartar
Avatar
muhammed noufal
Mejor respuesta

module is not available now, is there any new module available for keyclok

0
Avatar
Descartar
Avatar
Daniel Fourman
Mejor respuesta

On the latest version of odoo and keycloak im getting the following error:


2020-09-21 15:38:59,279 12493 ERROR odoo odoo.addons.auth_oauth.controllers.main: OAuth2: can only concatenate str (not "NoneType") to str

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/controllers/main.py", line 133, in signin

    credentials = env['res.users'].sudo().auth_oauth(provider, kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 96, in auth_oauth

    validation = self._auth_oauth_validate(provider, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth_keycloak/models/res_users.py", line 39, in _auth_oauth_validate

    validation = self._auth_oauth_rpc(oauth_provider.validation_endpoint, access_token, provider)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth_keycloak/models/res_users.py", line 32, in _auth_oauth_rpc

    return requests.get(endpoint, headers={'Authorization': 'bearer ' + access_token}).json()

TypeError: can only concatenate str (not "NoneType") to str

2020-09-21 15:38:59,285 12493 INFO odoo werkzeug: 173.245.52.181 - - [21/Sep/2020 15:38:59] "GET /auth_oauth/signin?error=invalid_request&error_description=Invalid+scopes%3A+False&state={%22d%22%3A+%22odoo%22%2C+%22p%22%3A+6%2C+%22r%22%3A+%22https%253A%252F%252Ferp.f-squared.net%252Fweb%22} HTTP/1.0" 303 - 3 0.007 0.021

It looks like keycloak requires a scope, any suggestions on which scope to use and how to properly configure it?

0
Avatar
Descartar
Bert Driehuis

The scope should include 'openid" if you want to use Keycloak 20.x. I've got mine set to "profile email openid", and this seems to work.

Avatar
Janik Von Rotz
Mejor respuesta

Still workss with Odoo 13! Thanks Hideyuki Otokawa and Karim Gillani :)

0
Avatar
Descartar
Avatar
Karim Gillani
Autor Mejor respuesta

i tried what you suggested but I still get access denied.   To confirm, the keycloak settings:

  1. Edit email mapper

  2. update Token Claim Name: user_id

Also, there is no place to put the endpoint "token"?  What settings do you have on keycloak client settings page?

The error is much less but still occurs..

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/controllers/main.py", line 142, in signin

    credentials = env['res.users'].sudo().auth_oauth(provider, kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 96, in auth_oauth

    validation = self._auth_oauth_validate(provider, access_token)

  File "/usr/lib/python3/dist-packages/odoo/addons/auth_oauth/models/res_users.py", line 36, in _auth_oauth_validate

    raise Exception(validation['error'])

Exception: invalid_request

2019-03-15 07:25:38,722 1 INFO db werkzeug: 17x.xx.xx.xx - - [15/Mar/2019 07:25:38] "GET /auth_oauth/signin?state={%22r%22%3A+%22https%253A%252F%252Fxxx.xxx.xx.xx.xx%252Fweb%22%2C+%22p%22%3A+7%2C+%22d%22%3A+%22db%22}&session_state=9e09a4d7-5e1f-4acf-b120-42ed5fc7e200&access_token=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI1NXhiZzcyaml6NWQ3cEtkbzdwNFhLdTB2VFA2UXMtemthZzFaY1&token_type=bearer&expires_in=900&not-before-policy=1548956992 HTTP/1.1" 303 - 2 0.002 5.115

 Thank you for your help in this..


0
Avatar
Descartar
Hideyuki Otokawa

You do not have to put the endpoint "token".

This is my keycloak client settings;

- access type is confidential

- standard flow is on

- implicit flow is on

OdooBot
Where did you put the client secret?

Regards

On Mar 15, 2019, at 4:32 AM, Hideyuki Otokawa <otokawa.hideyuki@sharp.co.jp> wrote:

You do not have to put the endpoint "token".

This is my keycloak client settings;

- access type is confidential

- standard flow is on

- implicit flow is on

Sent by Odoo S.A. using Odoo.

Hideyuki Otokawa

Without using secret, you can sign-in by keycloak.

Karim Gillani
Autor

Is there any other mapping I need to do, like name? I am unsure why mine is still not working albeit closer than before.

Again, thank you for your assistance.

Hideyuki Otokawa

No. In my investigation of the source codes, the only necessary mapping is email to 'user_id'.

Hideyuki Otokawa

These are my settings.

https://www.dropbox.com/s/hhb8272hj27ngmr/keycloak-client-setting.png?dl=0

https://www.dropbox.com/s/1maobsu29guhuuo/odoo-provider-setting.png?dl=0

Karim Gillani
Autor

I realized I didn't do the patch. Now that I do, I get this error, any suggestions?

Odoo Server Error

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/models.py", line 1108, in _validate_fields

check(self)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 351, in _check_xml

self.postprocess_and_fields(view.model, view_doc, view.id)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1095, in postprocess_and_fields

self.raise_view_error(message, view_id)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 548, in raise_view_error

raise ValueError(message)

ValueError: Field `keycloak` does not exist

Error context:

View `auth.oauth.provider.form`

[view_id: 547, xml_id: n/a, model: auth.oauth.provider, parent_id: n/a]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

self._tags[rec.tag](rec, de, mode=mode)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 662, in _tag_record

record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3821, in _load_records

records = self._load_records_create([data['values'] for data in to_create])

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3735, in _load_records_create

return self.create(values)

File "<decorator-gen-32>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 428, in create

return super(View, self).create(vals_list)

File "<decorator-gen-3>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3552, in create

fields[0].determine_inverse(batch_recs)

File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1097, in determine_inverse

getattr(records, self.inverse)()

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 275, in _inverse_arch

view.write(data)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 444, in write

return super(View, self).write(self._compute_defaults(vals))

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3269, in write

self._write(store_vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3413, in _write

self._validate_fields(vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 1112, in _validate_fields

raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.exceptions.ValidationError: ('Error while validating constraint\n\nField `keycloak` does not exist\n\nError context:\nView `auth.oauth.provider.form`\n[view_id: 547, xml_id: n/a, model: auth.oauth.provider, parent_id: n/a]', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/odoo/http.py", line 654, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception

raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise

raise value

File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in dispatch

result = self._call_function(**self.params)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper

return f(dbname, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call

result = self.endpoint(*a, **kw)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in __call__

return self.method(*args, **kw)

File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap

response = f(*args, **kw)

File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 966, in call_button

action = self._call_kw(model, method, args, {})

File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw

return call_kw(request.env[model], method, args, kwargs)

File "/usr/lib/python3/dist-packages/odoo/api.py", line 749, in call_kw

return _call_kw_multi(method, model, args, kwargs)

File "/usr/lib/python3/dist-packages/odoo/api.py", line 736, in _call_kw_multi

result = method(recs, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/res_config.py", line 637, in execute

self._install_modules(to_install)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/res_config.py", line 34, in _install_modules

result = to_install_modules.button_immediate_install()

File "<decorator-gen-61>", line 2, in button_immediate_install

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 73, in check_and_log

return method(self, *args, **kwargs)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 444, in button_immediate_install

return self._button_immediate_function(type(self).button_install)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 553, in _button_immediate_function

modules.registry.Registry.new(self._cr.dbname, update_module=True)

File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 86, in new

odoo.modules.load_modules(registry._db, force_demo, status, update_module)

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 421, in load_modules

loaded_modules, update_module, models_to_check)

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 313, in load_marked_modules

perform_checks=perform_checks, models_to_check=models_to_check

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph

load_data(cr, idref, mode, kind='data', package=package, report=report)

File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 68, in load_data

tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 801, in convert_file

convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 864, in convert_xml_import

obj.parse(doc.getroot(), mode=mode)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 763, in parse

exc_info[2]

File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise

raise value.with_traceback(tb)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 757, in parse

self._tags[rec.tag](rec, de, mode=mode)

File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 662, in _tag_record

record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3821, in _load_records

records = self._load_records_create([data['values'] for data in to_create])

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3735, in _load_records_create

return self.create(values)

File "<decorator-gen-32>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 428, in create

return super(View, self).create(vals_list)

File "<decorator-gen-3>", line 2, in create

File "/usr/lib/python3/dist-packages/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3552, in create

fields[0].determine_inverse(batch_recs)

File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1097, in determine_inverse

getattr(records, self.inverse)()

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 275, in _inverse_arch

view.write(data)

File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 444, in write

return super(View, self).write(self._compute_defaults(vals))

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3269, in write

self._write(store_vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 3413, in _write

self._validate_fields(vals)

File "/usr/lib/python3/dist-packages/odoo/models.py", line 1112, in _validate_fields

raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.tools.convert.ParseError: "Error while validating constraint

Field `keycloak` does not exist

Error context:

View `auth.oauth.provider.form`

[view_id: 547, xml_id: n/a, model: auth.oauth.provider, parent_id: n/a]

None" while parsing /mnt/extra-addons/auth_oauth/views/auth_oauth_views.xml:3, near

<record id="view_oauth_provider_form" model="ir.ui.view">

<field name="name">auth.oauth.provider.form</field>

<field name="model">auth.oauth.provider</field>

<field name="arch" type="xml">

<form string="arch">

<sheet>

<group>

<field name="name"/>

<field name="client_id"/>

<field name="enabled"/>

<field name="keycloak"/>

<field name="body"/>

</group>

<group>

<field name="auth_endpoint"/>

<field name="scope"/>

<field name="validation_endpoint"/>

<field name="data_endpoint"/>

</group>

</sheet>

</form>

</field>

</record>

Karim Gillani
Autor

A bit further but now I get this error:

odoo.tools.convert.ParseError: "<class 'ValueError'>: "External ID not found in the system: auth_oauth.provider_openerp" while evaluating

"[ref('auth_oauth.provider_openerp')]"" while parsing /mnt/extra-addons/keycloak_oauth/data/auth_oauth_data.xml:34, near

<function model="auth.oauth.provider" name="write">

<value eval="[ref('auth_oauth.provider_openerp')]"/>

<value model="ir.config_parameter" eval="{ 'client_id': obj().env['ir.config_parameter'].get_param('database.uuid'), }"/>

</function>

Karim Gillani
Autor

Ok, I figured it out. I needed to delete the old Oauth and refresh the list then restart. And all is working now.

For others, I ended up copying the auth_oauth folder, updating with the patch mentioned above and placing in /mnt/extra-addons.

Hideyuki Otokawa thank you so much!!!

Avatar
john paul
Mejor respuesta

I have been trying to add Keycloak to Odoo V12 

Can someone provide the addon? 

0
Avatar
Descartar
Janik Von Rotz

https://github.com/Mint-System/Odoo-App-Auth-OAuth-Keycloak

Maybe the same code applies for v13 works for v12. Not sure.

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now