文档目录

统一认证SSO相关接口

通过AD/LDAP用户DN创建IAM2用户(CreateIAM2VirtualIDFromLdapUid)

API请求

URLs
POST zstack/v1/iam2/virtual-id/ldap/uid
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "ldapUid": "ou\u003dEmployee,uid\u003dtest"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"ldapUid":"ou=Employee,uid=test"}}' http://localhost:8080/zstack/v1/iam2/virtual-id/ldap/uid
参数列表
名字 类型 位置 描述 可选值 起始版本
ldapUid String body (包含在params结构中) AD/LDAP用户UID 4.7.0
resourceUuid (可选) String body (包含在params结构中) 资源UUID 4.7.0
tagUuids (可选) List body (包含在params结构中) 标签UUID列表 4.7.0
systemTags (可选) List body 3.5.1
userTags (可选) List body 3.5.1

API返回

返回示例
{
  "inventory": {
    "uuid": "417c94a9fdfb3b61b2e0d11ed42f4b4d",
    "ldapUid": "ou\u003dEmployee,uid\u003dtest",
    "ldapServerUuid": "6e667cc905903cfc82ddef6f14d45831",
    "virtualIDUuid": "bbcf2b14a0d13401872088bd1aa7f930"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
inventory LdapIAM2VirtualIDRefInventory 详情参考inventory 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
ldapUid String AD/LDAP条目标志 3.5.1
ldapServerUuid String AD/LDAP服务器 3.5.1
resourceUuid String 资源UUID 3.5.1
createDate Timestamp 创建时间 3.5.1
lastOpDate Timestamp 最后一次修改时间 3.5.1

SDK示例

Java SDK
CreateIAM2VirtualIDFromLdapUidAction action = new CreateIAM2VirtualIDFromLdapUidAction();
action.ldapUid = "ou=Employee,uid=test";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateIAM2VirtualIDFromLdapUidAction.Result res = action.call();
Python SDK
CreateIAM2VirtualIDFromLdapUidAction action = CreateIAM2VirtualIDFromLdapUidAction()
action.ldapUid = "ou=Employee,uid=test"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateIAM2VirtualIDFromLdapUidAction.Result res = action.call()

创建AD/LDAP用户和IAM2用户绑定关系(CreateIAM2VirtualIDLdapBinding)

API请求

URLs
POST zstack/v1/iam2/ldap/bindings
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "virtualIDUuid": "7f78522de8ce3e3c8550207c26704dc8",
    "ldapUid": "ou\u003dEmployee,uid\u003dtest"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"virtualIDUuid":"7f78522de8ce3e3c8550207c26704dc8","ldapUid":"ou=Employee,uid=test"}}' http://localhost:8080/zstack/v1/iam2/ldap/bindings
参数列表
名字 类型 位置 描述 可选值 起始版本
virtualIDUuid String body (包含在params结构中) IAM2用户UUID 4.7.0
ldapUid String body (包含在params结构中) AD/LDAP用户UUID 4.7.0
resourceUuid (可选) String body (包含在params结构中) 4.7.0
tagUuids (可选) List body (包含在params结构中) 标签UUID列表 4.7.0
systemTags (可选) List body 3.5.1
userTags (可选) List body 3.5.1

API返回

