Spring Security Oauth2.0认证授权

21.Spring Security应用详解-授权-web授权

2020-03-28  本文已影响0人  LANSHENGYANG

web授权

@Override
protected void configure (HttpSecurity http) throws Exception {
http
    .authorizeRequests()
    .antMatchers("/r/r1").hasAuthority("p1")
    .antMatchers("/r/r2").hasAuthority("p2")
    .antMatchers("/r/r3").access("hasAuthority('p1') and hasAuthority('p2')")
    .antMatchers("/r/**").authenticated()
    .anyRequest().permitAll()
    .and()
    .formLogin()
    //...
}

注意

.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/admin/login").permitAll()
.antMatchers("/admin/login").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
上一篇下一篇

猜你喜欢

热点阅读