String role = roleMapper.findByUserIdAndOrgId(AuthenticationUtils.getUserId(),po.getId()); SimpleGrantedAuthority grantedAuthority = new SimpleGrantedAuthority(role) ; List<SimpleGrantedAuthority> list = new ArrayList<>(); list.add(grantedAuthority); PreAuthenticatedAuthenticationToken auth = new PreAuthenticatedAuthenticationToken( userDetails, userDetails.getPassword(),list ); auth.setDetails(new WebAuthenticationDetails(request)); SecurityContextHolder.getContext().setAuthentication(auth);
SecurityContextHolder.getContext().setAuthentication(auth)重新设值
最新推荐文章于 2024-10-26 09:24:50 发布