提交 3753e3b9 编写于 作者: 智布道's avatar 智布道 👁

👽 AuthConfig 中 CodingGroupName 改为 DomainPrefix

上级 bc3af963
......@@ -2,8 +2,8 @@ package me.zhyd.oauth.config;
import com.xkcoding.http.config.HttpConfig;
import lombok.*;
import me.zhyd.oauth.enums.scope.AuthScope;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.utils.StringUtils;
import java.util.List;
......@@ -66,13 +66,17 @@ public class AuthConfig {
private String agentId;
/**
* 使用 Coding 登录时,需要传该值
* 域名前缀
* <p>
* 团队域名前缀,比如以“ https://justauth.coding.net/ ”为例,{@code codingGroupName} = justauth
* 使用 Coding 登录和 Okta 登录时,需要传该值。
* <p>
* Coding 登录:团队域名前缀,比如以“ https://justauth.coding.net ”为例,{@code domainPrefix} = justauth
* <p>
* Okta 登录:Okta 账号域名前缀,比如以“ https://justauth.okta.com ”为例,{@code domainPrefix} = justauth
*
* @since 1.15.5
* @since 1.16.0
*/
private String codingGroupName;
private String domainPrefix;
/**
* 针对国外服务可以单独设置代理
......@@ -138,4 +142,26 @@ public class AuthConfig {
* @since 1.15.9
*/
private boolean pkce;
/**
* Okta 授权服务器的 ID, 默认为 default。如果要使用自定义授权服务,此处传实际的授权服务器 ID(一个随机串)
* <p>
* 创建自定义授权服务器,请参考:
* <p>
* ① https://developer.okta.com/docs/concepts/auth-servers
* <p>
* ② https://developer.okta.com/docs/guides/customize-authz-server
*
* @since 1.16.0
*/
private String authServerId;
/**
* 适配 builder 模式 set 值的情况
*
* @return authServerId
*/
public String getAuthServerId() {
return StringUtils.isEmpty(authServerId) ? "default" : authServerId;
}
}
......@@ -85,7 +85,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
*/
@Override
public String authorize(String state) {
return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getCodingGroupName()))
return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getDomainPrefix()))
.queryParam("response_type", "code")
.queryParam("client_id", config.getClientId())
.queryParam("redirect_uri", config.getRedirectUri())
......@@ -102,7 +102,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
*/
@Override
public String accessTokenUrl(String code) {
return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getCodingGroupName()))
return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getDomainPrefix()))
.queryParam("code", code)
.queryParam("client_id", config.getClientId())
.queryParam("client_secret", config.getClientSecret())
......@@ -119,7 +119,7 @@ public class AuthCodingRequest extends AuthDefaultRequest {
*/
@Override
public String userInfoUrl(AuthToken authToken) {
return UrlBuilder.fromBaseUrl(String.format(source.userInfo(), config.getCodingGroupName()))
return UrlBuilder.fromBaseUrl(String.format(source.userInfo(), config.getDomainPrefix()))
.queryParam("access_token", authToken.getAccessToken())
.build();
}
......
......@@ -35,8 +35,8 @@ public class AuthChecker {
if (isSupported && AuthDefaultSource.WECHAT_ENTERPRISE == source) {
isSupported = StringUtils.isNotEmpty(config.getAgentId());
}
if (isSupported && AuthDefaultSource.CODING == source) {
isSupported = StringUtils.isNotEmpty(config.getCodingGroupName());
if (isSupported && (AuthDefaultSource.CODING == source || AuthDefaultSource.OKTA == source)) {
isSupported = StringUtils.isNotEmpty(config.getDomainPrefix());
}
if (isSupported && AuthDefaultSource.XMLY == source) {
isSupported = StringUtils.isNotEmpty(config.getDeviceId()) && null != config.getClientOsType();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册