Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
112780eb
authored
Sep 30, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: passkey security
parent
f3477cb2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
35 deletions
+44
-35
controller/passkey.go
+8
-13
router/api-router.go
+1
-1
web/src/components/table/users/UsersColumnDefs.jsx
+34
-20
web/src/hooks/users/useUsersData.jsx
+1
-1
No files found.
controller/passkey.go
View file @
112780eb
...
...
@@ -189,13 +189,8 @@ func PasskeyStatus(c *gin.Context) {
}
data
:=
gin
.
H
{
"enabled"
:
true
,
"last_used_at"
:
credential
.
LastUsedAt
,
"backup_eligible"
:
credential
.
BackupEligible
,
"backup_state"
:
credential
.
BackupState
,
}
if
credential
!=
nil
{
data
[
"credential_aaguid"
]
=
fmt
.
Sprintf
(
"%x"
,
credential
.
AAGUID
)
"enabled"
:
true
,
"last_used_at"
:
credential
.
LastUsedAt
,
}
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
...
...
@@ -278,14 +273,14 @@ func PasskeyLoginFinish(c *gin.Context) {
return
nil
,
errors
.
New
(
"该用户已被禁用"
)
}
// 验证用户句柄(如果提供的话)
if
len
(
userHandle
)
>
0
{
if
userID
,
parseErr
:=
strconv
.
Atoi
(
string
(
userHandle
));
parseErr
==
nil
{
if
userID
!=
user
.
Id
{
return
nil
,
errors
.
New
(
"用户句柄与凭证不匹配"
)
}
userID
,
parseErr
:=
strconv
.
Atoi
(
string
(
userHandle
))
if
parseErr
!=
nil
{
// 记录异常但继续验证,因为某些客户端可能使用非数字格式
common
.
SysLog
(
fmt
.
Sprintf
(
"PasskeyLogin: userHandle parse error for credential, length: %d"
,
len
(
userHandle
)))
}
else
if
userID
!=
user
.
Id
{
return
nil
,
errors
.
New
(
"用户句柄与凭证不匹配"
)
}
// 如果解析失败,不做严格验证,因为某些情况下userHandle可能为空或格式不同
}
return
passkeysvc
.
NewWebAuthnUser
(
user
,
credential
),
nil
...
...
router/api-router.go
View file @
112780eb
...
...
@@ -99,7 +99,7 @@ func SetApiRouter(router *gin.Engine) {
adminRoute
.
POST
(
"/manage"
,
controller
.
ManageUser
)
adminRoute
.
PUT
(
"/"
,
controller
.
UpdateUser
)
adminRoute
.
DELETE
(
"/:id"
,
controller
.
DeleteUser
)
adminRoute
.
DELETE
(
"/:id/passkey"
,
controller
.
AdminResetPasskey
)
adminRoute
.
DELETE
(
"/:id/
reset_
passkey"
,
controller
.
AdminResetPasskey
)
// Admin 2FA routes
adminRoute
.
GET
(
"/2fa/stats"
,
controller
.
Admin2FAStats
)
...
...
web/src/components/table/users/UsersColumnDefs.jsx
View file @
112780eb
...
...
@@ -26,7 +26,9 @@ import {
Progress
,
Popover
,
Typography
,
Dropdown
,
}
from
'@douyinfe/semi-ui'
;
import
{
IconMore
}
from
'@douyinfe/semi-icons'
;
import
{
renderGroup
,
renderNumber
,
renderQuota
}
from
'../../../helpers'
;
/**
...
...
@@ -213,6 +215,28 @@ const renderOperations = (
return
<></>;
}
const
moreMenu
=
[
{
node
:
'item'
,
name
:
t
(
'重置 Passkey'
),
onClick
:
()
=>
showResetPasskeyModal
(
record
),
},
{
node
:
'item'
,
name
:
t
(
'重置 2FA'
),
onClick
:
()
=>
showResetTwoFAModal
(
record
),
},
{
node
:
'divider'
,
},
{
node
:
'item'
,
name
:
t
(
'注销'
),
type
:
'danger'
,
onClick
:
()
=>
showDeleteModal
(
record
),
},
];
return
(
<
Space
>
{
record
.
status
===
1
?
(
...
...
@@ -255,27 +279,17 @@ const renderOperations = (
>
{
t
(
'降级'
)
}
</
Button
>
<
Butto
n
type=
'warning'
size=
'small
'
onClick=
{
()
=>
showResetPasskeyModal
(
record
)
}
<
Dropdow
n
menu=
{
moreMenu
}
trigger=
'click
'
position=
'bottomRight'
>
{
t
(
'重置 Passkey'
)
}
</
Button
>
<
Button
type=
'warning'
size=
'small'
onClick=
{
()
=>
showResetTwoFAModal
(
record
)
}
>
{
t
(
'重置 2FA'
)
}
</
Button
>
<
Button
type=
'danger'
size=
'small'
onClick=
{
()
=>
showDeleteModal
(
record
)
}
>
{
t
(
'注销'
)
}
</
Button
>
<
Button
type=
'tertiary'
size=
'small'
icon=
{
<
IconMore
/>
}
/>
</
Dropdown
>
</
Space
>
);
};
...
...
web/src/hooks/users/useUsersData.jsx
View file @
112780eb
...
...
@@ -159,7 +159,7 @@ const searchUsers = async (
return
;
}
try
{
const
res
=
await
API
.
delete
(
`/api/user/
${
user
.
id
}
/passkey`
);
const
res
=
await
API
.
delete
(
`/api/user/
${
user
.
id
}
/
reset_
passkey`
);
const
{
success
,
message
}
=
res
.
data
;
if
(
success
)
{
showSuccess
(
t
(
'Passkey 已重置'
));
...
...
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