0
0
Spring Bootframework~10 mins

Securing actuator endpoints in Spring Boot - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Securing actuator endpoints
Start Spring Boot App
Actuator Endpoints Enabled
Incoming Request to Actuator
Check Security Config
Authenticate
Authorize Role
Allow or Deny Access
Respond to Request
The app starts with actuator endpoints enabled. When a request comes, security checks if the user is authenticated and authorized before allowing access.
Execution Sample
Spring Boot
management.endpoints.web.exposure.include=health,info
management.endpoint.health.roles=ACTUATOR
management.endpoint.info.roles=ACTUATOR
spring.security.user.name=admin
spring.security.user.password=secret
spring.security.user.roles=ACTUATOR

# Security config to protect endpoints
This config exposes health and info endpoints and secures them with a user having ACTUATOR role.
Execution Table
StepRequest EndpointUser Authenticated?User RoleAccess Granted?Response
1/actuator/healthNoN/ANo401 Unauthorized
2/actuator/healthYesUSERNo403 Forbidden
3/actuator/healthYesACTUATORYes200 OK - Health Info
4/actuator/infoYesACTUATORYes200 OK - App Info
5/actuator/envYesACTUATORNo404 Not Found - Not Exposed
6/actuator/healthNoN/ANo401 Unauthorized
💡 Requests without authentication or proper role are denied; only ACTUATOR role can access exposed endpoints.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
User Authenticatedfalsefalsetruetruetruetruefalse
User RoleN/AN/AUSERACTUATORACTUATORACTUATORN/A
Access Grantedfalsefalsefalsetruetruefalsefalse
Key Moments - 3 Insights
Why does a user with role USER get denied access even if authenticated?
Because the security config requires the ACTUATOR role to access actuator endpoints, as shown in step 2 of the execution_table where access is denied despite authentication.
Why is the /actuator/env endpoint denied even for ACTUATOR role?
Because /actuator/env is not included in the exposed endpoints list (only health and info are exposed), so access is denied as shown in step 5.
What happens if a request is unauthenticated?
The request is denied with 401 Unauthorized immediately, as shown in steps 1 and 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the response at step 3 when the user has ACTUATOR role?
A200 OK - Health Info
B403 Forbidden
C401 Unauthorized
D404 Not Found
💡 Hint
Check the 'Response' column at step 3 in the execution_table.
At which step does the request get denied because the endpoint is not exposed?
AStep 2
BStep 4
CStep 5
DStep 6
💡 Hint
Look for the step where the response says '404 Not Found - Not Exposed' in the execution_table.
If the user role was changed from ACTUATOR to USER at step 4, what would be the access result?
AAccess Granted
BAccess Denied with 403 Forbidden
CAccess Denied with 401 Unauthorized
DAccess Granted only for /actuator/info
💡 Hint
Refer to step 2 where USER role is denied access despite authentication.
Concept Snapshot
Securing actuator endpoints in Spring Boot:
- Enable endpoints in application.properties (e.g., health, info)
- Use Spring Security to require authentication
- Assign ACTUATOR role to users allowed access
- Requests without proper role get 403 Forbidden
- Unauthenticated requests get 401 Unauthorized
- Only exposed endpoints are accessible
Full Transcript
This visual execution trace shows how Spring Boot actuator endpoints are secured. The app starts with actuator endpoints enabled. When a request arrives, the security configuration checks if the user is authenticated and has the ACTUATOR role. If not authenticated, the request is denied with 401 Unauthorized. If authenticated but without the ACTUATOR role, access is denied with 403 Forbidden. Only endpoints listed in the exposure property are accessible. The execution table traces requests to various endpoints with different user roles and shows the resulting access decisions and responses. The variable tracker shows how authentication status, user role, and access granted status change step by step. Key moments clarify common confusions about roles and endpoint exposure. The quiz tests understanding of these execution steps. The snapshot summarizes the main points for quick reference.