Skip to content

Commit 2bc07c9

Browse files
authored
pref: Improve Swagger authentication (#7298)
1 parent 3d84a55 commit 2bc07c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3168
-14
lines changed

backend/app/api/v1/app.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// @Param request body request.AppSearch true "request"
1616
// @Success 200
1717
// @Security ApiKeyAuth
18+
// @Security Timestamp
1819
// @Router /apps/search [post]
1920
func (b *BaseApi) SearchApp(c *gin.Context) {
2021
var req request.AppSearch
@@ -33,6 +34,7 @@ func (b *BaseApi) SearchApp(c *gin.Context) {
3334
// @Summary Sync app list
3435
// @Success 200
3536
// @Security ApiKeyAuth
37+
// @Security Timestamp
3638
// @Router /apps/sync [post]
3739
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
3840
func (b *BaseApi) SyncApp(c *gin.Context) {
@@ -65,6 +67,7 @@ func (b *BaseApi) SyncApp(c *gin.Context) {
6567
// @Param key path string true "app key"
6668
// @Success 200 {object} response.AppDTO
6769
// @Security ApiKeyAuth
70+
// @Security Timestamp
6871
// @Router /apps/:key [get]
6972
func (b *BaseApi) GetApp(c *gin.Context) {
7073
appKey, err := helper.GetStrParamByKey(c, "key")
@@ -88,6 +91,7 @@ func (b *BaseApi) GetApp(c *gin.Context) {
8891
// @Param version path string true "app type"
8992
// @Success 200 {object} response.AppDetailDTO
9093
// @Security ApiKeyAuth
94+
// @Security Timestamp
9195
// @Router /apps/detail/:appId/:version/:type [get]
9296
func (b *BaseApi) GetAppDetail(c *gin.Context) {
9397
appID, err := helper.GetIntParamByKey(c, "appId")
@@ -111,6 +115,7 @@ func (b *BaseApi) GetAppDetail(c *gin.Context) {
111115
// @Param appId path integer true "id"
112116
// @Success 200 {object} response.AppDetailDTO
113117
// @Security ApiKeyAuth
118+
// @Security Timestamp
114119
// @Router /apps/details/:id [get]
115120
func (b *BaseApi) GetAppDetailByID(c *gin.Context) {
116121
appDetailID, err := helper.GetIntParamByKey(c, "id")
@@ -131,6 +136,7 @@ func (b *BaseApi) GetAppDetailByID(c *gin.Context) {
131136
// @Accept json
132137
// @Success 200 {object} response.IgnoredApp
133138
// @Security ApiKeyAuth
139+
// @Security Timestamp
134140
// @Router /apps/ignored [get]
135141
func (b *BaseApi) GetIgnoredApp(c *gin.Context) {
136142
res, err := appService.GetIgnoredApp()
@@ -147,6 +153,7 @@ func (b *BaseApi) GetIgnoredApp(c *gin.Context) {
147153
// @Param request body request.AppInstallCreate true "request"
148154
// @Success 200 {object} model.AppInstall
149155
// @Security ApiKeyAuth
156+
// @Security Timestamp
150157
// @Router /apps/install [post]
151158
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"安装应用 [name]","formatEN":"Install app [name]"}
152159
func (b *BaseApi) InstallApp(c *gin.Context) {
@@ -178,6 +185,7 @@ func (b *BaseApi) GetAppTags(c *gin.Context) {
178185
// @Summary Get app list update
179186
// @Success 200
180187
// @Security ApiKeyAuth
188+
// @Security Timestamp
181189
// @Router /apps/checkupdate [get]
182190
func (b *BaseApi) GetAppListUpdate(c *gin.Context) {
183191
res, err := appService.GetAppUpdate()

backend/app/api/v1/app_install.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// @Param request body request.AppInstalledSearch true "request"
1616
// @Success 200
1717
// @Security ApiKeyAuth
18+
// @Security Timestamp
1819
// @Router /apps/installed/search [post]
1920
func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
2021
var req request.AppInstalledSearch
@@ -46,6 +47,7 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
4647
// @Accept json
4748
// @Success 200 array dto.AppInstallInfo
4849
// @Security ApiKeyAuth
50+
// @Security Timestamp
4951
// @Router /apps/installed/list [get]
5052
func (b *BaseApi) ListAppInstalled(c *gin.Context) {
5153
list, err := appInstallService.GetInstallList()
@@ -62,6 +64,7 @@ func (b *BaseApi) ListAppInstalled(c *gin.Context) {
6264
// @Param request body request.AppInstalledInfo true "request"
6365
// @Success 200 {object} response.AppInstalledCheck
6466
// @Security ApiKeyAuth
67+
// @Security Timestamp
6568
// @Router /apps/installed/check [post]
6669
func (b *BaseApi) CheckAppInstalled(c *gin.Context) {
6770
var req request.AppInstalledInfo
@@ -82,6 +85,7 @@ func (b *BaseApi) CheckAppInstalled(c *gin.Context) {
8285
// @Param request body dto.OperationWithNameAndType true "request"
8386
// @Success 200 {integer} port
8487
// @Security ApiKeyAuth
88+
// @Security Timestamp
8589
// @Router /apps/installed/loadport [post]
8690
func (b *BaseApi) LoadPort(c *gin.Context) {
8791
var req dto.OperationWithNameAndType
@@ -102,6 +106,7 @@ func (b *BaseApi) LoadPort(c *gin.Context) {
102106
// @Param request body dto.OperationWithNameAndType true "request"
103107
// @Success 200 {string} response.DatabaseConn
104108
// @Security ApiKeyAuth
109+
// @Security Timestamp
105110
// @Router /apps/installed/conninfo/:key [get]
106111
func (b *BaseApi) LoadConnInfo(c *gin.Context) {
107112
var req dto.OperationWithNameAndType
@@ -122,6 +127,7 @@ func (b *BaseApi) LoadConnInfo(c *gin.Context) {
122127
// @Param appInstallId path integer true "App install id"
123128
// @Success 200 {array} dto.AppResource
124129
// @Security ApiKeyAuth
130+
// @Security Timestamp
125131
// @Router /apps/installed/delete/check/:appInstallId [get]
126132
func (b *BaseApi) DeleteCheck(c *gin.Context) {
127133
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
@@ -142,6 +148,7 @@ func (b *BaseApi) DeleteCheck(c *gin.Context) {
142148
// @Summary Sync app installed
143149
// @Success 200
144150
// @Security ApiKeyAuth
151+
// @Security Timestamp
145152
// @Router /apps/installed/sync [post]
146153
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步已安装应用列表","formatEN":"Sync the list of installed apps"}
147154
func (b *BaseApi) SyncInstalled(c *gin.Context) {
@@ -158,6 +165,7 @@ func (b *BaseApi) SyncInstalled(c *gin.Context) {
158165
// @Param request body request.AppInstalledOperate true "request"
159166
// @Success 200
160167
// @Security ApiKeyAuth
168+
// @Security Timestamp
161169
// @Router /apps/installed/op [post]
162170
// @x-panel-log {"bodyKeys":["installId","operate"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"installId","isList":false,"db":"app_installs","output_column":"app_id","output_value":"appId"},{"input_column":"id","input_value":"installId","isList":false,"db":"app_installs","output_column":"name","output_value":"appName"},{"input_column":"id","input_value":"appId","isList":false,"db":"apps","output_column":"key","output_value":"appKey"}],"formatZH":"[operate] 应用 [appKey][appName]","formatEN":"[operate] App [appKey][appName]"}
163171
func (b *BaseApi) OperateInstalled(c *gin.Context) {
@@ -178,6 +186,7 @@ func (b *BaseApi) OperateInstalled(c *gin.Context) {
178186
// @Param key path string true "request"
179187
// @Success 200 {array} response.AppService
180188
// @Security ApiKeyAuth
189+
// @Security Timestamp
181190
// @Router /apps/services/:key [get]
182191
func (b *BaseApi) GetServices(c *gin.Context) {
183192
key := c.Param("key")
@@ -195,6 +204,7 @@ func (b *BaseApi) GetServices(c *gin.Context) {
195204
// @Param appInstallId path integer true "request"
196205
// @Success 200 {array} dto.AppVersion
197206
// @Security ApiKeyAuth
207+
// @Security Timestamp
198208
// @Router /apps/installed/update/versions [post]
199209
func (b *BaseApi) GetUpdateVersions(c *gin.Context) {
200210
var req request.AppUpdateVersion
@@ -215,6 +225,7 @@ func (b *BaseApi) GetUpdateVersions(c *gin.Context) {
215225
// @Param request body request.PortUpdate true "request"
216226
// @Success 200
217227
// @Security ApiKeyAuth
228+
// @Security Timestamp
218229
// @Router /apps/installed/port/change [post]
219230
// @x-panel-log {"bodyKeys":["key","name","port"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用端口修改 [key]-[name] => [port]","formatEN":"Application port update [key]-[name] => [port]"}
220231
func (b *BaseApi) ChangeAppPort(c *gin.Context) {
@@ -235,6 +246,7 @@ func (b *BaseApi) ChangeAppPort(c *gin.Context) {
235246
// @Param request body dto.OperationWithNameAndType true "request"
236247
// @Success 200 {string} content
237248
// @Security ApiKeyAuth
249+
// @Security Timestamp
238250
// @Router /apps/installed/conf [post]
239251
func (b *BaseApi) GetDefaultConfig(c *gin.Context) {
240252
var req dto.OperationWithNameAndType
@@ -256,6 +268,7 @@ func (b *BaseApi) GetDefaultConfig(c *gin.Context) {
256268
// @Param appInstallId path string true "request"
257269
// @Success 200 {object} response.AppParam
258270
// @Security ApiKeyAuth
271+
// @Security Timestamp
259272
// @Router /apps/installed/params/:appInstallId [get]
260273
func (b *BaseApi) GetParams(c *gin.Context) {
261274
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
@@ -277,6 +290,7 @@ func (b *BaseApi) GetParams(c *gin.Context) {
277290
// @Param request body request.AppInstalledUpdate true "request"
278291
// @Success 200
279292
// @Security ApiKeyAuth
293+
// @Security Timestamp
280294
// @Router /apps/installed/params/update [post]
281295
// @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用参数修改 [installId]","formatEN":"Application param update [installId]"}
282296
func (b *BaseApi) UpdateInstalled(c *gin.Context) {
@@ -297,6 +311,7 @@ func (b *BaseApi) UpdateInstalled(c *gin.Context) {
297311
// @Param request body request.AppInstalledIgnoreUpgrade true "request"
298312
// @Success 200
299313
// @Security ApiKeyAuth
314+
// @Security Timestamp
300315
// @Router /apps/installed/ignore [post]
301316
// @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"忽略应用 [installId] 版本升级","formatEN":"Application param update [installId]"}
302317
func (b *BaseApi) IgnoreUpgrade(c *gin.Context) {

backend/app/api/v1/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func (b *BaseApi) MFALogin(c *gin.Context) {
8787
// @Summary User logout
8888
// @Success 200
8989
// @Security ApiKeyAuth
90+
// @Security Timestamp
9091
// @Router /auth/logout [post]
9192
func (b *BaseApi) LogOut(c *gin.Context) {
9293
if err := authService.LogOut(c); err != nil {

backend/app/api/v1/backup.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
// @Param request body dto.BackupOperate true "request"
1818
// @Success 200
1919
// @Security ApiKeyAuth
20+
// @Security Timestamp
2021
// @Router /settings/backup [post]
2122
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建备份账号 [type]","formatEN":"create backup account [type]"}
2223
func (b *BaseApi) CreateBackup(c *gin.Context) {
@@ -52,6 +53,7 @@ func (b *BaseApi) CreateBackup(c *gin.Context) {
5253
// @Summary Refresh OneDrive token
5354
// @Success 200
5455
// @Security ApiKeyAuth
56+
// @Security Timestamp
5557
// @Router /settings/backup/refresh/onedrive [post]
5658
func (b *BaseApi) RefreshOneDriveToken(c *gin.Context) {
5759
backupService.Run()
@@ -64,6 +66,7 @@ func (b *BaseApi) RefreshOneDriveToken(c *gin.Context) {
6466
// @Param request body dto.ForBuckets true "request"
6567
// @Success 200 {array} string
6668
// @Security ApiKeyAuth
69+
// @Security Timestamp
6770
// @Router /settings/backup/search [post]
6871
func (b *BaseApi) ListBuckets(c *gin.Context) {
6972
var req dto.ForBuckets
@@ -100,6 +103,7 @@ func (b *BaseApi) ListBuckets(c *gin.Context) {
100103
// @Accept json
101104
// @Success 200 {object} dto.OneDriveInfo
102105
// @Security ApiKeyAuth
106+
// @Security Timestamp
103107
// @Router /settings/backup/onedrive [get]
104108
func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) {
105109
data, err := backupService.LoadOneDriveInfo()
@@ -116,6 +120,7 @@ func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) {
116120
// @Param request body dto.OperateByID true "request"
117121
// @Success 200
118122
// @Security ApiKeyAuth
123+
// @Security Timestamp
119124
// @Router /settings/backup/del [post]
120125
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"backup_accounts","output_column":"type","output_value":"types"}],"formatZH":"删除备份账号 [types]","formatEN":"delete backup account [types]"}
121126
func (b *BaseApi) DeleteBackup(c *gin.Context) {
@@ -137,6 +142,7 @@ func (b *BaseApi) DeleteBackup(c *gin.Context) {
137142
// @Param request body dto.RecordSearch true "request"
138143
// @Success 200
139144
// @Security ApiKeyAuth
145+
// @Security Timestamp
140146
// @Router /settings/backup/record/search [post]
141147
func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
142148
var req dto.RecordSearch
@@ -162,6 +168,7 @@ func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
162168
// @Param request body dto.RecordSearchByCronjob true "request"
163169
// @Success 200
164170
// @Security ApiKeyAuth
171+
// @Security Timestamp
165172
// @Router /settings/backup/record/search/bycronjob [post]
166173
func (b *BaseApi) SearchBackupRecordsByCronjob(c *gin.Context) {
167174
var req dto.RecordSearchByCronjob
@@ -187,6 +194,7 @@ func (b *BaseApi) SearchBackupRecordsByCronjob(c *gin.Context) {
187194
// @Param request body dto.DownloadRecord true "request"
188195
// @Success 200
189196
// @Security ApiKeyAuth
197+
// @Security Timestamp
190198
// @Router /settings/backup/record/download [post]
191199
// @x-panel-log {"bodyKeys":["source","fileName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载备份记录 [source][fileName]","formatEN":"download backup records [source][fileName]"}
192200
func (b *BaseApi) DownloadRecord(c *gin.Context) {
@@ -209,6 +217,7 @@ func (b *BaseApi) DownloadRecord(c *gin.Context) {
209217
// @Param request body dto.BatchDeleteReq true "request"
210218
// @Success 200
211219
// @Security ApiKeyAuth
220+
// @Security Timestamp
212221
// @Router /settings/backup/record/del [post]
213222
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"backup_records","output_column":"file_name","output_value":"files"}],"formatZH":"删除备份记录 [files]","formatEN":"delete backup records [files]"}
214223
func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
@@ -230,6 +239,7 @@ func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
230239
// @Param request body dto.BackupOperate true "request"
231240
// @Success 200
232241
// @Security ApiKeyAuth
242+
// @Security Timestamp
233243
// @Router /settings/backup/update [post]
234244
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新备份账号 [types]","formatEN":"update backup account [types]"}
235245
func (b *BaseApi) UpdateBackup(c *gin.Context) {
@@ -266,6 +276,7 @@ func (b *BaseApi) UpdateBackup(c *gin.Context) {
266276
// @Summary List backup accounts
267277
// @Success 200 {array} dto.BackupInfo
268278
// @Security ApiKeyAuth
279+
// @Security Timestamp
269280
// @Router /settings/backup/search [get]
270281
func (b *BaseApi) ListBackup(c *gin.Context) {
271282
data, err := backupService.List()
@@ -283,6 +294,7 @@ func (b *BaseApi) ListBackup(c *gin.Context) {
283294
// @Param request body dto.BackupSearchFile true "request"
284295
// @Success 200 {array} string
285296
// @Security ApiKeyAuth
297+
// @Security Timestamp
286298
// @Router /settings/backup/search/files [post]
287299
func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
288300
var req dto.BackupSearchFile
@@ -300,6 +312,7 @@ func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
300312
// @Param request body dto.CommonBackup true "request"
301313
// @Success 200
302314
// @Security ApiKeyAuth
315+
// @Security Timestamp
303316
// @Router /settings/backup/backup [post]
304317
// @x-panel-log {"bodyKeys":["type","name","detailName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"备份 [type] 数据 [name][detailName]","formatEN":"backup [type] data [name][detailName]"}
305318
func (b *BaseApi) Backup(c *gin.Context) {
@@ -344,6 +357,7 @@ func (b *BaseApi) Backup(c *gin.Context) {
344357
// @Param request body dto.CommonRecover true "request"
345358
// @Success 200
346359
// @Security ApiKeyAuth
360+
// @Security Timestamp
347361
// @Router /settings/backup/recover [post]
348362
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
349363
func (b *BaseApi) Recover(c *gin.Context) {
@@ -394,6 +408,7 @@ func (b *BaseApi) Recover(c *gin.Context) {
394408
// @Param request body dto.CommonRecover true "request"
395409
// @Success 200
396410
// @Security ApiKeyAuth
411+
// @Security Timestamp
397412
// @Router /settings/backup/recover/byupload [post]
398413
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
399414
func (b *BaseApi) RecoverByUpload(c *gin.Context) {

0 commit comments

Comments
 (0)