package com.chinaweal.aiccs.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 统一认证平台OAuth2配置
 *
 * @author lroyia
 * @since 2025/03/02
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "oauth2.unified-auth")
public class UnifiedAuthConfig {

    /**
     * 认证地址
     */
    private String authUrl;

    /**
     * 认证地址（内网）
     */
    private String authUrlIntranet;

    /**
     * 客户端ID
     */
    private String clientId;

    /**
     * 客户端秘钥
     */
    private String clientSecret;

    /**
     * 回调地址
     */
    private String redirectUri;

    /**
     * 授权码接口路径
     */
    private String authorizePath = "/authcenter/getOauth2Authorize";

    /**
     * 获取令牌接口路径
     */
    private String tokenPath = "/authcenter/getOauth2Token";

    /**
     * 获取用户信息接口路径
     */
    private String userinfoPath = "/authcenter/getOauth2UserInfo";

    /**
     * 验证令牌有效性接口路径
     */
    private String checkTokenPath = "/authcenter/checkTAValid";

    /**
     * 单点登出接口路径
     */
    private String logoutPath = "/authcenter/userLogout";

    /**
     * 获取完整授权码接口URL
     */
    public String getAuthorizeUrl() {
        return authUrl + authorizePath;
    }

    /**
     * 获取完整令牌接口URL
     */
    public String getTokenUrl() {
        return authUrlIntranet + tokenPath;
    }

    /**
     * 获取完整用户信息接口URL
     */
    public String getUserinfoUrl() {
        return authUrlIntranet + userinfoPath;
    }

    /**
     * 获取完整验证令牌接口URL
     */
    public String getCheckTokenUrl() {
        return authUrlIntranet + checkTokenPath;
    }

    /**
     * 获取完整单点登出接口URL
     */
    public String getLogoutUrl() {
        return authUrlIntranet + logoutPath;
    }
}