| | |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_HEADER, user.getUsername()); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_REAL_NAME, "");//待完善 |
| | | List<SysOrganization> organizations = (List<SysOrganization>) user.getOrganizations(); |
| | | //如果没有有组织架构 |
| | | //将组织数据 存到header 里面 |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORGS_HEADER, JSON.toJSONString(organizations)); |
| | | // log.error("用户ID写入Header成功,用户ID为:"+String.valueOf(user.getId())); |
| | | organizations.sort((e1,e2)->e1.getOrgLevel().compareTo(e2.getOrgLevel())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_ID_HEADER,String.valueOf(organizations.get(0).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_NAME_HEADER, URLEncoder.encode(organizations.get(0).getOrgName(),"UTF-8")); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(organizations.get(organizations.size()-1).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_NAME_HEADER,URLEncoder.encode(organizations.get(organizations.size()-1).getOrgName(),"UTF-8")); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORGS_HEADER,JSON.toJSONString(organizations.get(organizations.size()-1))); |
| | | //将角色放到header |
| | | ctx.addZuulRequestHeader(SecurityConstants.ROLE_HEADER, JSON.toJSONString(user.getRoles())); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | ctx.addZuulRequestHeader(SecurityConstants.TENANT_HEADER, tenantId); |
| | | ctx.addZuulRequestHeader(SecurityConstants.CLIENT_HEADER, clientId); |
| | | ctx.addZuulRequestHeader(SecurityConstants.ROLE_HEADER, CollectionUtil.join(authentication.getAuthorities(), ",")); |
| | | |
| | | } |
| | | return null; |
| | | } |