代码拉取完成,页面将自动刷新
package authing_v2
import (
"fmt"
"log"
"net/http"
"github.com/Authing/authing-go-sdk/lib/model"
)
func (a *AuthingCli) CreateIdp(name, idpType string) (string, error) {
req := &model.CreateExtIdpRequest{
Name: name,
Type: idpType,
// TenantUd: tenantId,
}
resp, err := a.Cli.CreateExtIdp(req)
if err != nil {
log.Printf("CreateIdp.error[%+v]:%+v\n", req, resp)
return "", err
}
log.Printf("CreateIdp.success[%+v]:%+v\n", req, resp)
return resp.ID, nil
}
func (a *AuthingCli) UpdateIdp(idpId string, name string) error {
req := &model.UpdateExtIdpRequest{
Name: name,
}
resp, err := a.Cli.UpdateExtIdp(idpId, req)
if err != nil {
log.Printf("UpdateIdp.error[%+v]:%+v\n", req, resp)
return err
}
log.Printf("UpdateIdp.success[%+v]:%+v\n", req, resp)
return nil
}
func (a *AuthingCli) DeleteIdp(idpId string) error {
resp, err := a.Cli.DeleteExtIdp(idpId)
if err != nil {
log.Printf("DeleteIdp.error[%s]:%+v\n", idpId, resp)
return err
}
log.Printf("DeleteIdp.success[%s]:%+v\n", idpId, resp)
return nil
}
func (a *AuthingCli) CreateIdp4Tenant(name, idpType, tenantId string) (string, error) {
req := &model.CreateExtIdpRequest{
Name: name,
Type: idpType,
TenantUd: tenantId,
}
resp, err := a.Cli.CreateExtIdp(req)
if err != nil {
log.Printf("CreateIdp4Tenant.error[%+v]:%+v\n", req, resp)
return "", err
}
log.Printf("CreateIdp4Tenant.success[%+v]:%+v\n", req, resp)
return resp.ID, nil
}
func (a *AuthingCli) UpdateIdp4Tenant(idpId string, tenantId string, name string) error {
req := &model.UpdateExtIdpRequest{
Name: name,
}
resp, err := a.Cli.UpdateExtIdp(idpId, req)
if err != nil {
log.Printf("UpdateIdp4Tenant.error[%+v]:%+v\n", req, resp)
return err
}
log.Printf("UpdateIdp4Tenant.success[%+v]:%+v\n", req, resp)
return nil
}
func (a *AuthingCli) DeleteIdp4Tenant(idpId string, tenantId string) error {
resp, err := a.Cli.DeleteExtIdp(idpId)
if err != nil {
log.Println("DeleteIdp4Tenant.error", resp)
return err
}
log.Println("DeleteIdp4Tenant.success", resp)
return nil
}
func (a *AuthingCli) CreateIdpConnection4Tenant(idpId string, tenantId string, connType string, identifier string, displayName string, fields interface{}) (string, error) {
req := &model.CreateExtIdpConnectionRequest{
ExtIdpId: idpId,
Type: connType,
Identifier: identifier,
DisplayName: displayName,
Fields: fields,
Logo: "",
// UserMatchFields: userMatchFields,
}
resp, err := a.Cli.CreateExtIdpConnection(req)
if err != nil {
return "", err
}
return resp.ID, nil
}
func (a *AuthingCli) UpdateIdpConnection4Tenant(idpConnectionId string, tenantId string, displayName string, fields interface{}) error {
req := &model.UpdateExtIdpConnectionRequest{
DisplayName: displayName,
Fields: fields,
Logo: "",
//UserMatchFields: userMatchFields,
}
resp, err := a.Cli.UpdateExtIdpConnection(idpConnectionId, req)
if err != nil {
return err
}
log.Println("UpdateIdpConnection4Tenant", resp)
return nil
}
func (a *AuthingCli) DeleteIdpConnection4Tenant(idpConnectionId string, tenantId string) error {
resp, err := a.Cli.DeleteExtIdpConnection(idpConnectionId)
if err != nil {
return err
}
log.Println("DeleteIdpConnection4Tenant", resp)
return nil
}
func (a *AuthingCli) CreateIdpConnection(idpId string, connType string, identifier string, displayName string, fields interface{}) (string, error) {
req := &model.CreateExtIdpConnectionRequest{
ExtIdpId: idpId,
Type: connType,
Identifier: identifier,
DisplayName: displayName,
Fields: fields,
Logo: "",
// UserMatchFields: userMatchFields,
}
resp, err := a.Cli.CreateExtIdpConnection(req)
if err != nil {
return "", err
}
return resp.ID, nil
}
func (a *AuthingCli) UpdateIdpConnection(idpConnectionId string, displayName string, fields interface{}) error {
req := &model.UpdateExtIdpConnectionRequest{
DisplayName: displayName,
Fields: fields,
Logo: "",
//UserMatchFields: userMatchFields,
}
resp, err := a.Cli.UpdateExtIdpConnection(idpConnectionId, req)
if err != nil {
return err
}
log.Println("UpdateIdpConnection.success", resp)
return nil
}
func (a *AuthingCli) DeleteIdpConnection(idpConnectionId string) error {
resp, err := a.Cli.DeleteExtIdpConnection(idpConnectionId)
if err != nil {
return err
}
log.Println("DeleteIdpConnection.success", resp)
return nil
}
func (a *AuthingCli) ChangeIdpConnectionState4App(idpConnectionId string, enable bool) error {
req := &model.ChangeExtIdpConnectionStateRequest{
Enabled: enable,
AppID: a.AuthCli.AppId,
}
_, err := a.Cli.ChangeExtIdpConnectionState(idpConnectionId, req)
return err
}
func (a *AuthingCli) ChangeIdpConnectionState4Tenant(idpConnectionId string, enable bool, tenantId string, isCreate bool) error {
req := &model.ChangeExtIdpConnectionStateRequest{
Enabled: enable,
AppID: a.AuthCli.AppId,
TenantID: tenantId,
}
_, err := a.Cli.ChangeExtIdpConnectionState(idpConnectionId, req)
return err
}
func (a *AuthingCli) AutoJoinUserToTenant(idpId string, enable bool, tenantId string) error {
c := a.Cli
url := fmt.Sprintf("%s/api/v2/extIdp/%s/autoJoin/%s", c.Host, idpId, tenantId)
req := &struct {
Enabled bool `json:"enabled"`
}{
Enabled: enable,
}
return a.SendAuthingRequest(url, http.MethodPut, req)
}
func (a *AuthingCli) ChangeIdpConnMfa(extConnId string, factor string, enable bool) error {
c := a.Cli
url := fmt.Sprintf("%s/api/v2/extIdpConn/%s", c.Host, extConnId)
req := &struct {
SkipMfa bool `json:"skipMfa"`
}{
SkipMfa: !enable,
}
return a.SendAuthingRequest(url, http.MethodPut, req)
}
func (a *AuthingCli) ChangeIdpConnectionMfa4Tenant(idpConnectionId string, tenantId string, EnabledFactors []string) error {
defFactor := "OTP"
if len(EnabledFactors) > 0 {
return a.ChangeIdpConnMfa(idpConnectionId, defFactor, true)
} else {
return a.ChangeIdpConnMfa(idpConnectionId, defFactor, false)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。