Skip to content

Commit

Permalink
feat: LDAP 数据源支持同时同步多个同级 OU (#1990)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJohw authored Nov 27, 2024
1 parent 66e09d0 commit c143671
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 39 deletions.
10 changes: 8 additions & 2 deletions src/pages/src/http/dataSourceFiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import http from './fetch';
import type {
DataSourceDetails,
DataSourceUsersParams,
DataSourceUsersResult,
DeleteDataSourcesParams,
Expand All @@ -12,9 +13,14 @@ import type {
PutDataSourceUserParams,
ResetPasswordParams,
SyncRecordsParams,
TestConnectionData,
TestConnectionParams,
} from './types/dataSourceFiles';

interface ResponseData<T> {
data: T
}

/**
* 数据源用户信息列表
*/
Expand Down Expand Up @@ -72,7 +78,7 @@ export const newDataSource = (params: NewDataSourceParams) => http.post('/api/v3
/**
* 数据源详情
*/
export const getDataSourceDetails = (id: string) => http.get(`/api/v3/web/data-sources/${id}/`);
export const getDataSourceDetails = (id: string) => http.get<ResponseData<DataSourceDetails>>(`/api/v3/web/data-sources/${id}/`);

/**
* 新建数据源默认配置
Expand All @@ -92,7 +98,7 @@ export const changeSwitchStatus = (id: string) => http.patch(`/api/v3/web/data-s
/**
* 数据源连通性测试
*/
export const postTestConnection = (params: TestConnectionParams) => http.post('/api/v3/web/data-sources/test-connection/', params);
export const postTestConnection = (params: TestConnectionParams) => http.post<ResponseData<TestConnectionData>>('/api/v3/web/data-sources/test-connection/', params);

/**
* 数据源同步
Expand Down
7 changes: 6 additions & 1 deletion src/pages/src/http/settingFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import type {
PutUserValidityParams,
RealUsersParams,
TenantItem,
TenantSettingFieldsData,
} from './types/settingFiles';

interface ResponseData<T> {
data: T
}

/**
* 用户字段列表
*/
export const getFields = () => http.get('/api/v3/web/tenant-setting/fields/');
export const getFields = () => http.get<ResponseData<TenantSettingFieldsData>>('/api/v3/web/tenant-setting/fields/');

/**
* 新建用户自定义字段
Expand Down
115 changes: 113 additions & 2 deletions src/pages/src/http/types/dataSourceFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface DataSourceUsersParams {
export interface NewDataSourceParams {
plugin_id: string,
plugin_config: {},
field_mapping?: [],
field_mapping?: any[],
sync_config?: {},
}

Expand All @@ -68,7 +68,7 @@ export interface NewDataSourceParams {
export interface PutDataSourceParams {
id: string,
plugin_config: {},
field_mapping: [],
field_mapping: any[],
}

/**
Expand Down Expand Up @@ -134,3 +134,114 @@ export interface DeleteDataSourcesParams {
id: string,
is_delete_idp?: string,
}

/**
* 数据源详情返回值
*/
export interface DataSourceDetails {
id: number,
owner_tenant_id: string,
type: string,
plugin: {
id: string,
name: string,
description: string,
logo: string,
},
plugin_config: {
server_config: {
server_base_url: string,
server_url: string,
bind_dn: string,
bind_password: string,
base_dn: string,
user_api_path: string,
user_api_query_params: any[],
department_api_path: string,
department_api_query_params: any[],
page_size: number,
request_timeout: number,
retries: number,
},
auth_config: {
method: string,
bearer_token: string,
username: string,
password: string,
},
data_config: {
user_object_class: string,
user_search_base_dns: string[],
dept_object_class: string,
dept_search_base_dns: string[],
},
leader_config: {
enabled: boolean,
leader_field: string,
},
user_group_config: {
enabled: boolean,
object_class: string,
search_base_dns: string[],
group_member_field: string,
},
},
sync_config: {
sync_period: number,
sync_timeout: number,
},
field_mapping: {
source_field: string,
mapping_operation: string,
target_field: string,
}[],
}

/**
* 数据源连通性测试返回值
*/
export interface TestConnectionData {
error_message: string,
user: {
code: string,
properties: {
username: string,
full_name: string,
email: string,
phone: string,
phone_country_code: string,
age: string,
gender: string,
region: string,
},
leaders: any[],
departments: string[],
},
department: {
id: string,
name: string,
parent: any,
},
extras: {
user_data: {
departments: string[],
email: string,
extras: {
age: string,
gender: string,
region: string,
},
full_name: string,
id: string,
leaders: any[],
phone: string,
phone_country_code: string,
username: string,
},
department_data: {
id: string,
name: string,
parent: any,
},
},
}
14 changes: 14 additions & 0 deletions src/pages/src/http/types/settingFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,17 @@ export interface CollaborationSyncRecordsParams {
export interface TenantItem {
tenant_ids: string
}

export interface TenantSettingFieldsData {
builtin_fields: {
id: number,
name: string,
display_name: string,
data_type: string,
required: boolean,
unique: boolean,
default: string,
options: any[],
}[],
custom_fields: any[],
}
4 changes: 4 additions & 0 deletions src/pages/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@
"用户对象类": "User Object Class",
"用户过滤器": "User filter",
"过滤器中无需指定对象类,如(objectclass=xxx)": "No object class needs to be specified in the filter, such as (objectclass=xxx)",
"支持同步多个 LDAP 树(森林),需为每棵树指定相应的BaseDN": "Support synchronizing multiple LDAP trees (forests), with corresponding BaseDN specified for each tree",
"部门对象类": "Department Object Class",
"LDAP 服务地址": "LDAP service address",
"Bind DN 密码": "Bind DN password",
"用户 Base DN": "User Base DN",
"部门 Base DN": "Department Base DN",
"用户组 Base DN": "User Group Base DN",
"根目录 (Base DN)": "Root directory (Base DN)",
"服务地址": "Service address",
"用户数据 API 路径": "User data API path",
Expand Down
4 changes: 4 additions & 0 deletions src/pages/src/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@
"用户对象类": "用户对象类",
"用户过滤器": "用户过滤器",
"过滤器中无需指定对象类,如(objectclass=xxx)": "过滤器中无需指定对象类,如(objectclass=xxx)",
"支持同步多个 LDAP 树(森林),需为每棵树指定相应的BaseDN": "支持同步多个 LDAP 树(森林),需为每棵树指定相应的BaseDN",
"部门对象类": "部门对象类",
"LDAP 服务地址": "LDAP 服务地址",
"Bind DN 密码": "Bind DN 密码",
"用户 Base DN": "用户 Base DN",
"部门 Base DN": "部门 Base DN",
"用户组 Base DN": "用户组 Base DN",
"根目录 (Base DN)": "根目录 (Base DN)",
"服务地址": "服务地址",
"用户数据 API 路径": "用户数据 API 路径",
Expand Down
Loading

0 comments on commit c143671

Please sign in to comment.