r/KeyCloak • • Sep 21 '26

Using Keycloak with LDAP users as authentication for Odoo?

I am currently in the process of setting up Keycloak with LDAP as a log in option for Odoo - I can log into the keycloak realm without issue but I get

You do not have access to this database or your invitation has expired. Please ask for an invitation and be sure to follow the link in your invitation email.

The user's email exists as an account inside Odoo, and the emails match properly. Any idea what could be going on here? I have attached my Odoo keycloak config as well.

8 Upvotes

2 comments sorted by

1

u/MLabs-Haskell Oct 05 '26

Odoo never matches an OAuth login on email. In Odoo 17's OAuth module, the sign-in code looks the user up by OAuth user ID plus provider, and nothing else. If that finds no one, it tries to sign up a new user. When that fails, because signup is off or the login already exists (your case), it raises AccessDenied. The controller turns that into oauth_error=3, which is exactly the "invitation has expired" text you're seeing.

So the matching emails never come into it. Two ways out.

  1. On the existing Odoo user, set the OAuth provider and fill in "OAuth User ID" with the subject Keycloak sends. Odoo reads sub first, and in Keycloak that's the ID on the user's Details page. The LDAP username and the email play no part.
  2. Send the user an Odoo invitation and have them follow the link, then log in with the Keycloak button from there. The invitation token travels in the OAuth state, and signup with a token writes the OAuth fields onto the existing user.

With more than a handful of users, option 1 is easy to script over XML-RPC against res.users.

1

u/FootballRemarkable53 Oct 05 '26 edited Oct 05 '26

I'm working with Odoo 19, and setting up keycloak seemed to require installing and using the Authentication OpenID Connect app. I am currently trying to find the OAuth User ID field on my existing working user but I dont see that field anywhere on the front any. Is this something only viewable from the database?

I think once I figure this out, Option 1 is the only realistic method, I have a bunch of Odoo users already created, just need to let them access it properly.

EDIT: Ive got it working! appreciate the help o7