【发布时间】:2016-10-19 22:43:24
【问题描述】:
我有
/welcome/employees - 员工名单
/welcome/employees/edit/ - 编辑员工
/welcome/employees/find/ - 查找员工
我想定义ADMIN 来访问所有内容,但USER 只是为了查看列表和查找。
我应该如何进行相应的配置。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/welcome", "/welcome/employees", "/welcome/employee/find").access("hasRole('ROLE_USER')")
.antMatchers("/welcome/**").access("hasRole('ROLE_ADMIN')")
.and()
.formLogin().loginPage("/login")
.defaultSuccessUrl("/welcome")
.failureUrl("/login?error")
.usernameParameter("username").passwordParameter("password")
.and()
.logout().logoutSuccessUrl("/login?logout");
}
【问题讨论】:
标签: spring spring-mvc spring-security spring-boot