Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
2f4cc1c0
Unverified
Commit
2f4cc1c0
authored
Jun 17, 2023
by
gaoyan
Committed by
GitHub
Jun 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature add import user from ldap (#2080)
* add import user from ldap * fix code style * fix ui
parent
48cd4a7c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
143 additions
and
40 deletions
+143
-40
LdapContext.java
dinky-admin/src/main/java/org/dinky/context/LdapContext.java
+1
-0
LdapController.java
...in/src/main/java/org/dinky/controller/LdapController.java
+26
-7
pages.ts
dinky-web/src/locales/en-US/pages.ts
+1
-0
pages.ts
dinky-web/src/locales/zh-CN/pages.ts
+1
-0
LoadUser.tsx
...tting/SettingOverView/LdapConfig/compontents/LoadUser.tsx
+77
-0
TestLogin.tsx
...ting/SettingOverView/LdapConfig/compontents/TestLogin.tsx
+29
-0
index.tsx
...Center/GlobalSetting/SettingOverView/LdapConfig/index.tsx
+6
-30
api.ts
dinky-web/src/services/api.ts
+1
-3
constants.tsx
dinky-web/src/services/constants.tsx
+1
-0
No files found.
dinky-admin/src/main/java/org/dinky/context/LdapContext.java
View file @
2f4cc1c0
...
...
@@ -103,6 +103,7 @@ public class LdapContext {
user
.
setUsername
(
usernameAttr
.
get
().
toString
());
user
.
setNickname
(
nicknameAttr
.
get
().
toString
());
user
.
setUserType
(
UserType
.
LDAP
.
getCode
());
user
.
setEnabled
(
true
);
return
user
;
}
...
...
dinky-admin/src/main/java/org/dinky/controller/LdapController.java
View file @
2f4cc1c0
...
...
@@ -25,9 +25,9 @@ import org.dinky.data.enums.Status;
import
org.dinky.data.exception.AuthException
;
import
org.dinky.data.model.SystemConfiguration
;
import
org.dinky.data.model.User
;
import
org.dinky.data.result.ProTableResult
;
import
org.dinky.data.result.Result
;
import
org.dinky.service.LdapService
;
import
org.dinky.service.UserService
;
import
java.util.List
;
...
...
@@ -51,6 +51,8 @@ public class LdapController {
@Autowired
LdapService
ldapService
;
@Autowired
UserService
userService
;
@GetMapping
(
"/ldapEnableStatus"
)
public
Result
<
Boolean
>
ldapStatus
()
{
return
Result
.
succeed
(
...
...
@@ -68,13 +70,30 @@ public class LdapController {
}
@GetMapping
(
"/listUser"
)
public
ProTableResult
<
User
>
listUser
()
{
public
Result
<
List
<
User
>
>
listUser
()
{
List
<
User
>
users
=
ldapService
.
listUsers
();
return
ProTableResult
.<
User
>
builder
()
.
success
(
true
)
.
data
(
users
)
.
total
((
long
)
users
.
size
())
.
build
();
List
<
User
>
localUsers
=
userService
.
list
();
users
.
stream
()
.
filter
(
ldapUser
->
localUsers
.
stream
()
.
anyMatch
(
user
->
user
.
getUsername
()
.
equals
(
ldapUser
.
getUsername
())))
.
forEach
(
user
->
user
.
setEnabled
(
false
));
return
Result
.
succeed
(
users
);
}
@PostMapping
(
"/importUsers"
)
public
Result
<
Void
>
importUsers
(
@RequestBody
List
<
User
>
users
)
{
boolean
b
=
userService
.
saveBatch
(
users
);
if
(
b
)
{
return
Result
.
succeed
();
}
return
Result
.
failed
();
}
/**
...
...
dinky-web/src/locales/en-US/pages.ts
View file @
2f4cc1c0
...
...
@@ -580,6 +580,7 @@ export default {
'sys.ldap.settings.testConnect.success'
:
'Test Connect Successful, {count} users were obtained'
,
'sys.ldap.settings.testLogin'
:
'Test Login'
,
'sys.ldap.settings.loadUser'
:
'Load User'
,
'sys.ldap.settings.loadable'
:
'Whether it can be imported'
,
// process
'sys.process.id'
:
'Process ID'
,
...
...
dinky-web/src/locales/zh-CN/pages.ts
View file @
2f4cc1c0
...
...
@@ -582,6 +582,7 @@ export default {
'sys.ldap.settings.testConnect.success'
:
'测试连接成功,获取到了{count}个用户'
,
'sys.ldap.settings.testLogin'
:
'测试登录'
,
'sys.ldap.settings.loadUser'
:
'导入用户'
,
'sys.ldap.settings.loadable'
:
'是否可以导入'
,
// process
...
...
dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig/compontents/LoadUser.tsx
0 → 100644
View file @
2f4cc1c0
import
React
,
{
useState
}
from
"react"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
Table
,
Tag
}
from
"antd"
;
import
{
UserSwitchOutlined
}
from
"@ant-design/icons"
;
import
{
handleOption
}
from
"@/services/BusinessCrud"
;
import
{
API_CONSTANTS
}
from
"@/services/constants"
;
import
{
UserBaseInfo
}
from
"@/types/User/data"
;
import
{
getData
}
from
"@/services/api"
;
import
{
ColumnsType
}
from
"antd/es/table"
;
import
{
ModalForm
}
from
"@ant-design/pro-components"
;
const
columns
:
ColumnsType
<
UserBaseInfo
.
User
>
=
[
{
title
:
l
(
"user.username"
),
dataIndex
:
"username"
,
},
{
title
:
l
(
"user.nickname"
),
dataIndex
:
"nickname"
,
},
{
title
:
l
(
"sys.ldap.settings.loadable"
),
dataIndex
:
"enabled"
,
render
:(
_
,
record
)
=>
record
.
enabled
?
l
(
'rc.ai.isSimple.yes'
):
l
(
'rc.ai.isSimple.no'
)
},
];
export
const
LoadUser
=
()
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
selectedUsers
,
setSelectedUsers
]
=
useState
<
UserBaseInfo
.
User
[]
>
([]);
const
[
users
,
setUsers
]
=
useState
<
UserBaseInfo
.
User
[]
>
([]);
const
fetchUserData
=
async
()
=>
{
setLoading
(
true
);
const
res
=
await
getData
(
API_CONSTANTS
.
LDAP_LIST_USER
);
setUsers
(
res
.
datas
);
setLoading
(
false
);
}
const
importUser
=
async
()
=>
{
await
handleOption
(
API_CONSTANTS
.
LDAP_IMPORT_USERS
,
l
(
"sys.ldap.settings.loadUser"
),
selectedUsers
);
await
fetchUserData
();
setSelectedUsers
([]);
}
return
<>
<
ModalForm
title=
{
l
(
"sys.ldap.settings.loadUser"
)
}
width=
{
800
}
onFinish=
{
()
=>
importUser
()
}
trigger=
{
<
Tag
icon=
{
<
UserSwitchOutlined
/>
}
color=
"#f50"
onClick=
{
()
=>
fetchUserData
()
}
>
{
l
(
"sys.ldap.settings.loadUser"
)
}
</
Tag
>
}
>
<
Table
<
UserBaseInfo
.
User
>
loading=
{
loading
}
size=
{
"small"
}
columns=
{
columns
}
rowSelection=
{
{
onChange
:
(
_
,
rows
)
=>
setSelectedUsers
(
rows
),
getCheckboxProps
:
(
record
)
=>
({
disabled
:
!
record
.
enabled
,}),
}
}
dataSource=
{
users
}
rowKey=
{
"username"
}
/
>
</
ModalForm
>
</>
;
};
dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig/compontents/TestLogin.tsx
0 → 100644
View file @
2f4cc1c0
import
React
from
"react"
;
import
{
ModalForm
,
ProFormText
}
from
"@ant-design/pro-components"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
Form
,
Tag
}
from
"antd"
;
import
{
LoginOutlined
}
from
"@ant-design/icons"
;
import
{
handleOption
}
from
"@/services/BusinessCrud"
;
import
{
API_CONSTANTS
}
from
"@/services/constants"
;
export
const
TestLogin
=
()
=>
{
const
[
form
]
=
Form
.
useForm
();
const
testLogin
=
async
(
value
:
any
)
=>
{
await
handleOption
(
API_CONSTANTS
.
LDAP_TEST_LOGIN
,
l
(
"sys.ldap.settings.testLogin"
),
value
);
}
return
<>
<
ModalForm
width=
{
400
}
onFinish=
{
testLogin
}
form=
{
form
}
modalProps=
{
{
onCancel
:()
=>
form
.
resetFields
()}
}
trigger=
{
<
Tag
icon=
{
<
LoginOutlined
/>
}
color=
"#108ee9"
>
{
l
(
"sys.ldap.settings.testLogin"
)
}
</
Tag
>
}
>
<
ProFormText
name=
"username"
label=
{
l
(
"login.username.placeholder"
)
}
/>
<
ProFormText
name=
"password"
label=
{
l
(
"login.password.placeholder"
)
}
/>
</
ModalForm
>
</>;
};
dinky-web/src/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig/index.tsx
View file @
2f4cc1c0
...
...
@@ -17,19 +17,19 @@
import
{
BaseConfigProperties
}
from
'@/types/SettingCenter/data'
;
import
{
ModalForm
,
ProCard
,
ProFormText
}
from
'@ant-design/pro-components'
;
import
{
ProCard
}
from
'@ant-design/pro-components'
;
import
GeneralConfig
from
'@/pages/SettingCenter/GlobalSetting/SettingOverView/GeneralConfig'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
Space
,
Tag
}
from
'antd'
;
import
React
from
'react'
;
import
{
ApiFilled
,
LoginOutlined
,
UserSwitchOutlined
,
}
from
"@ant-design/icons"
;
import
{
handleOption
,
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
{
queryDataByParams
}
from
"@/services/BusinessCrud"
;
import
{
API_CONSTANTS
}
from
"@/services/constants"
;
import
{
SuccessMessage
}
from
"@/utils/messages"
;
import
{
TestLogin
}
from
"@/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig/compontents/TestLogin"
;
import
{
LoadUser
}
from
"@/pages/SettingCenter/GlobalSetting/SettingOverView/LdapConfig/compontents/LoadUser"
;
interface
LdapConfigProps
{
data
:
BaseConfigProperties
[];
...
...
@@ -49,13 +49,6 @@ export const LdapConfig = ({data, onSave}: LdapConfigProps) => {
setLoading
(
false
);
}
const
testLogin
=
async
(
value
:
any
)
=>
{
setLoading
(
true
);
await
handleOption
(
API_CONSTANTS
.
LDAP_TEST_LOGIN
,
l
(
"sys.ldap.settings.testLogin"
),
value
);
setLoading
(
false
);
}
const
onSaveHandler
=
(
data
:
BaseConfigProperties
)
=>
{
setLoading
(
true
);
onSave
(
data
);
...
...
@@ -64,21 +57,6 @@ export const LdapConfig = ({data, onSave}: LdapConfigProps) => {
},
1000
);
};
/**
* render ldap test login form
*/
const
renderTestLoginForm
=
()
=>
{
return
(
<
ModalForm
width=
{
400
}
onFinish=
{
testLogin
}
trigger=
{
<
Tag
icon=
{
<
LoginOutlined
/>
}
color=
"#108ee9"
>
{
l
(
"sys.ldap.settings.testLogin"
)
}
</
Tag
>
}
>
<
ProFormText
name=
"username"
label=
{
l
(
"login.username.placeholder"
)
}
/>
<
ProFormText
name=
"password"
label=
{
l
(
"login.password.placeholder"
)
}
/>
</
ModalForm
>
)
}
/**
* render ldap test case toolbar
*/
...
...
@@ -88,10 +66,8 @@ export const LdapConfig = ({data, onSave}: LdapConfigProps) => {
<
Tag
icon=
{
<
ApiFilled
/>
}
color=
"#87d068"
onClick=
{
()
=>
testConnection
()
}
>
{
l
(
"sys.ldap.settings.testConnect"
)
}
</
Tag
>
{
renderTestLoginForm
()
}
<
Tag
icon=
{
<
UserSwitchOutlined
/>
}
color=
"#f50"
onClick=
{
()
=>
{}
}
>
{
l
(
"sys.ldap.settings.loadUser"
)
}
</
Tag
>
<
TestLogin
/>
<
LoadUser
/>
</
Space
>
];
};
...
...
dinky-web/src/services/api.ts
View file @
2f4cc1c0
...
...
@@ -119,9 +119,7 @@ export async function postDataArray(url: string, params: number[]) {
export
async
function
postAll
(
url
:
string
,
params
?:
any
)
{
return
request
(
url
,
{
method
:
METHOD_CONSTANTS
.
POST
,
data
:
{
...
params
,
},
data
:
params
,
});
}
...
...
dinky-web/src/services/constants.tsx
View file @
2f4cc1c0
...
...
@@ -188,6 +188,7 @@ export const API_CONSTANTS = {
LDAP_TEST_CONNECT
:
"/api/ldap/testConnection"
,
LDAP_TEST_LOGIN
:
"/api/ldap/testLogin"
,
LDAP_LIST_USER
:
"/api/ldap/listUser"
,
LDAP_IMPORT_USERS
:
"/api/ldap/importUsers"
,
// -- home
GET_STATUS_COUNT
:
"api/jobInstance/getStatusCount"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment