Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

update role spring security

Set<GrantedAuthority> 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);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #update #role #spring #security
ADD COMMENT
Topic
Name
9+7 =