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

[ELY-2780] Logging in aggregaterealm changes authentication and authorization flow #2176

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,14 @@ public AggregateSecurityRealm(final SecurityRealm authenticationRealm, Function<
public RealmIdentity getRealmIdentity(final Evidence evidence) throws RealmUnavailableException {
boolean ok = false;
final RealmIdentity authenticationIdentity = authenticationRealm.getRealmIdentity(evidence);
if (authenticationIdentity.exists()) {
log.tracef("Authentication identity for principal [%s] found.", evidence.getDecodedPrincipal());
}
log.tracef("Authentication identity for principal [%s] obtained.", evidence.getDecodedPrincipal());
final RealmIdentity[] authorizationIdentities = new RealmIdentity[authorizationRealms.length];
try {
for (int i = 0; i < authorizationIdentities.length; i++) {
SecurityRealm authorizationRealm = authorizationRealms[i];
authorizationIdentities[i] = (authorizationRealm == authenticationRealm) ? authenticationIdentity
: getAuthorizationIdentity(authorizationRealm, evidence, principalTransformer, authenticationIdentity);
if (authorizationIdentities[i].exists()) {
log.tracef("Authorization identity for principal [%s] found.", evidence.getDecodedPrincipal());
}
log.tracef("Authorization identity for principal [%s] obtained.", evidence.getDecodedPrincipal());
}

final Identity identity = new Identity(authenticationIdentity, authorizationIdentities);
Expand All @@ -111,9 +107,7 @@ public RealmIdentity getRealmIdentity(final Evidence evidence) throws RealmUnava
public RealmIdentity getRealmIdentity(final Principal principal) throws RealmUnavailableException {
boolean ok = false;
final RealmIdentity authenticationIdentity = authenticationRealm.getRealmIdentity(principal);
if (authenticationIdentity.exists()) {
log.tracef("Authentication identity for principal [%s] found.", principal);
}
log.tracef("Authentication identity for principal [%s] obtained.", principal);
Principal authorizationPrincipal = principal;
if (principalTransformer != null) {
authorizationPrincipal = principalTransformer.apply(authorizationPrincipal);
Expand All @@ -125,9 +119,7 @@ public RealmIdentity getRealmIdentity(final Principal principal) throws RealmUna
for (int i = 0; i < authorizationIdentities.length; i++) {
SecurityRealm authorizationRealm = authorizationRealms[i];
authorizationIdentities[i] = (authorizationRealm == authenticationRealm) && (principalTransformer == null) ? authenticationIdentity : authorizationRealm.getRealmIdentity(authorizationPrincipal);
if (authorizationIdentities[i].exists()) {
log.tracef("Authorization identity for principal [%s] found.", principal);
}
log.tracef("Authorization identity for principal [%s] obtained.", principal);
}

final Identity identity = new Identity(authenticationIdentity, authorizationIdentities);
Expand Down
Loading