IAM
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
package com.chinaunicom.mall.ebtp.extend.iam.client;
|
package com.chinaunicom.mall.ebtp.extend.iam.client;
|
||||||
|
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.*;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.*;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamEmployee;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamEmployeeDTO;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamUser;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamUserDTO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -56,7 +56,7 @@ public interface IamClient {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
@GetMapping("/sign/login/jwt/employee")
|
@GetMapping("/sign/login/jwt/employee")
|
||||||
IamAuthResponseDTO<IamEmployee> employee(@RequestParam("jwt") String jwt);
|
IamAuthResponseDTO<IamEmployeeDTO> employee(@RequestParam("jwt") String jwt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息接口
|
* 获取用户信息接口
|
||||||
@ -64,7 +64,7 @@ public interface IamClient {
|
|||||||
* @return IamUserDTO 用户信息
|
* @return IamUserDTO 用户信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/sign/api/oauth/v20/me")
|
@GetMapping("/sign/api/oauth/v20/me")
|
||||||
IamUser me(@RequestHeader("Authorization") String authorization);
|
IamUserDTO me(@RequestHeader("Authorization") String authorization);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* code换token
|
* code换token
|
||||||
@ -83,6 +83,6 @@ public interface IamClient {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
@GetMapping("/sign/authz/oauth/v20/token")
|
@GetMapping("/sign/authz/oauth/v20/token")
|
||||||
IamToken token(@RequestHeader("Authorization") String authorization, IamTokenRequestDTO request);
|
IamTokenDTO token(@RequestHeader("Authorization") String authorization, IamTokenRequestDTO request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
|||||||
import com.chinaunicom.mall.ebtp.extend.iam.client.BidRatioClient;
|
import com.chinaunicom.mall.ebtp.extend.iam.client.BidRatioClient;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.constant.IamEnum;
|
import com.chinaunicom.mall.ebtp.extend.iam.constant.IamEnum;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.*;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.*;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamEmployee;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamEmployeeDTO;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamUser;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamUserDTO;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.service.IamAuthService;
|
import com.chinaunicom.mall.ebtp.extend.iam.service.IamAuthService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -73,8 +73,8 @@ public class IamAuthController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("IAM单点登陆 - jwt使用员工号免密登录")
|
@ApiOperation("IAM单点登陆 - jwt使用员工号免密登录")
|
||||||
@GetMapping("/jwt")
|
@GetMapping("/jwt")
|
||||||
public BaseResponse<IamEmployee> employee(@RequestParam("jwt") String jwt) {
|
public BaseResponse<IamEmployeeDTO> employee(@RequestParam("jwt") String jwt) {
|
||||||
IamAuthResponseDTO<IamEmployee> response = iamAuthService.employee(jwt);
|
IamAuthResponseDTO<IamEmployeeDTO> response = iamAuthService.employee(jwt);
|
||||||
if (Objects.equals(response.getStatusCodeValue(), IamEnum.IAM_RESP_SUCCESS_CODE.getCode())) {
|
if (Objects.equals(response.getStatusCodeValue(), IamEnum.IAM_RESP_SUCCESS_CODE.getCode())) {
|
||||||
return BaseResponse.success(response.getMsg(), response.getData());
|
return BaseResponse.success(response.getMsg(), response.getData());
|
||||||
} else {
|
} else {
|
||||||
@ -90,7 +90,7 @@ public class IamAuthController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("IAM单点登陆 - 获取用户信息接口")
|
@ApiOperation("IAM单点登陆 - 获取用户信息接口")
|
||||||
@GetMapping("/getUser")
|
@GetMapping("/getUser")
|
||||||
public BaseResponse<IamUser> getUser(@RequestParam("token") String token){
|
public BaseResponse<IamUserDTO> getUser(@RequestParam("token") String token){
|
||||||
return BaseResponse.success(iamAuthService.me(token));
|
return BaseResponse.success(iamAuthService.me(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class IamAuthController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("IAM单点登陆 - code换token")
|
@ApiOperation("IAM单点登陆 - code换token")
|
||||||
@GetMapping("/getTokenByCode")
|
@GetMapping("/getTokenByCode")
|
||||||
public BaseResponse<IamToken> getTokenByCode(IamTokenRequestDTO request) {
|
public BaseResponse<IamTokenDTO> getTokenByCode(IamTokenRequestDTO request) {
|
||||||
String authorization = "";
|
String authorization = "";
|
||||||
return BaseResponse.success(iamAuthService.getToken(authorization, request));
|
return BaseResponse.success(iamAuthService.getToken(authorization, request));
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
* IAM单点登陆Token令牌实体类
|
* IAM单点登陆Token令牌实体类
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class IamToken {
|
public class IamTokenDTO {
|
||||||
// 访问令牌
|
// 访问令牌
|
||||||
private String access_token;
|
private String access_token;
|
||||||
// 刷新令牌
|
// 刷新令牌
|
@ -3,7 +3,7 @@ package com.chinaunicom.mall.ebtp.extend.iam.entity.data;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IamEmployee {
|
public class IamEmployeeDTO {
|
||||||
private String[] authorities;
|
private String[] authorities;
|
||||||
private String displayName;
|
private String displayName;
|
||||||
private String email;
|
private String email;
|
@ -12,7 +12,7 @@ import java.io.Serializable;
|
|||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel(value = "IamUser对象", description = "人员基本信息表")
|
@ApiModel(value = "IamUser对象", description = "人员基本信息表")
|
||||||
public class IamUser implements Serializable {
|
public class IamUserDTO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
/** 生日 */
|
/** 生日 */
|
||||||
private String birthday;
|
private String birthday;
|
@ -2,8 +2,8 @@ package com.chinaunicom.mall.ebtp.extend.iam.service;
|
|||||||
|
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.client.IamClient;
|
import com.chinaunicom.mall.ebtp.extend.iam.client.IamClient;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.*;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.*;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamEmployee;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamEmployeeDTO;
|
||||||
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamUser;
|
import com.chinaunicom.mall.ebtp.extend.iam.entity.data.IamUserDTO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -30,15 +30,15 @@ public class IamAuthService {
|
|||||||
return iamClient.authorize(request);
|
return iamClient.authorize(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IamAuthResponseDTO<IamEmployee> employee(String jwt) {
|
public IamAuthResponseDTO<IamEmployeeDTO> employee(String jwt) {
|
||||||
return iamClient.employee(jwt);
|
return iamClient.employee(jwt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IamUser me(String token){
|
public IamUserDTO me(String token){
|
||||||
return iamClient.me(token);
|
return iamClient.me(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IamToken getToken(String authorization, IamTokenRequestDTO request) {
|
public IamTokenDTO getToken(String authorization, IamTokenRequestDTO request) {
|
||||||
return iamClient.token(authorization, request);
|
return iamClient.token(authorization, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user