Skip to content

Commit

Permalink
fix(NF-1928): add authentication null check
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidosm committed Jan 8, 2025
1 parent c23bffb commit 89f1b29
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean isAccessAllowed(final String resourceSpecifier, final Set<Action>
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

List<AccessRule> matchingRules = policy.getRules().stream() //
.filter(authentication.isAuthenticated() //
.filter(null != authentication && authentication.isAuthenticated() //
? (r) -> matchesAuthentication(r, authentication) //
: this::matchesAnonymousUser) //
.filter(r -> matchesResource(r, resourceSpecifier)) //
Expand All @@ -101,7 +101,7 @@ public boolean isAccessAllowed(final String resourceSpecifier, final Set<Action>
policy.getDefaultEffect() != null ? policy.getDefaultEffect() : Effect.DENY;

LOGGER.debug("Authorization for {} on {} with principal {}: {}", actions, resourceSpecifier,
authentication.isAuthenticated() ? authentication.getPrincipal() : "anonymous", e);
authentication != null && authentication.isAuthenticated() ? authentication.getPrincipal() : "anonymous", e);

return e == Effect.ALLOW;
}
Expand Down

0 comments on commit 89f1b29

Please sign in to comment.