返回示例
{
  "inventory": {
    "uuid": "35f1a7c85cf038f6892a9c6b5e2f0470",
    "ldapUid": "ou\u003dEmployee,uid\u003dtest",
    "ldapServerUuid": "1bca8f5b607b3d0d9cc5b22270c3a262",
    "virtualIDUuid": "5d1be61d0d1d3657afdd9e7829f4d2ed"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
inventory LdapIAM2VirtualIDRefInventory 详情参考inventory 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
ldapUid String AD/LDAP条目标志 3.5.1
ldapServerUuid String AD/LDAP服务器UUID 3.5.1
resourceUuid String 资源UUID 3.5.1
createDate Timestamp 创建时间 3.5.1
lastOpDate Timestamp 最后一次修改时间 3.5.1

SDK示例

Java SDK
CreateIAM2VirtualIDLdapBindingAction action = new CreateIAM2VirtualIDLdapBindingAction();
action.virtualIDUuid = "52d9727518053f50889bebe14617d2d2";
action.ldapUid = "ou=Employee,uid=test";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateIAM2VirtualIDLdapBindingAction.Result res = action.call();
Python SDK
CreateIAM2VirtualIDLdapBindingAction action = CreateIAM2VirtualIDLdapBindingAction()
action.virtualIDUuid = "52d9727518053f50889bebe14617d2d2"
action.ldapUid = "ou=Employee,uid=test"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateIAM2VirtualIDLdapBindingAction.Result res = action.call()

获取AD/LDAP认证可用用户条目(GetCandidateLdapEntryForIAM2Binding)

用于获取可供IAM2用户绑定的AD/LDAP条目。

API请求

URLs
GET zstack/v1/iam2/ldap/entries/candidates
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/iam2/ldap/entries/candidates?ldapFilter=(cn=user_xxx)&limit=2500.0
参数列表
名字 类型 位置 描述 可选值 起始版本
ldapFilter String query AD/LDAP查询条件 3.5.1
limit (可选) Integer query AD/LDAP查询条数限制 3.5.1
systemTags (可选) List query 3.5.1
userTags (可选) List query 3.5.1

API返回

返回示例
{
  "inventories": []
}
名字 类型 描述 起始版本
inventories List 3.5.1
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1

SDK示例

Java SDK
GetCandidateLdapEntryForIAM2BindingAction action = new GetCandidateLdapEntryForIAM2BindingAction();
action.ldapFilter = "(cn=user_xxx)";
action.limit = 2500.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateLdapEntryForIAM2BindingAction.Result res = action.call();
Python SDK
GetCandidateLdapEntryForIAM2BindingAction action = GetCandidateLdapEntryForIAM2BindingAction()
action.ldapFilter = "(cn=user_xxx)"
action.limit = 2500.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetCandidateLdapEntryForIAM2BindingAction.Result res = action.call()

通过AD/LDAP认证登录IAM2用户(LoginIAM2VirtualIDWithLdap)

API请求

URLs
PUT zstack/v1/iam2/login/virtual-ids/ldap
Body
{
  "loginIAM2VirtualIDWithLdap": {
    "uid": "ou\u003dEmployee,uid\u003dtest",
    "password": "password"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X PUT -d '{"loginIAM2VirtualIDWithLdap":{"uid":"ou=Employee,uid=test","password":"password"}}' http://localhost:8080/zstack/v1/iam2/login/virtual-ids/ldap
参数列表
名字 类型 位置 描述 可选值 起始版本
uid String body(包含在loginIAM2VirtualIDWithLdap结构中) 平台指定的AD/LDAP用户登录属性值 3.5.1
password String body(包含在loginIAM2VirtualIDWithLdap结构中) AD/LDAP用户登录密码 3.5.1
verifyCode (可选) String body(包含在loginIAM2VirtualIDWithLdap结构中) 验证登录码 3.5.1
captchaUuid (可选) String body(包含在loginIAM2VirtualIDWithLdap结构中) 验证登录码UUID 3.5.1
systemTags (可选) List body 3.5.1
userTags (可选) List body 3.5.1

API返回

返回示例
{
  "inventory": {
    "uuid": "4abb254913c23d488c161bcd3524f176",
    "accountUuid": "ac1453a45c6830c6ad6d488326a4c0ec",
    "expiredDate": "Nov 14, 2017 10:20:57 PM",
    "noSessionEvaluation": false
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
inventory SessionInventory 详情参考inventory 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
accountUuid String 账户UUID 3.5.1
userUuid String 用户UUID 3.5.1
expiredDate Timestamp 3.5.1
createDate Timestamp 创建时间 3.5.1

SDK示例

Java SDK
LoginIAM2VirtualIDWithLdapAction action = new LoginIAM2VirtualIDWithLdapAction();
action.uid = "ou=Employee,uid=test";
action.password = "password";
LoginIAM2VirtualIDWithLdapAction.Result res = action.call();
Python SDK
LoginIAM2VirtualIDWithLdapAction action = LoginIAM2VirtualIDWithLdapAction()
action.uid = "ou=Employee,uid=test"
action.password = "password"
LoginIAM2VirtualIDWithLdapAction.Result res = action.call()

删除IAM2用户与AD/LDAP用户绑定关系(DeleteIAM2VirtualIDLdapBinding)

API请求

URLs
DELETE /v1/iam2/ldap/bindings/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/iam2/ldap/bindings/0a7983d3082530c4b6d4b844e694694e?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.5.1
deleteMode (可选) String body 3.5.1
systemTags (可选) List body 3.5.1
userTags (可选) List body 3.5.1

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteIAM2VirtualIDLdapBindingAction action = new DeleteIAM2VirtualIDLdapBindingAction();
action.uuid = "0a7983d3082530c4b6d4b844e694694e";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteIAM2VirtualIDLdapBindingAction.Result res = action.call();
Python SDK
DeleteIAM2VirtualIDLdapBindingAction action = DeleteIAM2VirtualIDLdapBindingAction()
action.uuid = "0a7983d3082530c4b6d4b844e694694e"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteIAM2VirtualIDLdapBindingAction.Result res = action.call()

清除IAM2用户与AD/LDAP用户绑定关系(CleanInvalidLdapIAM2Binding)

清除IAM2用户与AD/LDAP用户的绑定关系。

API请求

URLs
PUT zstack/v1/iam2/ldap/bindings/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "cleanInvalidLdapIAM2Binding": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"cleanInvalidLdapIAM2Binding":{}}' http://localhost:8080/zstack/v1/iam2/ldap/bindings/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
systemTags (可选) List body 3.5.1
userTags (可选) List body 3.5.1

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "642833fc31983380b25ecf08f3f8f8f4",
      "name": "admin",
      "state": "Enabled",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
inventories List 详情参考inventories 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
name String 资源名称 3.5.1
description String 资源的详细描述 3.5.1
createDate Timestamp 创建时间 3.5.1
lastOpDate Timestamp 最后一次修改时间 3.5.1
state State 详情参考state 3.5.1
attributes List 详情参考attributes 3.5.1
#state
名字 类型 描述 起始版本
name String 资源名称 3.5.1
ordinal int 3.5.1
#attributes
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
name String 资源名称 3.5.1
value String 3.5.1
type AttributeType 详情参考type 3.5.1
#type
名字 类型 描述 起始版本
name String 资源名称 3.5.1
ordinal int 3.5.1

SDK示例

Java SDK
CleanInvalidLdapIAM2BindingAction action = new CleanInvalidLdapIAM2BindingAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CleanInvalidLdapIAM2BindingAction.Result res = action.call();
Python SDK
CleanInvalidLdapIAM2BindingAction action = CleanInvalidLdapIAM2BindingAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CleanInvalidLdapIAM2BindingAction.Result res = action.call()

查询AD/LDAP绑定(QueryIAM2LdapBinding)

API请求

URLs
GET zstack/v1/iam2/ldap/bindings
GET zstack/v1/iam2/ldap/bindings/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/iam2/ldap/bindings?q=accountUuid=bb452952218931cdb9c058085748dc8a
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/iam2/ldap/bindings/c757b80ef90f37dba57f180ac1b52269

可查询字段

运行CLI命令行工具,输入QueryIAM2LdapBinding并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "5e66b22cb6d33a87802d12b4ee280f64",
      "ldapUid": "ou\u003dEmployee,uid\u003dtest",
      "ldapServerUuid": "03f1ff7e314232ebbb365c7fc62878f3",
      "resourceUuid": "3946f8a48c6d320fbddd0e6c0c30c281"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
inventories List 详情参考inventories 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
ldapUid String AD/LDAP条目标志 3.5.1
ldapServerUuid String AD/LDAP服务器UUID 3.5.1
resourceUuid String 资源UUID 3.5.1
createDate Timestamp 创建时间 3.5.1
lastOpDate Timestamp 最后一次修改时间 3.5.1

SDK示例

Java SDK
QueryIAM2LdapBindingAction action = new QueryIAM2LdapBindingAction();
action.conditions = asList("accountUuid=cf0b19d0309c31e2bf9d2f9e50a3a013");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryIAM2LdapBindingAction.Result res = action.call();
Python SDK
QueryIAM2LdapBindingAction action = QueryIAM2LdapBindingAction()
action.conditions = ["accountUuid=5f37176baf4b35479f25bf375879c83d"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryIAM2LdapBindingAction.Result res = action.call()

同步AD/LDAP服务器用户及组织(SyncLdapServer)

API请求

URLs
PUT zstack/v1/ldap/servers/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "syncLdapServer": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"syncLdapServer":{}}' http://localhost:8080/zstack/v1/ldap/servers/7a3718959bae3ac88e0b828e06ab2e22/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.5.1
systemTags (可选) List body 3.5.1
userTags (可选) List body 3.5.1

API返回

返回示例
{
  "inventory": {
    "uuid": "14dc461677b23ea1a984849f501a7152"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.5.1
inventory LongJobInventory 详情参考inventory 3.5.1
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.5.1
description String 错误的概要描述 3.5.1
details String 错误的详细信息 3.5.1
elaboration String 保留字段,默认为null 3.5.1
opaque LinkedHashMap 保留字段,默认为null 3.5.1
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.5.1
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.5.1
name String 资源名称 3.5.1
description String 资源的详细描述 3.5.1
apiId String 用于关联TaskProgress的APIID 3.5.1
jobName String 任务名称 3.5.1
jobData String 任务数据 3.5.1
jobResult String 任务结果 3.5.1
targetResourceUuid String 目标资源UUID 3.5.1
managementNodeUuid String 管理节点UUID 3.5.1
createDate Timestamp 创建时间 3.5.1
lastOpDate Timestamp 最后一次修改时间 3.5.1
state LongJobState 详情参考state 3.5.1
#state
名字 类型 描述 起始版本
name String 资源名称 3.5.1
ordinal int 3.5.1

SDK示例

Java SDK
SyncLdapServerAction action = new SyncLdapServerAction();
action.uuid = "7a3718959bae3ac88e0b828e06ab2e22";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncLdapServerAction.Result res = action.call();
Python SDK
SyncLdapServerAction action = SyncLdapServerAction()
action.uuid = "7a3718959bae3ac88e0b828e06ab2e22"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SyncLdapServerAction.Result res = action.call()

创建OAuth客户端(CreateOAuthClient)

API请求

URLs
POST zstack/v1/create/oauth2/client
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "test",
    "description": "test",
    "clientId": "756770202fcd36bfbaa00ea7dea7f5ff",
    "clientSecret": "8255b36a4e0e38ffa20dda1a079aa687",
    "authorizationUrl": "http://zstack.com/code",
    "tokenUrl": "http://zstack.com/token",
    "userinfoUrl": "http://zstack.com/userinfoUrl",
    "redirectUrl": "http://zstack.com/redirectUrl",
    "logoutUrl": "http://zstack.com/logoutUrl",
    "loginType": "iam1",
    "identityProvider": "zf-soft",
    "pluginUuid": "393e36ee1b9e3dd281ef04443a0b4c73",
    "urlTemplate": "http://172.24.194.28:5000/oauth1/verify/?username\u003d${username}\u0026sessionId\u003d${sessionId}\u0026userUuid\u003d${userUuid}\u0026accountUuid\u003d${accountUuid}\u0026loginType\u003d${loginType}\u0026userType\u003d${userType}\u0027",
    "scopeList": [
      "559bf858d9cd35ce830dcfbfc2195195"
    ]
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"test","description":"test","clientId":"756770202fcd36bfbaa00ea7dea7f5ff","clientSecret":"8255b36a4e0e38ffa20dda1a079aa687","authorizationUrl":"http://zstack.com/code","tokenUrl":"http://zstack.com/token","userinfoUrl":"http://zstack.com/userinfoUrl","redirectUrl":"http://zstack.com/redirectUrl","logoutUrl":"http://zstack.com/logoutUrl","loginType":"iam1","identityProvider":"zf-soft","pluginUuid":"393e36ee1b9e3dd281ef04443a0b4c73","urlTemplate":"http://172.24.194.28:5000/oauth1/verify/?username=${username}&sessionId=${sessionId}&userUuid=${userUuid}&accountUuid=${accountUuid}&loginType=${loginType}&userType=${userType}'","scopeList":["559bf858d9cd35ce830dcfbfc2195195"]}}' http://localhost:8080/zstack/v1/create/oauth2/client
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 4.5.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.5.0
clientId String body(包含在params结构中) 客户端ID 4.5.0
clientSecret (可选) String body(包含在params结构中) 客户端密钥 4.5.0
authorizationUrl (可选) String body(包含在params结构中) 认证url 4.5.0
tokenUrl String body(包含在params结构中) 认证token url 4.5.0
loginType String body(包含在params结构中) 登录的类型
  • cas-iam1
  • cas-iam2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
grantType String body(包含在params结构中) 认证模式 4.5.0
urlTemplate String body(包含在params结构中) 认证之后跳转的地址 4.5.0
clientType String body(包含在params结构中) 客户端类型 4.5.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.5.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.5.0
systemTags (可选) List body 系统标签 4.5.0
userTags (可选) List body 用户标签 4.5.0
userinfoUrl (可选) String body(包含在params结构中) 请求用户信息地址 4.7.21
redirectUrl (可选) String body(包含在params结构中) 用户自定义回调地址 4.7.21
logoutUrl (可选) String body(包含在params结构中) 登出地址 4.7.21
scopeList (可选) List body(包含在params结构中) 权限范围 5.1.8
identityProvider (可选) String body(包含在params结构中) 认证供应商 5.1.8
pluginUuid (可选) String body(包含在params结构中) 供应商插件UUID 5.3.20

API返回

返回示例
{
  "inventory": {
    "clientId": "b7e1d25d8ae833f8b6f13c448efbfb4a",
    "clientSecret": "64a93cc0b9263993a25ef033994afc10",
    "authorizationUrl": "http://zstack.com/code",
    "tokenUrl": "http://zstack.com/token",
    "userinfoUrl": "http://zstack.com/userinfoUrl",
    "uuid": "628dbf582da836ba9693c8813f98371f",
    "loginMNUrl": "http://127.0.0.1:8080/zstack/sso/oauth2/",
    "redirectUrl": "http://zstack.com/redirectUrl"
  }
}
名字 类型 描述 起始版本
success boolean 4.5.0
inventory OAuth2ClientInventory 详情参考inventory 4.5.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.5.0
#inventory
名字 类型 描述 起始版本
clientId String 客户端ID 4.5.0
clientSecret String 客户端密钥 4.5.0
authorizationUrl String 认证url 4.5.0
tokenUrl String 认证token url 4.5.0
grantType String 认证模式 4.5.0
uuid String 资源的UUID,唯一标示该资源 4.5.0
name String 资源名称 4.5.0
description String 资源的详细描述 4.5.0
clientType String clientType 4.5.0
loginType String 登录的类型:
  • cas-iam1
  • cas-ima2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
loginMNUrl String 免密登录url 4.5.0
createDate Timestamp 创建时间 4.5.0
lastOpDate Timestamp 最后一次修改时间 4.5.0
accountUuid String 账户UUID 4.5.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.5.0
description String 错误的概要描述 4.5.0
details String 错误的详细信息 4.5.0
elaboration String 保留字段,默认为null 4.5.0
opaque LinkedHashMap 保留字段,默认为null 4.5.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.5.0

SDK示例

Java SDK
CreateOAuthClientAction action = new CreateOAuthClientAction();
action.name = "test";
action.description = "test";
action.clientId = "756770202fcd36bfbaa00ea7dea7f5ff";
action.clientSecret = "8255b36a4e0e38ffa20dda1a079aa687";
action.authorizationUrl = "http://zstack.com/code";
action.tokenUrl = "http://zstack.com/token";
action.userinfoUrl = "http://zstack.com/userinfoUrl";
action.redirectUrl = "http://zstack.com/redirectUrl";
action.logoutUrl = "http://zstack.com/logoutUrl";
action.loginType = "iam1";
action.identityProvider = "zf-soft";
action.pluginUuid = "393e36ee1b9e3dd281ef04443a0b4c73";
action.urlTemplate = "http://172.24.194.28:5000/oauth1/verify/?username=${username}&sessionId=${sessionId}&userUuid=${userUuid}&accountUuid=${accountUuid}&loginType=${loginType}&userType=${userType}'";
action.scopeList = asList("559bf858d9cd35ce830dcfbfc2195195");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateOAuthClientAction.Result res = action.call();
Python SDK
CreateOAuthClientAction action = CreateOAuthClientAction()
action.name = "test"
action.description = "test"
action.clientId = "756770202fcd36bfbaa00ea7dea7f5ff"
action.clientSecret = "8255b36a4e0e38ffa20dda1a079aa687"
action.authorizationUrl = "http://zstack.com/code"
action.tokenUrl = "http://zstack.com/token"
action.userinfoUrl = "http://zstack.com/userinfoUrl"
action.redirectUrl = "http://zstack.com/redirectUrl"
action.logoutUrl = "http://zstack.com/logoutUrl"
action.loginType = "iam1"
action.identityProvider = "zf-soft"
action.pluginUuid = "393e36ee1b9e3dd281ef04443a0b4c73"
action.urlTemplate = "http://172.24.194.28:5000/oauth1/verify/?username=${username}&sessionId=${sessionId}&userUuid=${userUuid}&accountUuid=${accountUuid}&loginType=${loginType}&userType=${userType}'"
action.scopeList = [559bf858d9cd35ce830dcfbfc2195195]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateOAuthClientAction.Result res = action.call()

更新OAuth客户端(UpdateOAuthClient)

API请求

URLs
POST zstack/v1/update/oauth2/client
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "test",
    "description": "test",
    "clientId": "9f44e569b86c3883b0295fcab980e945",
    "clientSecret": "8b151acd0f7533538ed9e9315fadcaca",
    "authorizationUrl": "http://zstack.com/code",
    "tokenUrl": "http://zstack.com/token",
    "redirectUrl": "http://zstack.com/redirectUrl",
    "userinfoUrl": "http://zstack.com/userinfoUrl",
    "identityProvider": "zf-soft",
    "pluginUuid": "0b3b9a43772439c3aaa102fe8361b3d1",
    "loginType": "iam1",
    "logoutUrl": "http://zstack.com/logouturl",
    "scopeList": [
      "d8f4a70ef87b35c986336a88dd5bafd1"
    ]
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"test","description":"test","clientId":"9f44e569b86c3883b0295fcab980e945","clientSecret":"8b151acd0f7533538ed9e9315fadcaca","authorizationUrl":"http://zstack.com/code","tokenUrl":"http://zstack.com/token","redirectUrl":"http://zstack.com/redirectUrl","userinfoUrl":"http://zstack.com/userinfoUrl","identityProvider":"zf-soft","pluginUuid":"0b3b9a43772439c3aaa102fe8361b3d1","loginType":"iam1","logoutUrl":"http://zstack.com/logouturl","scopeList":["d8f4a70ef87b35c986336a88dd5bafd1"]}}' http://localhost:8080/zstack/v1/update/oauth2/client
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在params结构中) 资源的UUID,唯一标示该资源 4.5.0
name (可选) String body(包含在params结构中) 资源名称 4.5.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.5.0
clientId (可选) String body(包含在params结构中) 客户端ID 4.5.0
clientSecret (可选) String body(包含在params结构中) 客户端密钥 4.5.0
authorizationUrl (可选) String body(包含在params结构中) 认证url 4.5.0
tokenUrl (可选) String body(包含在params结构中) 认证token url 4.5.0
loginType (可选) String body(包含在params结构中) 登录的类型
  • cas-iam1
  • cas-iam2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
systemTags (可选) List body 系统标签 4.5.0
userTags (可选) List body 用户标签 4.5.0
redirectUrl (可选) String body(包含在params结构中) 用户自定义回调地址 4.7.21
userinfoUrl (可选) String body(包含在params结构中) 请求用户信息地址 4.7.21
logoutUrl (可选) String body(包含在params结构中) 登出地址 4.7.21
scopeList (可选) List body(包含在params结构中) 权限范围 5.1.8
identityProvider (可选) String pluginUuid (可选) 认证供应商 5.1.8
pluginUuid (可选) pluginUuid (可选) 供应商插件UUID 5.3.28

API返回

返回示例
{
  "inventory": {
    "clientId": "90de13d7ad483cb582bd14c792bd1ba7",
    "clientSecret": "e9107bd9f6213e29926da80c016a9639",
    "authorizationUrl": "http://zstack.com/code",
    "tokenUrl": "http://zstack.com/token",
    "userinfoUrl": "http://zstack.com/userinfoUrl",
    "uuid": "76467fb551ca362d98d6ba0782f3bb4c",
    "loginMNUrl": "http://127.0.0.1:8080/zstack/sso/oauth2/",
    "redirectUrl": "http://zstack.com/redirectUrl"
  }
}
名字 类型 描述 起始版本
success boolean 4.5.0
inventory OAuth2ClientInventory 详情参考inventory 4.5.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.5.0
#inventory
名字 类型 描述 起始版本
clientId String 客户端ID 4.5.0
clientSecret String 客户端密钥 4.5.0
authorizationUrl String 认证url 4.5.0
tokenUrl String 认证token url 4.5.0
grantType String 认证模式 4.5.0
uuid String 资源的UUID,唯一标示该资源 4.5.0
name String 资源名称 4.5.0
description String 资源的详细描述 4.5.0
clientType String clientType 4.5.0
loginType String 登录的类型:
  • cas-iam1
  • cas-ima2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
loginMNUrl String 免密登录url 4.5.0
createDate Timestamp 创建时间 4.5.0
lastOpDate Timestamp 最后一次修改时间 4.5.0
accountUuid String 账户UUID 4.5.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
UpdateOAuthClientAction action = new UpdateOAuthClientAction();
action.name = "test";
action.description = "test";
action.clientId = "9f44e569b86c3883b0295fcab980e945";
action.clientSecret = "8b151acd0f7533538ed9e9315fadcaca";
action.authorizationUrl = "http://zstack.com/code";
action.tokenUrl = "http://zstack.com/token";
action.redirectUrl = "http://zstack.com/redirectUrl";
action.userinfoUrl = "http://zstack.com/userinfoUrl";
action.identityProvider = "zf-soft";
action.pluginUuid = "0b3b9a43772439c3aaa102fe8361b3d1";
action.loginType = "iam1";
action.logoutUrl = "http://zstack.com/logouturl";
action.scopeList = asList("d8f4a70ef87b35c986336a88dd5bafd1");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateOAuthClientAction.Result res = action.call();
Python SDK
UpdateOAuthClientAction action = UpdateOAuthClientAction()
action.name = "test"
action.description = "test"
action.clientId = "9f44e569b86c3883b0295fcab980e945"
action.clientSecret = "8b151acd0f7533538ed9e9315fadcaca"
action.authorizationUrl = "http://zstack.com/code"
action.tokenUrl = "http://zstack.com/token"
action.redirectUrl = "http://zstack.com/redirectUrl"
action.userinfoUrl = "http://zstack.com/userinfoUrl"
action.identityProvider = "zf-soft"
action.pluginUuid = "0b3b9a43772439c3aaa102fe8361b3d1"
action.loginType = "iam1"
action.logoutUrl = "http://zstack.com/logouturl"
action.scopeList = [d8f4a70ef87b35c986336a88dd5bafd1]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateOAuthClientAction.Result res = action.call()

获取OAuth2 Token(GetOAuth2Token)

API请求

URLs
GET zstack/v1/get/oauth2/token
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X  GET http://localhost:8080/zstack/v1/get/oauth2/token
参数列表
名字 类型 位置 描述 可选值 起始版本
systemTags (可选) List body 系统标签 4.6.21
userTags (可选) List body 用户标签 4.6.21

API返回

返回示例
{
  "inventory": {
    "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGV3NnY2k4cENJQkZFY1hoVkZmNkhzVUkwU1FmekN2SGJ0LVFFOHc4OXJZIn0.eyJleHAiOjE2NjM1NzQ3NjcsImlhdCI6MTY2MzU3NDQ2NywiYXV0aF90aW1lIjoxNjYzNTc0NDY3LCJqdGkiOiI2MzQwOTRjNy00ZjA3LTRlZGMtYjMxMS05MmE5NDc0NWIwYTkiLCJpc3MiOiJodHRwczovLzE3Mi4yMC4xNi4xODg6ODQ0My9hdXRoL3JlYWxtcy9jbG91ZCIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiJkNjYyYWNiYi0yMjYxLTQ2ODctYjNkZS0zOTI2OTA0ZWRlNzQiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJjbG91ZF9zc28iLCJzZXNzaW9uX3N0YXRlIjoiNTM1MjM0ZDUtOTEyYi00NzY2LThhMjktN2Q5MTdkYjE2YTBmIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyIvKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsib2ZmbGluZV9hY2Nlc3MiLCJkZWZhdWx0L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bHNlLCJuYW1lIjoicWl1eXUgemhhbmciLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJxaXV5dSIsImdpdmVuX25hbWUiOiJxaXV5dSIsImZhbWlseV9uYW1lIjoiemhhbmciLCJlbWFpbCI6IjI0OTQ0OTcyNkBxcS5jb20ifQ.Mun8NSAnoPW3IjRLFySji8r243ydDYCARMXRstTllM1vsmVp56E3wpfJy8LAf_9PPAo-ryoTkuj1O2Z_nDV4F5lMQ_QASwqIMoBKzg3_Umf-D2pPlTC9BjMIuCeK0qoFiuJq23IS7IN9lYAHDRMdyP6MLUjkyqW-sWgq1l3boT7FcHfkl6cGBzFDLigpsckkm_b7yiN8lDxBdw7SNTcg_AO6D7ZipPG09up8hiatq_4fY1vnhfiBbL9pa8vX4wKoGGR8B_-uO6PrcALOt08QrW06YB084n56dzjD3hCRe9fA9tHB7krTCMnHZN-Bf0QptsYEzwU5zUvIRke9SM88Kg",
    "uuid": "58ac3d5235f230cbbac1bcf966c43685",
    "clientUuid": "b2d39b32cba335888e6c6d9a15c9ce3d",
    "userUuid": "1489d2a1d93531ffb83f2c49cd4cedcd"
  }
}
名字 类型 描述 起始版本
success boolean 4.6.21
inventory OAuth2TokenInventory 详情参考inventory 4.6.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.6.21
#inventory
名字 类型 描述 起始版本
accessToken String accessToken 4.6.21
idToken String idToken 4.6.21
refreshToken String refreshToken 4.6.21
uuid String 资源的UUID,唯一标示该资源 4.6.21
clientUuid String clientUuid 4.6.21
userUuid String 用户UUID 4.6.21
createDate Timestamp 创建时间 4.6.21
lastOpDate Timestamp 最后一次修改时间 4.6.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.6.21
description String 错误的概要描述 4.6.21
details String 错误的详细信息 4.6.21
elaboration String 保留字段,默认为null 4.6.21
opaque LinkedHashMap 保留字段,默认为null 4.6.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.6.21

SDK示例

Java SDK
GetOAuth2TokenAction action = new GetOAuth2TokenAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetOAuth2TokenAction.Result res = action.call();
Python SDK
GetOAuth2TokenAction action = GetOAuth2TokenAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetOAuth2TokenAction.Result res = action.call()

创建CAS客户端(CreateCasClient)

API请求

URLs
POST zstack/v1/create/cas/client
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "test",
    "description": "test",
    "casServerLoginUrl": "http://zstack.com/login",
    "casServerUrlPrefix": "http://zstack.com",
    "serverName": "http://127.0.0.1:8080",
    "loginType": "iam1"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \-X POST -d '{"params":{"name":"test","description":"test","casServerLoginUrl":"http://zstack.com/login","casServerUrlPrefix":"http://zstack.com","serverName":"http://127.0.0.1:8080","loginType":"iam1"}}' \
http://localhost:8080/zstack/v1/create/cas/client
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 4.5.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.5.0
casServerLoginUrl String body(包含在params结构中) casServerLoginUrl 4.5.0
casServerUrlPrefix String body(包含在params结构中) casServerUrlPrefix 4.5.0
serverName String body(包含在params结构中) mn的地址(http://{mn_ip:port}/8080) 4.5.0
loginType String body(包含在params结构中) 登录的类型:
  • cas-iam1
  • cas-iam2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
urlTemplate (可选) String body(包含在params结构中) 免密登录之后的跳转 4.5.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.5.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.5.0
systemTags (可选) List body 系统标签 4.5.0
userTags (可选) List body 用户标签 4.5.0

API返回

返回示例
{
  "inventory": {
    "casServerUrlPrefix": "http://zstack.com",
    "serverName": "http://127.0.0.1",
    "state": "Enabled",
    "uuid": "6bc5a073efd73d6d861d348694abcc91",
    "loginMNUrl": "http://127.0.0.1:8080/zstack/sso/cas/"
  }
}
名字 类型 描述 起始版本
success boolean 4.5.0
inventory CasClientInventory 详情参考inventory 4.5.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.5.0
#inventory
名字 类型 描述 起始版本
casServerLoginUrl String casServerLoginUrl 4.5.0
casServerUrlPrefix String casServerUrlPrefix 4.5.0
serverName String mn的地址(http://{mn_ip:port}/8080) 4.5.0
uuid String 资源的UUID,唯一标示该资源 4.5.0
name String 资源名称 4.5.0
description String 资源的详细描述 4.5.0
clientType String clientType 4.5.0
loginType String 登录的类型:
  • cas-iam1
  • cas-ima2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
loginMNUrl String 免密登录的url 4.5.0
createDate Timestamp 创建时间 4.5.0
lastOpDate Timestamp 最后一次修改时间 4.5.0
accountUuid String 账户UUID 4.5.0
state CasState 详情参考state 4.5.0
#state
名字 类型 描述 起始版本
Enabled CasState 4.5.0
Disabled CasState 4.5.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.5.0
description String 错误的概要描述 4.5.0
details String 错误的详细信息 4.5.0
elaboration String 保留字段,默认为null 4.5.0
opaque LinkedHashMap 保留字段,默认为null 4.5.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.5.0

SDK示例

Java SDK
CreateCasClientAction action = new CreateCasClientAction();
action.name = "test";
action.description = "test";
action.casServerLoginUrl = "http://zstack.com/login";
action.casServerUrlPrefix = "http://zstack.com";
action.serverName = "http://127.0.0.1:8080";
action.loginType = "iam1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateCasClientAction.Result res = action.call();
Python SDK
CreateCasClientAction action = CreateCasClientAction()
action.name = "test"
action.description = "test"
action.casServerLoginUrl = "http://zstack.com/login"
action.casServerUrlPrefix = "http://zstack.com"
action.serverName = "http://127.0.0.1:8080"
action.loginType = "iam1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateCasClientAction.Result res = action.call()

更新CAS客户端(UpdateCasClient)

API请求

URLs
POST zstack/v1/update/cas/client
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "uuid": "c9b85d8d64353f89a0fc97833dbda36e",
    "description": "test",
    "name": "test",
    "casServerLoginUrl": "http://zstack.com/login",
    "casServerUrlPrefix": "http://zstack.com",
    "serverName": "http://127.0.0.1:8080",
    "loginType": "iam1"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"uuid":"c9b85d8d64353f89a0fc97833dbda36e","description":"test","name":"test","casServerLoginUrl":"http://zstack.com/login","casServerUrlPrefix":"http://zstack.com","serverName":"http://127.0.0.1:8080","loginType":"iam1"}}' \
http://localhost:8080/zstack/v1/update/cas/client
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在params结构中) 资源的UUID,唯一标示该资源 4.5.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.5.0
name (可选) String body(包含在params结构中) 资源名称 4.5.0
casServerLoginUrl (可选) String body(包含在params结构中) casServerLoginUrl 4.5.0
casServerUrlPrefix (可选) String body(包含在params结构中) casServerUrlPrefix 4.5.0
serverName (可选) String body(包含在params结构中) mn的地址(http://{mn_ip:port}/8080) 4.5.0
loginType (可选) String body(包含在params结构中) 登录的类型:
  • cas-iam1
  • cas-iam2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
systemTags (可选) List body 系统标签 4.5.0
userTags (可选) List body 用户标签 4.5.0

API返回

返回示例
{
  "inventory": {
    "casServerLoginUrl": "http://zstack.com/login",
    "casServerUrlPrefix": "http://zstack.com",
    "serverName": "http://127.0.0.1:8080/",
    "uuid": "5068f4c641153a3d9353c3326dc1dd5e",
    "name": "test",
    "description": "test",
    "loginType": "iam2",
    "loginMNUrl": "http://127.0.0.1:8080/zstack/sso/cas/"
  }
}
名字 类型 描述 起始版本
success boolean 4.5.0
inventory CasClientInventory 详情参考inventory 4.5.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.5.0
#inventory
名字 类型 描述 起始版本
casServerLoginUrl String casServerLoginUrl 4.5.0
casServerUrlPrefix String casServerUrlPrefix 4.5.0
serverName String mn的地址(http://{mn_ip:port}/8080) 4.5.0
uuid String 资源的UUID,唯一标示该资源 4.5.0
name String 资源名称 4.5.0
description String 资源的详细描述 4.5.0
clientType String clientType 4.5.0
loginType String 登录的类型:
  • cas-iam1
  • cas-ima2
  • oauth2-iam1
  • oauth2-iam2
4.5.0
loginMNUrl String 免密登录的url 4.5.0
createDate Timestamp 创建时间 4.5.0
lastOpDate Timestamp 最后一次修改时间 4.5.0
accountUuid String 账户UUID 4.5.0
state CasState 详情参考state 4.5.0
#state
名字 类型 描述 起始版本
Enabled CasState 4.5.0
Disabled CasState 4.5.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.5.0
description String 错误的概要描述 4.5.0
details String 错误的详细信息 4.5.0
elaboration String 保留字段,默认为null 4.5.0
opaque LinkedHashMap 保留字段,默认为null 4.5.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.5.0

SDK示例

Java SDK
UpdateCasClientAction action = new UpdateCasClientAction();
action.uuid = "c9b85d8d64353f89a0fc97833dbda36e";
action.description = "test";
action.name = "test";
action.casServerLoginUrl = "http://zstack.com/login";
action.casServerUrlPrefix = "http://zstack.com";
action.serverName = "http://127.0.0.1:8080";
action.loginType = "iam1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateCasClientAction.Result res = action.call();
Python SDK
UpdateCasClientAction action = UpdateCasClientAction()
action.uuid = "c9b85d8d64353f89a0fc97833dbda36e"
action.description = "test"
action.name = "test"
action.casServerLoginUrl = "http://zstack.com/login"
action.casServerUrlPrefix = "http://zstack.com"
action.serverName = "http://127.0.0.1:8080"
action.loginType = "iam1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateCasClientAction.Result res = action.call()

删除认证客户端(DeleteSSOClient)

API请求

URLs
POST zstack/v1/delete/sso/client
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "uuid": "3e54cb2e27ff31dda2c49851bf2662d2",
    "deleteMode": "Permissive"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"uuid":"3e54cb2e27ff31dda2c49851bf2662d2","deleteMode":"Permissive"}}' \
http://localhost:8080/zstack/v1/delete/sso/client
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在params结构中) 资源的UUID,唯一标示该资源 4.5.0
deleteMode (可选) String body(包含在params结构中) 删除模式:
  • Permissive
  • Enforcing,Permissive
