Skip to content

Instantly share code, notes, and snippets.

@altfatterz
Created February 22, 2014 11:51
Show Gist options
  • Select an option

  • Save altfatterz/9152747 to your computer and use it in GitHub Desktop.

Select an option

Save altfatterz/9152747 to your computer and use it in GitHub Desktop.
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(auth.getAuthorities());
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
Authentication newAuth = new UsernamePasswordAuthenticationToken(auth.getPrincipal(), auth.getCredentials(), authorities);
SecurityContextHolder.getContext().setAuthentication(newAuth);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment