Skip to content
Advertisement

Tag: spring

Using static methods with Spring Security to get current user details

I have a requirement to get the details of the current user who has been loggedIn. To get the details, we can use the SecurityContextHolder.getContext() and extract the details. According to, SecurityContextHolder, SecurityContext and Authentication Objects By default, the SecurityContextHolder uses a ThreadLocal to store these details, which means that the security context is always available to methods in the

How to properly access a secured Spring Data REST Repository in a ApplicationRunner?

I followed the documentation on how to secure REST repositories with @PreAuthorize. However, the following repository needs to be accessed by an ApplicationRunner to perform some initial setup tasks after application startup. Since there’s no security context active when this runner is executed the application won’t start at all What are my options to access the REST repository properly? I’m

Spring actuator ‘/auditevents’ endpoint returns 404

I am getting a 404 error when invoking /actuator/auditevents endpoint. Upon closer look, I see that available endpoint listing doesn’t include /auditevents endpoint. pom.xml dependencies application.properties management.endpoints.web.exposure.include=* http://localhost:8080/actuator output Spring-boot version: 2.2.6.RELEASE Not sure whether I am missing any required configuration. Answer Auditing can be enabled by providing a bean of type AuditEventRepository in your application’s configuration. Try to add

Advertisement