代码拉取完成,页面将自动刷新
package authing_v3
import (
"log"
"os"
"gitee.com/carlmax_my/console-core-go/pkg/idp"
"gitee.com/carlmax_my/console-core-go/pkg/util"
"gitee.com/carlmax_my/authing-golang-sdk/v3/management"
)
type AuthingCli struct {
// for global general mgmt
// UserPoolId string
// Secret string
Cli *management.ManagementClient
UserPoolId string
UserPoolSecret string
TenantId *string
AuthingHost string
UseEnvHost bool
// for app
AuthCli *AuthingAuthCli
}
func NewAuthingCli(tenantId *string, useEnvHost bool) *AuthingCli {
userPoolId := os.Getenv("AUTHING_USER_POOL_ID")
secret := os.Getenv("AUTHING_SECRET")
authingHost := os.Getenv("AUTHING_CONSOLE_HOST")
cli := NewAuthingMgmtCli(userPoolId, secret, authingHost, tenantId, useEnvHost)
cli.SetUserPoolId(userPoolId)
appId := os.Getenv("AUTHING_SDP_APP_ID")
appSecret := os.Getenv("AUTHING_SDP_APP_SECRET")
appHost := idp.GetAuthingAppHost(os.Getenv("AUTHING_SDP_APP_IDENTIFIER"))
appRedirectUri := os.Getenv("AUTHING_SDP_APP_REDIRECT_URI")
authingAuthCli := &AuthingAuthCli{
UserPoolId: userPoolId,
AppId: appId,
AppSecret: appSecret,
AppHost: appHost,
}
if appId != "" && !idp.IsAuthingAppDynamicMode() { // single app mode, then we can set app id in env file
authCli := NewAuthingAuthCli(appId, appSecret, appHost, appRedirectUri, "", "")
authingAuthCli.Cli = authCli
}
return &AuthingCli{
Cli: cli,
AuthingHost: authingHost,
UseEnvHost: useEnvHost,
UserPoolId: userPoolId,
UserPoolSecret: secret,
TenantId: tenantId,
AuthCli: authingAuthCli,
}
}
func NewAuthingMgmtCli(userPoolId string, secret string, authingHost string, tenantId *string, useEnvHost bool) *management.ManagementClient {
mgmtOptions := management.ManagementClientOptions{
AccessKeyId: userPoolId, // Authing Access Key ID
AccessKeySecret: secret, // Authing Access Key Secret
// Host: authingHost, // Authing 服务器地址,默认为 https://api.authing.cn
}
if useEnvHost {
mgmtOptions.Host = authingHost
}
if !util.IsStringEmpty(tenantId) {
mgmtOptions.TenantId = *tenantId
}
cli, _ := management.NewManagementClient(&mgmtOptions)
return cli
}
func (a *AuthingCli) ResetCliTenantId(tenantId string) {
a.Cli = NewAuthingMgmtCli(a.UserPoolId, a.UserPoolSecret, a.AuthingHost, &tenantId, a.UseEnvHost)
}
func (a *AuthingCli) ResetAuthCli(appId, appSecret, appHost, appRedirectUri, appLogoutRedirectUri, accessToken string) {
a.AuthCli.ResetAuthCli(appId, appSecret, appHost, appRedirectUri, appLogoutRedirectUri, accessToken)
}
func (a *AuthingCli) GetAppHost() string {
return a.AuthCli.AppHost
}
func (a *AuthingCli) GetAppId() string {
return a.AuthCli.AppId
}
func (a *AuthingCli) PrintOptions() {
log.Println("a.UserPoolId", a.UserPoolId)
log.Println("a.UserPoolSecret", a.UserPoolSecret)
if a.TenantId != nil {
log.Println("a.TenantId", *a.TenantId)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。