代码拉取完成,页面将自动刷新
package authing_v3
import (
"errors"
"log"
"gitee.com/carlmax_my/authing-golang-sdk/v3/dto"
)
func (a *AuthingCli) CreateIdp(name, idpType string) (string, error) {
reqDto := &dto.CreateExtIdpDto{
Name: name,
Type: idpType,
}
resp := a.Cli.CreateExtIdp(reqDto)
if resp.StatusCode == 200 {
return resp.Data.Id, nil
}
log.Printf("[v3]CreateIdp error[%+v]:%+v\n", reqDto, resp)
return "", errors.New(resp.Message)
}
func (a *AuthingCli) UpdateIdp(idpId string, name string) error {
reqDto := &dto.UpdateExtIdpDto{
Id: idpId,
Name: name,
}
resp := a.Cli.UpdateExtIdp(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "UpdateIdp")
}
func (a *AuthingCli) DeleteIdp(idpId string) error {
reqDto := &dto.DeleteExtIdpDto{
Id: idpId,
}
resp := a.Cli.DeleteExtIdp(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "DeleteIdp")
}
func (a *AuthingCli) CreateIdp4Tenant(name, idpType, tenantId string) (string, error) {
reqDto := &dto.CreateExtIdpDto{
Name: name,
Type: idpType,
TenantId: tenantId,
}
resp := a.Cli.CreateExtIdp(reqDto)
if resp.StatusCode == 200 {
return resp.Data.Id, nil
}
log.Printf("CreateIdp4Tenant error[%+v]:%+v\n", reqDto, resp)
return "", errors.New(resp.Message)
}
func (a *AuthingCli) UpdateIdp4Tenant(idpId string, tenantId string, name string) error {
reqDto := &dto.UpdateExtIdpDto{
Id: idpId,
Name: name,
TenantId: tenantId,
}
resp := a.Cli.UpdateExtIdp(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "UpdateIdp4Tenant")
}
func (a *AuthingCli) DeleteIdp4Tenant(idpId string, tenantId string) error {
reqDto := &dto.DeleteExtIdpDto{
Id: idpId,
TenantId: tenantId,
}
resp := a.Cli.DeleteExtIdp(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "DeleteIdp4Tenant")
}
func (a *AuthingCli) CreateIdpConnection4Tenant(idpId string, tenantId string, connType string, identifier string, displayName string, fields interface{}) (string, error) {
reqDto := &dto.CreateExtIdpConnDto{
ExtIdpId: idpId,
TenantId: tenantId,
Type: connType,
Identifier: identifier,
DisplayName: displayName,
Fields: fields,
}
resp := a.Cli.CreateExtIdpConn(reqDto)
if resp.StatusCode == 200 {
return resp.Data.Id, nil
}
log.Printf("CreateIdpConnection4Tenant error[%+v]:%+v\n", reqDto, resp)
return "", errors.New(resp.Message)
}
func (a *AuthingCli) UpdateIdpConnection4Tenant(idpConnectionId string, tenantId string, displayName string, fields interface{}) error {
reqDto := &dto.UpdateExtIdpConnDto{
Id: idpConnectionId,
TenantId: tenantId,
DisplayName: displayName,
Fields: fields,
}
resp := a.Cli.UpdateExtIdpConn(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "UpdateIdpConnection4Tenant")
}
func (a *AuthingCli) DeleteIdpConnection4Tenant(idpConnectionId string, tenantId string) error {
reqDto := &dto.DeleteExtIdpConnDto{
Id: idpConnectionId,
TenantId: tenantId,
}
resp := a.Cli.DeleteExtIdpConn(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "DeleteIdpConnection4Tenant")
}
func (a *AuthingCli) CreateIdpConnection(idpId string, connType string, identifier string, displayName string, fields interface{}) (string, error) {
reqDto := &dto.CreateExtIdpConnDto{
ExtIdpId: idpId,
Type: connType,
Identifier: identifier,
DisplayName: displayName,
Fields: fields,
}
resp := a.Cli.CreateExtIdpConn(reqDto)
if resp.StatusCode == 200 {
return resp.Data.Id, nil
}
log.Printf("[v3]CreateIdpConnection error[%+v]:%+v\n", reqDto, resp)
return "", errors.New(resp.Message)
}
func (a *AuthingCli) UpdateIdpConnection(idpConnectionId string, displayName string, fields interface{}) error {
reqDto := &dto.UpdateExtIdpConnDto{
Id: idpConnectionId,
DisplayName: displayName,
Fields: fields,
}
resp := a.Cli.UpdateExtIdpConn(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "UpdateIdpConnection")
}
func (a *AuthingCli) DeleteIdpConnection(idpConnectionId string) error {
reqDto := &dto.DeleteExtIdpConnDto{
Id: idpConnectionId,
}
resp := a.Cli.DeleteExtIdpConn(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "DeleteIdpConnection")
}
// will get 400
// not work
// deprecated
func (a *AuthingCli) ChangeIdpConnectionState4App(idpConnectionId string, enable bool) error {
reqDto := &dto.ChangeExtIdpAssociationStateDto{
Id: idpConnectionId,
Association: enable,
}
resp := a.Cli.ChangeExtIdpConnAssociationState(reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "ChangeIdpConnectionState4App")
}
func (a *AuthingCli) ChangeIdpConnectionState4Tenant(idpConnectionId string, enable bool, tenantId string, isCreate bool) error {
// step1: enable tenant下关联的app
// social idp no need to do step1,because idp already in app
reqDto1 := &dto.ChangeExtIdpConnStateDto{
Id: idpConnectionId,
Enabled: enable,
AppId: a.AuthCli.AppId,
TenantId: tenantId,
// AppIds: []string `json:"appIds,omitempty"`
}
//var resp1 *dto.IsSuccessRespDto
//resp1 = a.Cli.ChangeExtIdpConnState(reqDto1)
resp1 := ChangeExtIdpConnState_authing_fix(a.Cli, a.AuthingHost, a.UserPoolId, reqDto1)
if resp1.StatusCode != 200 {
log.Printf("ChangeExtIdpConnState.error[%+v]:%+v\n", reqDto1, resp1)
return errors.New(resp1.Message)
}
log.Printf("ChangeExtIdpConnState.success[%+v]:%+v\n", reqDto1, resp1)
if isCreate {
// step2:
reqDto := &dto.ChangeExtIdpAssociationStateDto{
Id: idpConnectionId,
Association: true,
TenantId: tenantId,
}
// resp := a.Cli.ChangeExtIdpConnAssociationState(reqDto)
resp := ChangeExtIdpConnAssociationState_authing_fix(a.Cli, a.AuthingHost, a.UserPoolId, reqDto)
return ProcessAuthingV3Resp2(resp.StatusCode, resp.Message, resp, "ChangeIdpConnectionState4Tenant")
}
return nil
}
func (a *AuthingCli) ChangeIdpConnectionMfa4Tenant(idpConnectionId string, tenantId string, EnabledFactors []string) error {
return a.ChangeGlobalMfa(EnabledFactors)
}
func ProcessAuthingV3Resp(statusCode int, message string, resp interface{}, api string) (bool, error) {
if statusCode == 200 {
log.Printf("ProcessAuthingV3Resp2.success[%s]:%+v\n", api, resp)
return true, nil
}
log.Printf("ProcessAuthingV3Resp.error[%s]:%+v\n", api, resp)
return false, errors.New(message)
}
func ProcessAuthingV3Resp2(statusCode int, message string, resp interface{}, api string) error {
if statusCode == 200 {
log.Printf("ProcessAuthingV3Resp2.success[%s]:%+v\n", api, resp)
return nil
}
log.Printf("ProcessAuthingV3Resp2.error[%s]:%+v\n", api, resp)
return errors.New(message)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。