+30
-2
@@ -10,7 +10,7 @@ import {
|
||||
mockUserDetails,
|
||||
mockUsers,
|
||||
} from './mock'
|
||||
import { mockOn, mocked, request } from './request'
|
||||
import { mockOn, mocked, rawFetch, request } from './request'
|
||||
import type {
|
||||
AuditEventsResult,
|
||||
IamUser,
|
||||
@@ -18,6 +18,7 @@ import type {
|
||||
IamUserDetail,
|
||||
IdentityProvider,
|
||||
IdentitySetting,
|
||||
IdpIconUpload,
|
||||
LimitItem,
|
||||
LimitService,
|
||||
NotificationRecipients,
|
||||
@@ -298,7 +299,7 @@ export interface CreateIdpBody {
|
||||
name: string
|
||||
metadata: string
|
||||
description?: string
|
||||
/** logo:data URI 或外链 URL */
|
||||
/** logo:http(s) 外链 URL(可先经 IdP 图标上传接口取得) */
|
||||
iconUrl?: string
|
||||
nameIdFormat?: string
|
||||
/** 非空表示按断言属性映射;空则按 SAML NameID 映射 */
|
||||
@@ -325,6 +326,33 @@ export function createIdp(id: number, body: CreateIdpBody, domainId?: string): P
|
||||
return request(`/oci-configs/${id}/identity-providers`, { method: 'POST', body, query: { domainId } })
|
||||
}
|
||||
|
||||
/** 上传 IdP 图标到身份域公共图片存储,返回可填入 iconUrl 的公网地址(multipart 走 rawFetch) */
|
||||
export async function uploadIdpIcon(
|
||||
id: number,
|
||||
file: File,
|
||||
domainId?: string,
|
||||
): Promise<IdpIconUpload> {
|
||||
if (mockOn)
|
||||
return mocked({ url: 'https://mock.local/images/idp-icon.png', fileName: 'images/idp-icon.png' }, 600)
|
||||
const fd = new FormData()
|
||||
fd.append('file', file, file.name)
|
||||
const resp = await rawFetch(`/oci-configs/${id}/idp-icons`, {
|
||||
method: 'POST',
|
||||
query: { domainId },
|
||||
body: fd,
|
||||
})
|
||||
return (await resp.json()) as IdpIconUpload
|
||||
}
|
||||
|
||||
/** 删除尚未被 IdP 采用的身份域公共图片 */
|
||||
export function deleteIdpIcon(id: number, fileName: string, domainId?: string): Promise<void> {
|
||||
if (mockOn) return mocked(undefined)
|
||||
return request(`/oci-configs/${id}/idp-icons`, {
|
||||
method: 'DELETE',
|
||||
query: { domainId, fileName },
|
||||
})
|
||||
}
|
||||
|
||||
export function listIdps(id: number, domainId?: string): Promise<IdentityProvider[]> {
|
||||
if (mockOn) return mocked(mockIdps)
|
||||
return request(`/oci-configs/${id}/identity-providers`, { query: { domainId } })
|
||||
|
||||
Reference in New Issue
Block a user