Skip to content

Commit

Permalink
Merge pull request #44 from levigo/fix/NF-1928-no-auth-authentication…
Browse files Browse the repository at this point in the history
…-problem

fix(NF-1928): add authentication null check
  • Loading branch information
ebidosm authored Jan 10, 2025
2 parents c23bffb + 89f1b29 commit 2a59b15
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 2a59b15

Please sign in to comment.