1

I'm trying to add security on a Jersey(2.x) rest controller on a Spring boot(1.2.5) application. My Project use spring boot starter: web, security and jersey.

The Spring Security config

@EnableGlobalMethodSecurity(jsr250Enabled = true)
@EnableWebMvcSecurity
public class WebConfiguration extends WebMvcConfigurerAdapter {}

The Jersey rest controller

@Named
@Path("test")
public class JerseyEndPoint {

    @GET
    @RolesAllowed("ADMIN")
    public String message() {
        return "Hello";
    }

}

The security doesn't works (any user can access to the rest controller) But the security works with a Spring controller

@RestController
public class SpringEndPoint {

    @RequestMapping(value = "test", method = RequestMethod.GET)
    @RolesAllowed("ADMIN")
    public String message() {
        return "Hello";
    }
}

Thanks in advance for you help

herau
  • 1,466
  • 2
  • 18
  • 36

0 Answers0