Skip to content

Conversation

@mhajas
Copy link
Contributor

@mhajas mhajas commented May 4, 2022

Closes #11769

@mhajas mhajas added area/storage Indicates an issue that touches storage (change in data layout or data manipulation) team/storage-sig labels May 4, 2022
@ahus1 ahus1 self-requested a review May 4, 2022 09:50
Copy link
Contributor

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the changes for LDAP and briefly at the other changes as well.

The LDAP changes are fine for now as will retrieve all roles, and then use the CHM criteria to filter out the right roles.

Please open a LDAP issue to add a more efficient implementation for LDAP and assign this to me.

@mhajas
Copy link
Contributor Author

mhajas commented May 4, 2022

Thank you for the review @ahus1. I created an issue: #11836 feel free to add more details.

Comment on lines +68 to +72
return new JpaRoleModelCriteriaBuilder((cb, root) ->
cb.isTrue(cb.function("@>",
Boolean.TYPE,
cb.function("->", JsonbType.class, root.get("metadata"), cb.literal("fCompositeRoles")),
cb.literal(convertToJson(value[0]))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vramik @ahus1 Is this search supported by any index?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hmlnarik - probably not. At the same time I would assume that composite roles might soon move to its own table to follow along the discussion found here to allow adding or removing an entry to the composite roles without loading the rest of the entity: #11799

Depending on where that other PR will move to and how the performance improvements are, I wanted to call for a meeting on that topic to discuss how to handle situation where an attribute can contain a big collection of entries.

Copy link
Contributor

@vramik vramik May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hmlnarik, that is correct what @ahus1 wrote, there is no index atm to support the search. I can also see the separation composite roles to its own table in near future (probably as a follow-up PR of this one)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to keep this as is in this PR. Could you please file a GH issue that points to this discussion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return new JpaRoleModelCriteriaBuilder((cb, root) ->
cb.equal(root.get(modelField.getName()), value[0])
);
} else if (modelField == SearchableFields.COMPOSITE_ROLE){
Copy link
Contributor Author

@mhajas mhajas May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized I am using a different comparison method here. I am using == while everywhere else is the equals method call. If I am not mistaken, both should work the way we want. Should I change this to use the equals method as well? Or it is okay to leave this as is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, when thinking about it and reading[1], I believe we should be using == instead of equals. I'd create follow-up task to update it in all other places if we agree on it. I'll bring it up in the mtg.

[1] https://docs.oracle.com/javase/specs/jls/se9/html/jls-8.html#jls-8.9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with changing it to == as we want to have only one instance of each SearchableField, however, SearchableFields are not enum. That is probably why there was equals method used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for using ==, the fields should be the same instances as the predefined ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@hmlnarik hmlnarik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving per @ahus1 and @vramik 's approvals

@hmlnarik hmlnarik merged commit fc974fc into keycloak:main May 5, 2022
@mhajas mhajas deleted the 11769-MapStorage-is-not-removing-compositeRoles-reference-when-roles-are-removed branch July 7, 2022 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Indicates an issue that touches storage (change in data layout or data manipulation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapStorage is not removing compositeRoles reference when roles are removed

4 participants