-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow members joining multiple organizations #29613
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
Conversation
fef8950 to
1379d88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unreported flaky test detected, please review
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.model.user.UserModelTest#testAddRemoveUserConcurrentKeycloak CI - Store Model Tests org.keycloak.testsuite.model.user.UserModelTest#testAddRemoveUserConcurrentKeycloak CI - Store Model Tests org.keycloak.testsuite.model.user.UserModelTest#testAddRemoveUserConcurrentKeycloak CI - Store Model Tests |
1379d88 to
4bb0fdb
Compare
7d9d70d to
95cc95a
Compare
cc92c0d to
16d784f
Compare
ahus1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving based on @sguilhen's approval. Not merging yet in case a review from another person is necessary.
|
BTW, Adapter IT failed, rerunning that job. |
4fdab18 to
0061b02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unreported flaky test detected, please review
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.LoginHotpTest#loginWithHotpSuccessKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.LoginHotpTest#loginWithHotpFailureKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.LoginHotpTest#loginWithHotpInvalidPasswordKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.LoginHotpTest#loginWithMissingHotpKeycloak CI - Forms IT (chrome) |
vramik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @pedroigor for the PR, I have only few suggestions about naming and one question about caching. I assume there will be needed rebase after #31471 would be merged.
| @GET | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| OrganizationRepresentation getOrganization(@PathParam("id") String id); | ||
| List<OrganizationRepresentation> getOrganization(@PathParam("id") String id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| List<OrganizationRepresentation> getOrganization(@PathParam("id") String id); | |
| List<OrganizationRepresentation> getOrganizations(@PathParam("id") String id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vramik Just realized ... Do we really need this method? Why not just have member(id).getOrganizations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, good catch.
| @DELETE | ||
| Response delete(); | ||
|
|
||
| @Path("organization") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @Path("organization") | |
| @Path("organizations") |
| @QueryParam("max") Integer max | ||
| ); | ||
|
|
||
| @Path("{id}/organization") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @Path("{id}/organization") | |
| @Path("{id}/organizations") |
| UserModel member = getMemberById(organization, user.getId()); | ||
|
|
||
| if (member == null) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rely on CachedMembership instead of getting the member by id? I am probably missing something ... if CachedMembership is not invalidated then we may be able to get the information whether the users is Managed or not from it, don't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the getMemberById returns null is because the user is not a member.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks, so it means that user might not a member, but could still be cached the information within CachedMembership, right?
0061b02 to
770cbe7
Compare
770cbe7 to
24905da
Compare
|
@vramik Applied your suggestions. |
|
@vramik It is rebased already. I'll check now the behavior with your latest changes. |
9e597b3 to
9bb1987
Compare
Closes keycloak#30747 Signed-off-by: Pedro Igor <[email protected]>
Signed-off-by: Pedro Igor <[email protected]>
9bb1987 to
116d685
Compare
mhajas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving based on reviews from @keycloak/core-iam
|
Today I tried Keycloak 25.0.6 but when I try to add user to a second Organization gave a error than the user only can have 1 Organization, is that ok ? |
|
@jaeaxt This was merged into main so will be available in the next major release of Keycloak which is Keycloak 26. |
|
Hey Folks 👋 Great work with orgs so-far. I've just tried out the latest nightly build via , created 2 orgs foo/foo.com and bar/bar.com, and added a user baz/[email protected] as member in both orgs. Now I wanted to login using the new identity first - flow and just "baz". My expectation was that I could somehow "choose" for which org I want to log in. Now I am a bit unsure how, with this PR, it'd be possible to login my [email protected] user under the context of the foo org. It'd be awesome if you had any hints, couldn't find an issue so-far and thought I'd ask here first :) |
|
@DGuhr I just tested here and I see what you mean - if the user has an e-mail that matches one of the orgs, we're being a bit too opinionated towards the IDP selection. In this case, we're narrowing the IDP choices based on the e-mail that matched. @pedroigor we need to discuss how to make this a little less opinionated - if user belongs to more than 1 org, then if none of the orgs has an idp that automatically redirects based on e-mail, we prob should be assembling the IDP list in a way that all orgs the user belongs too are represented (provided they have public IDPs, that is). |
|
If you think about it, even with no public IDPs, if the user is a member of multiple orgs then perhaps a better option would be not to select the IDP itself, but the org he wants to sign in to. Then we redirect to the org IDP, which doesn't even have to be public. |
Hi @sguilhen and @pedroigor. Would this also set which organization the user is "primarily acting on behalf of"? Eg. if you have a consultant or similar working on the behalf of multiple of your clients (but always only on one at a time)? |
|
Hey @Anderen2, no problem. Sometimes I find myself doing the same ... Not ideal because comments usually get lost. There is support for allowing users to select an organization when they are a member of multiple ones. The part of the documentation covering this capability is here [1]. Basically, whenever you send the Is this what you are looking for? [1] https://www.keycloak.org/docs/latest/server_admin/#_mapping_organization_claims_ |
Closes #30747
OrganizationAuthenticatorwas refactored to make it simpler and to support members of multiple organizationskc.orguser attributekc.orguser attribute