How to have multiple data sources

435 views
Skip to first unread message

Sultan Omashev

unread,
Mar 7, 2023, 6:42:25 AM3/7/23
to Keycloak User
Hello.

I want to use one Keycloak instance with multiple realms. And each realm has to store users in different databases.

How can I configure Keycloak to have different data sources for each realm?

SadaShiv Dash

unread,
Mar 7, 2023, 12:51:15 PM3/7/23
to Keycloak User
Hello @sultan,

It is not possible in keycloak. What are you trying to accomplished ?

Björn Eickvonder

unread,
Aug 10, 2023, 11:24:46 AM8/10/23
to Keycloak User

I need the same because we use a realm per corporate customer and some customers have the requirement of having their data completely separated.

And I remember some posting that Keycloak team has plans for  this feature but I can’t find the post or issue any more, thus I don’t know its status. 
Can anyone point me to that post?

Sada Shiv Dash

unread,
Aug 10, 2023, 12:03:51 PM8/10/23
to Björn Eickvonder, Keycloak User
Yes , Multiple data sources is currently not supported by keycloak. Keycloak has only one session factory to connect to single database. 

So , I would recommend if you host keycloak per realm for this kind of requirement.



Regards
Sada Shiv Dash

On 10-Aug-2023, at 8:54 PM, Björn Eickvonder <b.e...@gmx.net> wrote:


--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/056386dd-e8f3-482f-b310-af56c46e8719n%40googlegroups.com.
Message has been deleted

Niko Köbler

unread,
Aug 12, 2023, 11:54:35 AM8/12/23
to Keycloak User
Hi Björn,
I don't have any post at hand where this is mentioned, but AFAIK this should become possible with the new Map Storage SPI (currently experimental and no ETA available).

For the time being, the only option would be to implement the User Storage SPI pointing on a custom database per realm. This way, you'll get complete user data separation.

Cheers,
- Niko

Kalyan Dasika

unread,
Aug 12, 2023, 1:26:15 PM8/12/23
to Keycloak User
We implemented a custom user provider (User Federation) as an extension. All our users are external to keycloak.

Regards
Kalyan

--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages