📜  更新角色 spring security - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:38.963000             🧑  作者: Mango

代码示例1
Set authorities = new HashSet<>();
authorities.add(new SimpleGrantedAuthority("USER"));
authorities.add(new SimpleGrantedAuthority("ADMIN"));

Authentication reAuth = new UsernamePasswordAuthenticationToken("user",new 

BCryptPasswordEncoder().encode("password"),authorities);  

SecurityContextHolder.getContext().setAuthentication(reAuth);