IAM对接调试
This commit is contained in:
@@ -75,6 +75,7 @@ public class IamSsoTokenGranter extends AuthorizationCodeGranter {
|
|||||||
|
|
||||||
private static final String IAM_GRANT_TYPE = "authorization_code";
|
private static final String IAM_GRANT_TYPE = "authorization_code";
|
||||||
private static final String BEARER_PREFIX = "Bearer ";
|
private static final String BEARER_PREFIX = "Bearer ";
|
||||||
|
private static final String BASIC_PREFIX = "Basic ";
|
||||||
|
|
||||||
private final IUserClient userClient;
|
private final IUserClient userClient;
|
||||||
private final IamSsoProperties properties;
|
private final IamSsoProperties properties;
|
||||||
@@ -214,6 +215,9 @@ public class IamSsoTokenGranter extends AuthorizationCodeGranter {
|
|||||||
params.put("client_id", properties.getClientId());
|
params.put("client_id", properties.getClientId());
|
||||||
params.put("client_secret", properties.getClientSecret());
|
params.put("client_secret", properties.getClientSecret());
|
||||||
params.put("code", request.getCode());
|
params.put("code", request.getCode());
|
||||||
|
if (StringUtil.isNotBlank(request.getState())) {
|
||||||
|
params.put("state", request.getState());
|
||||||
|
}
|
||||||
params.put("redirect_uri", properties.getRedirectUri());
|
params.put("redirect_uri", properties.getRedirectUri());
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
@@ -231,17 +235,24 @@ public class IamSsoTokenGranter extends AuthorizationCodeGranter {
|
|||||||
|
|
||||||
private String authorizationHeader() {
|
private String authorizationHeader() {
|
||||||
if (StringUtil.isNotBlank(properties.getAuthorization())) {
|
if (StringUtil.isNotBlank(properties.getAuthorization())) {
|
||||||
return properties.getAuthorization();
|
return withBasicPrefix(properties.getAuthorization());
|
||||||
}
|
}
|
||||||
String token = Base64.getEncoder().encodeToString(
|
String token = Base64.getEncoder().encodeToString(
|
||||||
(properties.getClientId() + ":" + properties.getClientSecret()).getBytes(StandardCharsets.UTF_8)
|
(properties.getClientId() + ":" + properties.getClientSecret()).getBytes(StandardCharsets.UTF_8)
|
||||||
);
|
);
|
||||||
return "Basic " + token;
|
return BASIC_PREFIX + token;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String withBasicPrefix(String authorization) {
|
||||||
|
if (StringUtil.startsWithIgnoreCase(authorization, BASIC_PREFIX)) {
|
||||||
|
return authorization;
|
||||||
|
}
|
||||||
|
return BASIC_PREFIX + authorization;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String profileAuthorizationHeader(String accessToken) {
|
private String profileAuthorizationHeader(String accessToken) {
|
||||||
if (StringUtil.isNotBlank(properties.getProfileAuthorization())) {
|
if (StringUtil.isNotBlank(properties.getProfileAuthorization())) {
|
||||||
return properties.getProfileAuthorization();
|
return withBasicPrefix(properties.getProfileAuthorization());
|
||||||
}
|
}
|
||||||
return BEARER_PREFIX + accessToken;
|
return BEARER_PREFIX + accessToken;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user