mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-19 15:14:40 +09:00
Adds audit actions for security-relevant changes that were not logged at all, and records a few remaining events on paths that skipped them: - Account login prohibition (`user:status:prohibitlogin`) and the organization setting that lets repository admins change team access - Actions runner registration tokens issued, runners removed or enabled/disabled, and Actions variables, for every scope - Instance config changes, including maintenance mode (`system:config:update`) - Deploy token regeneration and pull mirror address changes - Review deletion and dismissal, package removal, and release and tag removal - Repository restores via `gitea admin restore-repo`, OAuth2 secret rotation on API update, and SSH keys added or removed by authentication source sync The authentication source SSH key sync moved from the asymkey model to the asymkey service so it can record events. Follow-up to https://github.com/go-gitea/gitea/pull/40317 and https://github.com/go-gitea/gitea/pull/40322. --------- Co-authored-by: silverwind <me@silverwind.io>
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
user_model "gitea.dev/models/user"
|
|
"gitea.dev/modules/util"
|
|
"gitea.dev/services/audit"
|
|
|
|
"github.com/urfave/cli/v3"
|
|
)
|
|
|
|
// parseUserTypeFlag parses "--user-type", keeping the lowercase "individual" and "bot" the flag shipped with
|
|
func parseUserTypeFlag(s string) (user_model.UserType, error) {
|
|
switch strings.ToLower(s) {
|
|
case "user", "individual":
|
|
return user_model.UserTypeIndividual, nil
|
|
case "bot":
|
|
return user_model.UserTypeBot, nil
|
|
default:
|
|
return 0, util.NewInvalidArgumentErrorf("invalid user type %q (expected User, Bot)", s)
|
|
}
|
|
}
|
|
|
|
func newUserCommand() *cli.Command {
|
|
return &cli.Command{
|
|
Name: "user",
|
|
Usage: "Modify users",
|
|
Before: func(ctx context.Context, _ *cli.Command) (context.Context, error) {
|
|
return audit.WithCLIDoer(ctx), nil
|
|
},
|
|
Commands: []*cli.Command{
|
|
microcmdUserCreate(),
|
|
newUserListCommand(),
|
|
microcmdUserChangePassword(),
|
|
microcmdUserDelete(),
|
|
newUserGenerateAccessTokenCommand(),
|
|
microcmdUserMustChangePassword(),
|
|
microcmdUserDisableTwoFactor(),
|
|
microcmdUserChangeType(),
|
|
},
|
|
}
|
|
}
|