e31cc54b8e
- 门户通用聊天:选择已批准模型直接对话,审批通过后自动开通用户级运行时 API Key(加密落库,限额取批准值),聊天经受管网关统一认证/限流/配额/审计; 会话哈希链完整性 + busy 租约防并发,失败不落库。 - 扫码登录:identity_providers 扩展 wecom/dingtalk/feishu,管理端配置 (AppID/AppSecret/AgentID/回调/自动开户/默认部门),登录页自动展示; one-time state 防 CSRF,provider_uid 全局唯一防多账号绑定,平台端点 固定公网 URL 复用 public-only 拨号。 - 个人安全策略:账号安全页(登录设备管理/吊销非当前会话/登录提醒开关/ 扫码绑定解绑),登录成功发布 security.login_detected 事件按偏好落站内信 (新增 security 类别),会话索引只存令牌摘要并惰性清理。 - 迁移 000038-000041;修复 social update 参数越界/凭据回读/路由挂载缺失; 全量测试 25 包通过,前端 admin/portal 构建通过,端到端验证完成。
210 lines
5.3 KiB
TypeScript
210 lines
5.3 KiB
TypeScript
import request from '@/utils/http'
|
|
|
|
export type IdentityKind = 'admin' | 'portal'
|
|
|
|
export interface IdentityRecord {
|
|
id: string
|
|
kind: IdentityKind
|
|
login: string
|
|
display_name: string
|
|
role: string
|
|
permissions: string[]
|
|
effective_permissions: string[]
|
|
active: boolean
|
|
auth_source: string
|
|
totp_enabled: boolean
|
|
locked_until?: string
|
|
created_at: string
|
|
updated_at: string
|
|
department_id?: string
|
|
department_name?: string
|
|
}
|
|
|
|
export interface IdentityInput {
|
|
login: string
|
|
display_name: string
|
|
role: string
|
|
password?: string
|
|
permissions: string[]
|
|
active: boolean
|
|
department_id?: string
|
|
}
|
|
|
|
export interface DepartmentRecord {
|
|
id: string
|
|
code: string
|
|
name: string
|
|
description: string
|
|
parent_id?: string
|
|
parent_name?: string
|
|
active: boolean
|
|
user_count: number
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface DepartmentInput {
|
|
code: string
|
|
name: string
|
|
description: string
|
|
parent_id?: string
|
|
active: boolean
|
|
}
|
|
|
|
export interface IdentityProviderRecord {
|
|
id: string
|
|
code: string
|
|
display_name: string
|
|
issuer_url: string
|
|
client_id: string
|
|
secret_configured: boolean
|
|
redirect_uri: string
|
|
portal_return_url: string
|
|
scopes: string[]
|
|
auto_provision: boolean
|
|
default_department_id?: string
|
|
enabled: boolean
|
|
revision: number
|
|
credential_kek_version: number
|
|
}
|
|
|
|
export interface IdentityProviderInput {
|
|
code: string
|
|
display_name: string
|
|
issuer_url: string
|
|
client_id: string
|
|
client_secret?: string
|
|
redirect_uri: string
|
|
portal_return_url: string
|
|
scopes: string[]
|
|
auto_provision: boolean
|
|
default_department_id?: string
|
|
enabled: boolean
|
|
}
|
|
|
|
export interface SAMLProviderRecord {
|
|
id: string
|
|
kind: 'saml'
|
|
code: string
|
|
display_name: string
|
|
metadata_url: string
|
|
sp_entity_id: string
|
|
acs_url: string
|
|
portal_return_url: string
|
|
email_attribute: string
|
|
name_attribute: string
|
|
auto_provision: boolean
|
|
default_department_id?: string
|
|
enabled: boolean
|
|
revision: number
|
|
}
|
|
|
|
export type SAMLProviderInput = Omit<SAMLProviderRecord, 'id' | 'kind' | 'revision'>
|
|
|
|
function resource(kind: IdentityKind) {
|
|
return kind === 'admin' ? 'admins' : 'portal-users'
|
|
}
|
|
|
|
export function fetchIdentities(kind: IdentityKind) {
|
|
return request.get<IdentityRecord[]>({
|
|
url: `/api/v1/admin/identities/${resource(kind)}`
|
|
})
|
|
}
|
|
|
|
export function createIdentity(kind: IdentityKind, data: IdentityInput) {
|
|
return request.post<IdentityRecord>({
|
|
url: `/api/v1/admin/identities/${resource(kind)}`,
|
|
params: data
|
|
})
|
|
}
|
|
|
|
export function updateIdentity(kind: IdentityKind, id: string, data: IdentityInput) {
|
|
return request.put<IdentityRecord>({
|
|
url: `/api/v1/admin/identities/${resource(kind)}/${id}`,
|
|
params: data
|
|
})
|
|
}
|
|
|
|
export function fetchDepartments() {
|
|
return request.get<DepartmentRecord[]>({ url: '/api/v1/admin/departments' })
|
|
}
|
|
|
|
export function createDepartment(data: DepartmentInput) {
|
|
return request.post<DepartmentRecord>({ url: '/api/v1/admin/departments', params: data })
|
|
}
|
|
|
|
export function updateDepartment(id: string, data: DepartmentInput) {
|
|
return request.put<DepartmentRecord>({ url: `/api/v1/admin/departments/${id}`, params: data })
|
|
}
|
|
|
|
export function fetchIdentityProviders() {
|
|
return request.get<IdentityProviderRecord[]>({ url: '/api/v1/admin/identity-providers' })
|
|
}
|
|
|
|
export function createIdentityProvider(data: IdentityProviderInput) {
|
|
return request.post<IdentityProviderRecord>({ url: '/api/v1/admin/identity-providers', params: data })
|
|
}
|
|
|
|
export function updateIdentityProvider(id: string, data: IdentityProviderInput) {
|
|
return request.put<IdentityProviderRecord>({ url: `/api/v1/admin/identity-providers/${id}`, params: data })
|
|
}
|
|
|
|
export function fetchSAMLProviders() {
|
|
return request.get<SAMLProviderRecord[]>({ url: '/api/v1/admin/saml-providers' })
|
|
}
|
|
|
|
export function createSAMLProvider(data: SAMLProviderInput) {
|
|
return request.post<SAMLProviderRecord>({ url: '/api/v1/admin/saml-providers', params: data })
|
|
}
|
|
|
|
export function updateSAMLProvider(id: string, data: SAMLProviderInput) {
|
|
return request.put<SAMLProviderRecord>({ url: `/api/v1/admin/saml-providers/${id}`, params: data })
|
|
}
|
|
|
|
export interface SocialProviderRecord {
|
|
id: string
|
|
code: string
|
|
kind: 'wecom' | 'dingtalk' | 'feishu'
|
|
display_name: string
|
|
client_id: string
|
|
agent_id: string
|
|
secret_configured: boolean
|
|
redirect_uri: string
|
|
portal_return_url: string
|
|
auto_provision: boolean
|
|
default_department_id?: string
|
|
enabled: boolean
|
|
revision: number
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface SocialProviderInput {
|
|
code: string
|
|
display_name: string
|
|
client_id: string
|
|
agent_id?: string
|
|
secret?: string
|
|
redirect_uri: string
|
|
portal_return_url: string
|
|
auto_provision: boolean
|
|
default_department_id?: string
|
|
enabled: boolean
|
|
}
|
|
|
|
export function fetchSocialProviders() {
|
|
return request.get<SocialProviderRecord[]>({ url: '/api/v1/admin/social-providers' })
|
|
}
|
|
|
|
export function createSocialProvider(kind: string, data: SocialProviderInput) {
|
|
return request.post<SocialProviderRecord>({ url: '/api/v1/admin/social-providers', params: { kind }, data })
|
|
}
|
|
|
|
export function updateSocialProvider(kind: string, data: SocialProviderInput) {
|
|
return request.put<SocialProviderRecord>({ url: `/api/v1/admin/social-providers/${kind}`, params: data })
|
|
}
|
|
|
|
export function deleteSocialProvider(kind: string) {
|
|
return request.del({ url: `/api/v1/admin/social-providers/${kind}` })
|
|
}
|