feat: Add audit logging (#38189)

Co-authored-by: bircni <bircni@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
bircni
2026-09-12 10:15:23 +02:00
committed by GitHub
parent 4d43445532
commit da37b7916b
136 changed files with 3864 additions and 209 deletions
+21
View File
@@ -0,0 +1,21 @@
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package auth
import (
"strconv"
"gitea.dev/modules/web/middleware"
)
// Credential kinds naming how a request authenticated, recorded so an audit
// event can point at the token rather than only at its owner.
const (
credentialAccessToken = "access-token"
credentialOAuth2Grant = "oauth2-grant"
)
func setAuthCredential(store DataStore, kind string, id int64) {
store.GetData()[middleware.ContextDataKeyAuthCredential] = kind + ":" + strconv.FormatInt(id, 10)
}