Java 如何在springbootmicroservices中将用户凭证从zuul发送到microservice模块

Java 如何在springbootmicroservices中将用户凭证从zuul发送到microservice模块,java,spring,security,jwt,microservices,Java,Spring,Security,Jwt,Microservices,我有三个微服务模块:auth服务器、zuul服务器和产品服务器。我想将经过身份验证服务器授权的用户凭据从zuul服务器发送到产品服务器,并在product服务器中获取它 我尝试在zuul服务器头中设置令牌,并从产品服务器获取它。但我在产品服务器中获得null if (username != null) { @SuppressWarnings("unchecked") List<String> authorities = (List<String>) claims.

我有三个微服务模块:auth服务器、zuul服务器和产品服务器。我想将经过身份验证服务器授权的用户凭据从zuul服务器发送到产品服务器,并在product服务器中获取它

我尝试在zuul服务器头中设置令牌,并从产品服务器获取它。但我在产品服务器中获得null

if (username != null) { 
   @SuppressWarnings("unchecked") List<String> authorities = (List<String>) claims.get("authorities"); 
   UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken( username, null, authorities.stream().map( SimpleGrantedAuthority::new ).collect(Collectors.toList()));
   SecurityContextHolder.getContext().setAuthentication(auth);
}
如果(用户名!=null){
@SuppressWarnings(“未选中”)列表权限=(List)claims.get(“权限”);
UsernamePasswordAuthenticationToken auth=新的UsernamePasswordAuthenticationToken(用户名,null,authorities.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());
SecurityContextHolder.getContext().setAuthentication(auth);
}

我希望将此securitycontext发送到另一个microservice模块,以便从中获取用户凭据。

请提供代码示例。如果(用户名!=null){@SuppressWarnings(“未选中”)列表权限=(列表)声明。获取(“权限”);UsernamePasswordAuthenticationToken auth=new UsernamePasswordAuthenticationToken(username,null,authorities.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());SecurityContextHolder.getContext().setAuthentication(auth);我希望将此securitycontext发送到另一个microservice模块,以便可以从中获取用户凭据。请提供代码示例。如果(用户名!=null){@SuppressWarnings(“未选中”)列表权限=(列表)声明。获取(“权限”);UsernamePasswordAuthenticationToken auth=new UsernamePasswordAuthenticationToken(username,null,authorities.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());SecurityContextHolder.getContext().setAuthentication(auth);我希望将此securitycontext发送到另一个microservice模块,以便从中获取用户凭据。