Skip to content

Conversation

@Skyllarr
Copy link
Contributor

@Skyllarr Skyllarr commented Jul 14, 2025

@Skyllarr Skyllarr requested a review from fjuma as a code owner July 14, 2025 10:14
@Skyllarr Skyllarr requested a review from darranl July 14, 2025 10:16
@Skyllarr
Copy link
Contributor Author

@rsearls Please review, thank you!

@Skyllarr
Copy link
Contributor Author

The tests for this change are here wildfly-security/elytron-web#285

Copy link
Contributor

@darranl darranl left a comment

Choose a reason for hiding this comment

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

I am going to have a further look but I think we need to continue to find a solution that does not result in JAAS APIs leaking into the Elytron public APIs and also does not iterate all roles for all realm types as that will be a big performance overhead.

*/
Principal getRealmIdentityPrincipal();

default Subject getSubject() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not keen on this part of the change, the RealmIdentity / SecurityIdentity APIs are deliberatly an alternative to using the JAAS Subject - I understand why the JAAS realm is Subject aware as it is based on JAAS but other realms should not have this added.

return this.identityCache.apply(securityDomain);
}

private static class Roles implements Principal {
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually have something coming the Jakarta EE 11 migration work that may provide an alternative for this.

* @param realmIdentity
*/
public void setSubject(RealmIdentity realmIdentity) {
checkNotNullParam("realmIdentity", realmIdentity);
Copy link
Contributor

Choose a reason for hiding this comment

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

This naming feels off to me, when I see a setClassName method I expect that the argument being passed in is an instance of that class name AND it is being set on the object that was called - this looks more like a utility method doing something else.

subject = new Subject();
Set<Principal> principals = subject.getPrincipals();
principals.add(realmIdentity.getRealmIdentityPrincipal());
cachedIdentity.getRoles().forEach(role -> principals.add(new Roles(role)));
Copy link
Contributor

Choose a reason for hiding this comment

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

This call is going to end up being applicable to all security realms, whilst JAAS may pro-actively load all roles in advance for others it is intended to be much more dynamic - in general this is why we prefer checking an identity is in a required role rather than listing all roles.

For configurations with a large set of roles this is going to be a big overhead with the end result being this Subject that they don't actually care about being immediately dropped and garbage collected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@darranl Btw, you are the author of the commit where these changes come from, IIRC I took this commit from this PR #2247 , I just added a smaller commit on top of it. I thought the commit from the PR that @pedro-hos created was approved before so I did not really go through it, but I should have

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

Successfully merging this pull request may close these issues.

3 participants