Implementing schema based multi tenancy in springboot application that is secured using keycloak

故事扮演 提交于 2019-12-11 18:28:19

问题




I have a springboot application linked to a postgresql database. The app is secured using keycloak (keycloak springboot adapter). The idea is to have multiple schemas in the postgres database for different groups of users that login. I hope to identify the user-group using the keycloak token that is received by rest endpoints on the springboot server and then access the respective schema.

Where should I start ? Can anyone point me to a guide for this ? or is there any other better approach ? Any help would be appreciated.

edit ::
Let me try narrowing it down a bit. Lets say the db has the schemas : public, tenant1, tenant2, tenant3. In the keycloak server, I have two clients in the same realm, one for spring boot app and one for my website. I have 3 groups. group 1 has users A and B, group 2 has users C and D, group 3 has users E and F. If the user A logs into the website, he has a keycloak token that is going to help him get the data through ajax requests from the springboot server. I assume that, the incoming ajax request could provide the kc token which would tell spring boot that user A is requesting the data and he belongs to group 1. Here, I want the spring boot server to figure out that the data has to be fetched from the schema "tenant1" and do accordingly. Similarly, group 2 should be directed to tenant2 and group 3 to tenant 3. I want support on the part where the spring boot has to figure out the user and the group and access the right schema..

Cheers,
Vikram

来源:https://stackoverflow.com/questions/52724191/implementing-schema-based-multi-tenancy-in-springboot-application-that-is-secure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!