| | |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.oauth2.provider.OAuth2Authentication; |
| | |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | public class Oauth2AuthSuccessHandler implements ServerAuthenticationSuccessHandler { |
| | | @SneakyThrows |
| | | @Override |
| | | public Mono<Void> onAuthenticationSuccess(WebFilterExchange webFilterExchange, Authentication authentication) { |
| | | MultiValueMap<String, String> headerValues = new LinkedMultiValueMap(4); |
| | |
| | | //如果有组织架构 |
| | | if(organizations!=null && organizations.size()==2){ |
| | | headerValues.add(SecurityConstants.USER_ORG_ID_HEADER,String.valueOf(organizations.get(0).getId())); |
| | | headerValues.add(SecurityConstants.USER_ORG_NAME_HEADER,organizations.get(0).getOrgName()); |
| | | headerValues.add(SecurityConstants.USER_ORG_NAME_HEADER, URLEncoder.encode(organizations.get(0).getOrgName(),"UTF-8")); |
| | | headerValues.add(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(organizations.get(1).getId())); |
| | | headerValues.add(SecurityConstants.USER_DEP_NAME_HEADER,organizations.get(1).getOrgName()); |
| | | headerValues.add(SecurityConstants.USER_DEP_NAME_HEADER,URLEncoder.encode(organizations.get(1).getOrgName(),"UTF-8")); |
| | | tenantId=String.valueOf(organizations.get(0).getId()); |
| | | } |
| | | } |