Skip to content

Commit 6f28f41

Browse files
committed
Polish "Simplify some code"
See spring-projectsgh-17860
1 parent 4bb8423 commit 6f28f41

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapper.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ private WebEndpointResponse<Health> createWebEndpointResponse(Health health) {
9797
}
9898

9999
private boolean canSeeDetails(SecurityContext securityContext, ShowDetails showDetails) {
100-
return showDetails != ShowDetails.NEVER && (showDetails != ShowDetails.WHEN_AUTHORIZED
101-
|| (securityContext.getPrincipal() != null && isUserInRole(securityContext)));
100+
if (showDetails == ShowDetails.NEVER || (showDetails == ShowDetails.WHEN_AUTHORIZED
101+
&& (securityContext.getPrincipal() == null || !isUserInRole(securityContext)))) {
102+
return false;
103+
}
104+
return true;
102105
}
103106

104107
private boolean isUserInRole(SecurityContext securityContext) {

0 commit comments

Comments
 (0)