feat: UI for the pull request trust management panel

See the documentation pull request for a description

https://codeberg.org/forgejo/docs/pulls/1567
https://forgejo.codeberg.page/@docs_pull_1567/docs/next/user/actions/security-pull-request/
This commit is contained in:
Earl Warren 2025-10-30 16:16:59 +01:00
parent 465d057fae
commit 57f986c7b1
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
10 changed files with 559 additions and 2 deletions

View file

@ -111,6 +111,19 @@ func RequireRepoReaderOr(unitTypes ...unit.Type) func(ctx *Context) {
}
}
func RequireRepoDelegateActionTrust() func(ctx *Context) {
return func(ctx *Context) {
if CheckRepoDelegateActionTrust(ctx) {
return
}
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
}
}
func CheckRepoDelegateActionTrust(ctx *Context) bool {
return ctx.Repo.IsAdmin() || (ctx.IsSigned && ctx.Doer.IsAdmin) || ctx.Repo.CanWrite(unit.TypeActions)
}
// CheckRepoScopedToken check whether personal access token has repo scope
func CheckRepoScopedToken(ctx *Context, repo *repo_model.Repository, level auth_model.AccessTokenScopeLevel) {
if !ctx.IsBasicAuth || ctx.Data["IsApiToken"] != true {