Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Keycloak Authentication on v12

Subscriure's

Get notified when there's activity on this post

This question has been flagged
8 Respostes
17238 Vistes
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
Best Answer

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
Best Answer

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
Best Answer

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
Best Answer

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

0
Avatar
Descartar
Avatar
Janik Von Rotz
Best Answer

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

0
Avatar
Descartar
Avatar
Daniel Fourman
Best Answer

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
john paul
Best Answer

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.

Avatar
Karim Gillani
Autor Best Answer

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!!!

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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