我正在设计一组用于访问URL的REST API。按我的要求有两个网址:REST URL的拦截URL模式
http://localhost:3126/securitydemo/webapi/db/students
查看所有不需要的访问学生和
http://localhost:3126/securitydemo/webapi/db/students/1
仅ROLE_USER
是允许的。
我的春天安全配置:
<http auto-config="true" use-expressions="true">
<intercept-url pattern="**/students/*" access="hasRole('ROLE_USER')" />
<http-basic/>
</http>
如果我使用模式**/students/*
没有基本的安全弹出窗口出现。如果我使用/**
它正常工作。
如何拦截具有不同安全级别的两个网址?
我的REST服务类:
@Path("/db")
@Produces(MediaType.APPLICATION_JSON)
public class StudentService {
static StudentDao data = new StudentDaoImpl();
@Path("/students")
@GET
public Response getStudents(){
GenericEntity<List<Student>> entity = new GenericEntity<List<Student>>(data.getAllStudents()){};
return Response.ok(entity).build();
}
@Path("/students/{id}")
@GET
public Response getStudent(@PathParam("id") int id){
return Response.ok(data.getStudent(id)).build();
}
}
的可能的复制(http://stackoverflow.com/questions/43704389/antmatchers [antMatchers该路径的任何开头匹配] -that-matches-any-beginning-of-path) – dur
你缺少一个'/'。试试'/ **/students/*'。 – dur