Mas*_*ind 2 java spring-security spring-boot
我在Spring-boot中使用Spring-security.我的应用程序是POC,目前不需要具有角色.
我想知道是否有可能有一个自定义UserDetailsService其返回UserDetails的loadUserByUsername方法,但没有GrantedAuthority,也没有UserRole阶级.
我一整天用谷歌搜索了一个例子,但我总是用它们来获取它们UserRole.
提前致谢
这应该工作:
让UserDetails返回一个空集合getAuthorities():
public class User implements UserDetails {
...
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return new HashSet<GrantedAuthority>();
}
}
Run Code Online (Sandbox Code Playgroud)只使用authenticated()在配置安全
http.authorizeRequests()
...
.antMatchers("/foo").authenticated()
...
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
2666 次 |
| 最近记录: |