4.5.0
systemTags (可选) List body 系统标签 4.5.0
userTags (可选) List body 用户标签 4.5.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteSSOClientAction action = new DeleteSSOClientAction();
action.uuid = "3e54cb2e27ff31dda2c49851bf2662d2";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteSSOClientAction.Result res = action.call();
Python SDK
DeleteSSOClientAction action = DeleteSSOClientAction()
action.uuid = "3e54cb2e27ff31dda2c49851bf2662d2"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteSSOClientAction.Result res = action.call()

获取认证客户端(GetSSOClient)

API请求

URLs
GET zstack/v1/get/sso/client
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-X  GET http://localhost:8080/zstack/v1/get/sso/client
参数列表
名字 类型 位置 描述 可选值 起始版本
systemTags (可选) List body 系统标签 4.6.21
userTags (可选) List body 用户标签 4.6.21

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "1fbb7c4cb98d38beb31fa9bd74bff347",
      "name": "test",
      "clientType": "OIDC",
      "loginMNUrl": "http://127.0.0.1:8080/zstack/sso/oauth2/"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 4.6.21
inventories List 详情参考inventories 4.6.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.6.21
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.6.21
name String 资源名称 4.6.21
description String 资源的详细描述 4.6.21
clientType String 客户端类型 4.6.21
loginType String 登录类型 4.6.21
loginMNUrl String 登录跳转url 4.6.21
createDate Timestamp 创建时间 4.6.21
lastOpDate Timestamp 最后一次修改时间 4.6.21
accountUuid String 账户UUID 4.6.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.6.21
description String 错误的概要描述 4.6.21
details String 错误的详细信息 4.6.21
elaboration String 保留字段,默认为null 4.6.21
opaque LinkedHashMap 保留字段,默认为null 4.6.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.6.21

