Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Your application validates from both the realms #2

Open
AasthaSethia opened this issue May 25, 2021 · 7 comments
Open

Your application validates from both the realms #2

AasthaSethia opened this issue May 25, 2021 · 7 comments

Comments

@AasthaSethia
Copy link

Ideally realm A should only be allowed to access endpoint with realm A in it but in your application once login has happened via realm a, even endpoint with realm B is accessed. can you please guide me what can be done to rectify this?

@javali
Copy link

javali commented May 26, 2021

You have a clear authentication context. You may place the tenant identification on the principal and e.g. annotate endpoints to match this. You could even add some logic in between that ties a user and a tenant to a business defined "functional role" per tenant. There are endless possibilities.

@czetsuya
Copy link
Owner

There are tons of solution to this problem. At the top of my head you can separate the set of endpoints per tenant by adding a prefix to the URL like /tenant1/api/ then use Spring Aspect around invoke to compare the value of the realm to the one in the URL. But really, it's already up to you.

@AasthaSethia
Copy link
Author

Can you suggest an example with spring Aspect?

@goafabric
Copy link

ok .. i've now searching for weeks for a solution until finding this single issue here ...
can someone please give a working example here ?
honestly quoting "there are endless possibilities" or "tons of solutions" does not help much ..
people come here to find a working solution
and with the defunct (basically already in keycloak adapter) of no seperations between realms, renders this solution practically useless

@czetsuya
Copy link
Owner

Hi @goafabric, can you describe what specifically is your problem and why this solution does not work for your use case?

@goafabric
Copy link

hi @czetsuya as @AasthaSethia already described ...
The moment you change the tenant /realm i would expect that you have to relogin if not already authenticated
INstead nothing happens, and the authenticated user for tenant a is also authenticated for tenant b.

I guess (the combination of) spring securoty and the keycloak adapter does not take the tenantid into account of the session ...

So it would be nice to have a working example.

e.g. the Quarkus OIDC Implementation does everything right of the box .. simple multi tenancy and when changing you have to relogin

@asharma-a10
Copy link

Hi, @goafabric @AasthaSethia did you figure out the workaround for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants