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
Unverified
Commit
1ac0f580
authored
Jun 13, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(audit): add authentication method tracking in audit logs
parent
51475c80
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
1 deletions
+42
-1
controller/audit.go
+8
-0
middleware/audit.go
+8
-0
web/default/rsbuild.config.ts
+1
-1
web/default/src/features/usage-logs/components/dialogs/details-dialog.tsx
+12
-0
web/default/src/features/usage-logs/types.ts
+1
-0
web/default/src/i18n/locales/en.json
+2
-0
web/default/src/i18n/locales/fr.json
+2
-0
web/default/src/i18n/locales/ja.json
+2
-0
web/default/src/i18n/locales/ru.json
+2
-0
web/default/src/i18n/locales/vi.json
+2
-0
web/default/src/i18n/locales/zh.json
+2
-0
No files found.
controller/audit.go
View file @
1ac0f580
...
...
@@ -68,9 +68,17 @@ func auditOperatorInfo(c *gin.Context) map[string]interface{} {
"admin_id"
:
c
.
GetInt
(
"id"
),
"admin_username"
:
c
.
GetString
(
"username"
),
"admin_role"
:
c
.
GetInt
(
"role"
),
"auth_method"
:
auditAuthMethod
(
c
),
}
}
func
auditAuthMethod
(
c
*
gin
.
Context
)
string
{
if
c
.
GetBool
(
"use_access_token"
)
{
return
"access_token"
}
return
"session"
}
// markAuditLogged 标记当前请求已在 handler 内手动记录审计日志,
// 使鉴权链路中的审计兜底(finishAdminAudit)跳过兜底记录,避免重复。
func
markAuditLogged
(
c
*
gin
.
Context
)
{
...
...
middleware/audit.go
View file @
1ac0f580
...
...
@@ -162,6 +162,7 @@ func finishAdminAudit(c *gin.Context, writer *auditResponseWriter) {
"admin_id"
:
operatorId
,
"admin_username"
:
operatorName
,
"admin_role"
:
operatorRole
,
"auth_method"
:
auditAuthMethod
(
c
),
}
auditInfo
:=
map
[
string
]
interface
{}{
"method"
:
method
,
...
...
@@ -179,6 +180,13 @@ func finishAdminAudit(c *gin.Context, writer *auditResponseWriter) {
})
}
func
auditAuthMethod
(
c
*
gin
.
Context
)
string
{
if
c
.
GetBool
(
"use_access_token"
)
{
return
"access_token"
}
return
"session"
}
// auditResponseSuccess 依据 HTTP 状态码与响应体推断操作是否成功。
// 优先解析响应 JSON 中的 success 字段;无法解析时退回到状态码判断。
func
auditResponseSuccess
(
status
int
,
body
[]
byte
)
bool
{
...
...
web/default/rsbuild.config.ts
View file @
1ac0f580
...
...
@@ -65,7 +65,7 @@ export default defineConfig(({ envMode }) => {
},
server
:
{
host
:
'0.0.0.0'
,
strictPort
:
tru
e
,
strictPort
:
fals
e
,
proxy
:
devProxy
,
},
output
:
{
...
...
web/default/src/features/usage-logs/components/dialogs/details-dialog.tsx
View file @
1ac0f580
...
...
@@ -473,6 +473,12 @@ export function DetailsDialog(props: DetailsDialogProps) {
if
(
hasUsername
)
return
String
(
username
)
return
`ID:
${
id
}
`
})()
const
authMethodLabel
=
(()
=>
{
if
(
!
isManage
||
!
props
.
isAdmin
||
!
adminInfo
?.
auth_method
)
return
''
if
(
adminInfo
.
auth_method
===
'access_token'
)
return
t
(
'Access Token'
)
if
(
adminInfo
.
auth_method
===
'session'
)
return
t
(
'Session'
)
return
String
(
adminInfo
.
auth_method
)
})()
// Localized operation text rendered from the language-independent op
// descriptor (shared by audit type=3 and login type=7).
...
...
@@ -806,6 +812,12 @@ export function DetailsDialog(props: DetailsDialogProps) {
{
operationText
!=
null
&&
(
<
DetailRow
label=
{
t
(
'Operation'
)
}
value=
{
operationText
}
/>
)
}
{
authMethodLabel
!==
''
&&
(
<
DetailRow
label=
{
t
(
'Authentication Method'
)
}
value=
{
authMethodLabel
}
/>
)
}
{
changedFieldsText
!==
''
&&
(
<
DetailRow
label=
{
t
(
'Changed Fields'
)
}
...
...
web/default/src/features/usage-logs/types.ts
View file @
1ac0f580
...
...
@@ -110,6 +110,7 @@ export interface LogOtherData {
admin_username
?:
string
admin_id
?:
number
|
string
admin_role
?:
number
auth_method
?:
'session'
|
'access_token'
|
string
}
// Language-independent operation descriptor (audit/login logs).
// Frontend renders localized content from action + params via i18n templates.
...
...
web/default/src/i18n/locales/en.json
View file @
1ac0f580
...
...
@@ -436,6 +436,7 @@
"auth.resetPasswordConfirm.retry"
:
"Retry ({{seconds}}s)"
,
"auth.resetPasswordConfirm.success"
:
"Your password has been reset successfully"
,
"Authentication"
:
"Authentication"
,
"Authentication Method"
:
"Authentication Method"
,
"Authenticator code"
:
"Authenticator code"
,
"Authorization Endpoint"
:
"Authorization Endpoint"
,
"Authorization Endpoint (Optional)"
:
"Authorization Endpoint (Optional)"
,
...
...
@@ -3686,6 +3687,7 @@
"Settings"
:
"Settings"
,
"Settings & Preferences"
:
"Settings & Preferences"
,
"Settings updated successfully"
:
"Settings updated successfully"
,
"Session"
:
"Session"
,
"Setup guide"
:
"Setup guide"
,
"Setup guide complete"
:
"Setup guide complete"
,
"Setup guide is collapsed. Expand it anytime."
:
"Setup guide is collapsed. Expand it anytime."
,
...
...
web/default/src/i18n/locales/fr.json
View file @
1ac0f580
...
...
@@ -436,6 +436,7 @@
"auth.resetPasswordConfirm.retry"
:
"Réessayer ({{seconds}}s)"
,
"auth.resetPasswordConfirm.success"
:
"Votre mot de passe a été réinitialisé avec succès"
,
"Authentication"
:
"Authentification"
,
"Authentication Method"
:
"Méthode d'authentification"
,
"Authenticator code"
:
"Code d'authentification"
,
"Authorization Endpoint"
:
"Point de terminaison d'autorisation"
,
"Authorization Endpoint (Optional)"
:
"Point de terminaison d'autorisation (Facultatif)"
,
...
...
@@ -3686,6 +3687,7 @@
"Settings"
:
"Paramètres"
,
"Settings & Preferences"
:
"Paramètres et préférences"
,
"Settings updated successfully"
:
"Paramètres mis à jour avec succès"
,
"Session"
:
"Session"
,
"Setup guide"
:
"Guide de configuration"
,
"Setup guide complete"
:
"Guide de configuration terminé"
,
"Setup guide is collapsed. Expand it anytime."
:
"Le guide de configuration est réduit. Vous pouvez le rouvrir à tout moment."
,
...
...
web/default/src/i18n/locales/ja.json
View file @
1ac0f580
...
...
@@ -436,6 +436,7 @@
"auth.resetPasswordConfirm.retry"
:
"再試行 ({{seconds}}秒)"
,
"auth.resetPasswordConfirm.success"
:
"パスワードが正常にリセットされました"
,
"Authentication"
:
"認証"
,
"Authentication Method"
:
"認証方式"
,
"Authenticator code"
:
"認証コード"
,
"Authorization Endpoint"
:
"認可エンドポイント"
,
"Authorization Endpoint (Optional)"
:
"認証エンドポイント (オプション)"
,
...
...
@@ -3686,6 +3687,7 @@
"Settings"
:
"設定"
,
"Settings & Preferences"
:
"設定と環境設定"
,
"Settings updated successfully"
:
"設定が正常に更新されました"
,
"Session"
:
"セッション"
,
"Setup guide"
:
"セットアップガイド"
,
"Setup guide complete"
:
"セットアップガイド完了"
,
"Setup guide is collapsed. Expand it anytime."
:
"セットアップガイドは折りたたまれています。いつでも展開できます。"
,
...
...
web/default/src/i18n/locales/ru.json
View file @
1ac0f580
...
...
@@ -436,6 +436,7 @@
"auth.resetPasswordConfirm.retry"
:
"Повторить ({{seconds}}с)"
,
"auth.resetPasswordConfirm.success"
:
"Ваш пароль успешно сброшен"
,
"Authentication"
:
"Аутентификация"
,
"Authentication Method"
:
"Метод аутентификации"
,
"Authenticator code"
:
"Код аутентификатора"
,
"Authorization Endpoint"
:
"Конечная точка авторизации"
,
"Authorization Endpoint (Optional)"
:
"Конечная точка авторизации (необязательно)"
,
...
...
@@ -3686,6 +3687,7 @@
"Settings"
:
"Настройки"
,
"Settings & Preferences"
:
"Настройки и предпочтения"
,
"Settings updated successfully"
:
"Настройки успешно обновлены"
,
"Session"
:
"Сессия"
,
"Setup guide"
:
"Руководство по настройке"
,
"Setup guide complete"
:
"Руководство по настройке завершено"
,
"Setup guide is collapsed. Expand it anytime."
:
"Руководство по настройке свернуто. Его можно открыть в любой момент."
,
...
...
web/default/src/i18n/locales/vi.json
View file @
1ac0f580
...
...
@@ -436,6 +436,7 @@
"auth.resetPasswordConfirm.retry"
:
"Thử lại ({{seconds}} giây)"
,
"auth.resetPasswordConfirm.success"
:
"Mật khẩu của bạn đã được đặt lại thành công"
,
"Authentication"
:
"Xác thực"
,
"Authentication Method"
:
"Phương thức xác thực"
,
"Authenticator code"
:
"Mã xác thực"
,
"Authorization Endpoint"
:
"Điểm cuối ủy quyền"
,
"Authorization Endpoint (Optional)"
:
"Điểm cuối ủy quyền (Tùy chọn)"
,
...
...
@@ -3686,6 +3687,7 @@
"Settings"
:
"Cài đặt"
,
"Settings & Preferences"
:
"Cài đặt & Tùy chọn"
,
"Settings updated successfully"
:
"Cài đặt đã được cập nhật thành công"
,
"Session"
:
"Phiên"
,
"Setup guide"
:
"Hướng dẫn thiết lập"
,
"Setup guide complete"
:
"Đã hoàn tất hướng dẫn thiết lập"
,
"Setup guide is collapsed. Expand it anytime."
:
"Hướng dẫn thiết lập đã được thu gọn. Bạn có thể mở lại bất cứ lúc nào."
,
...
...
web/default/src/i18n/locales/zh.json
View file @
1ac0f580
...
...
@@ -436,6 +436,7 @@
"auth.resetPasswordConfirm.retry"
:
"重试 ({{seconds}}s)"
,
"auth.resetPasswordConfirm.success"
:
"您的密码已成功重置"
,
"Authentication"
:
"身份验证"
,
"Authentication Method"
:
"认证方式"
,
"Authenticator code"
:
"身份验证器代码"
,
"Authorization Endpoint"
:
"授权端点"
,
"Authorization Endpoint (Optional)"
:
"授权端点(可选)"
,
...
...
@@ -3686,6 +3687,7 @@
"Settings"
:
"设置"
,
"Settings & Preferences"
:
"设置与偏好"
,
"Settings updated successfully"
:
"设置更新成功"
,
"Session"
:
"会话"
,
"Setup guide"
:
"设置引导"
,
"Setup guide complete"
:
"设置引导已完成"
,
"Setup guide is collapsed. Expand it anytime."
:
"设置引导已收起,可随时展开。"
,
...
...
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