SDK示例

Java SDK
GetSSOClientAction action = new GetSSOClientAction();
GetSSOClientAction.Result res = action.call();
Python SDK
GetSSOClientAction action = GetSSOClientAction()
GetSSOClientAction.Result res = action.call()

修改重定向UI(UpdateSSORedirectTemplate)

API请求

URLs
POST zstack/v1/update/sso/redirectTemplate
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "uuid": "35cc6909f0f23e55a209cd552d8bc938",
    "redirectTemplate": "http://zstack.com/userinfoUrl"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X POST -d '{"params":{"uuid":"35cc6909f0f23e55a209cd552d8bc938","redirectTemplate":"http://zstack.com/userinfoUrl"}}'
http://localhost:8080/zstack/v1/update/sso/redirectTemplate
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在params结构中) 资源的UUID,唯一标示该资源 4.7.21
redirectTemplate String body(包含在params结构中) UI重定向地址 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "43679041066d37b28f676a49851ade69",
    "clientUuid": "3e5541e27b9c320fa4ad0a86777cc5ab",
    "redirectTemplate": "http://zstack.com/code"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
inventory OAuth2ClientInventory 详情参考inventory 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.7.21
name String 资源名称 4.7.21
description String 资源的详细描述 4.7.21
clientUuid String 客户端uuid 4.7.21
redirectTemplate String 跳转的模板 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21

SDK示例

Java SDK
UpdateSSORedirectTemplateAction action = new UpdateSSORedirectTemplateAction();
action.uuid = "35cc6909f0f23e55a209cd552d8bc938";
action.redirectTemplate = "http://zstack.com/userinfoUrl";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSSORedirectTemplateAction.Result res = action.call();
Python SDK
UpdateSSORedirectTemplateAction action = UpdateSSORedirectTemplateAction()
action.uuid = "35cc6909f0f23e55a209cd552d8bc938"
action.redirectTemplate = "http://zstack.com/userinfoUrl"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSSORedirectTemplateAction.Result res = action.call()
开发手册 | 5.4.12 | ZStack Cloud · ZCF | ZStack 资源中心