问题
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