mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-19 22:14:58 +00:00
3bec08f998
Adds first-class bot accounts (`UserTypeBot`): local, password-less
users for automation that authenticate only with access tokens.
1. Admin UI: create bots, filter users by type, manage a bot's access
tokens, convert between user and bot
2. API: `POST /admin/users/{username}/convert-type`, and user objects
gain a GitHub-compatible `type` (`User`, `Organization`, `Bot`)
3. CLI: `gitea admin user change-type`, `--user-type` accepts `User` or
`Bot` case-insensitively
4. Converting keeps the password, 2FA, OAuth2 grants and access tokens,
and since sign-in rejects bots, converting back restores the account.
Only local, non-admin accounts can be converted, and conversions are
audited
5. Session, reverse proxy, SSPI, external source and password reset
sign-in reject non-individual users, so a bot never gets an interactive
session
6. Bots receive no notifications or emails
Co-authored-by: Nicolas <bircni@icloud.com>
Co-authored-by: joestump <joe@joestump.net>
Co-authored-by: Joe Stump <joe@stu.mp>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
71 lines
2.6 KiB
Go
71 lines
2.6 KiB
Go
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package forms
|
|
|
|
import (
|
|
"gitea.dev/modules/structs"
|
|
"gitea.dev/modules/web/middleware"
|
|
)
|
|
|
|
// AdminCreateUserForm form for admin to create user
|
|
type AdminCreateUserForm struct {
|
|
middleware.FormDefaultValidator
|
|
LoginType string `binding:"Required"`
|
|
LoginName string
|
|
UserName string `binding:"Required;Username;MaxSize(40)"`
|
|
UserType structs.UserTypeString `binding:"In(,User,Bot)"`
|
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
|
Password string `binding:"MaxSize(255)"`
|
|
SendNotify bool
|
|
MustChangePassword bool
|
|
Visibility structs.VisibleType
|
|
}
|
|
|
|
// AdminCreateBadgeForm form for admin to create badge
|
|
type AdminCreateBadgeForm struct {
|
|
middleware.FormDefaultValidator
|
|
Slug string `binding:"Required;BadgeSlug" locale:"admin.badges.slug"`
|
|
Description string `binding:"Required" locale:"admin.badges.description"`
|
|
ImageURL string `binding:"ValidUrl" locale:"admin.badges.image_url"`
|
|
}
|
|
|
|
// AdminEditBadgeForm form for admin to edit badge
|
|
type AdminEditBadgeForm struct {
|
|
middleware.FormDefaultValidator
|
|
Description string `binding:"Required" locale:"admin.badges.description"`
|
|
ImageURL string `binding:"ValidUrl" locale:"admin.badges.image_url"`
|
|
}
|
|
|
|
// AdminEditUserForm form for admin to create user
|
|
type AdminEditUserForm struct {
|
|
middleware.FormDefaultValidator
|
|
LoginType string `binding:"Required"`
|
|
UserType structs.UserTypeString `binding:"In(,User,Bot)"`
|
|
UserName string `binding:"Username;MaxSize(40)"`
|
|
LoginName string
|
|
FullName string `binding:"MaxSize(100)"`
|
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
|
Password string `binding:"MaxSize(255)"`
|
|
Website string `binding:"ValidUrl;MaxSize(255)"`
|
|
Location string `binding:"MaxSize(50)"`
|
|
Language string `binding:"MaxSize(5)"`
|
|
MaxRepoCreation int
|
|
Active bool
|
|
Admin bool
|
|
Restricted bool
|
|
AllowGitHook bool
|
|
AllowImportLocal bool
|
|
AllowCreateOrganization bool
|
|
ProhibitLogin bool
|
|
Reset2FA bool `form:"reset_2fa"`
|
|
Visibility structs.VisibleType
|
|
}
|
|
|
|
// AdminDashboardForm form for admin dashboard operations
|
|
type AdminDashboardForm struct {
|
|
middleware.FormDefaultValidator
|
|
Op string `binding:"required"`
|
|
From string
|
|
}
|