aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/admin.go
Commit message (Collapse)AuthorAgeFilesLines
* Move login related structs and functions to models/login (#17093)Lunny Xiao2021-09-241-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move login related structs and functions to models/login * Fix test * Fix lint * Fix lint * Fix lint of windows * Fix lint * Fix test * Fix test * Only load necessary fixtures when preparing unit tests envs * Fix lint * Fix test * Fix test * Fix error log * Fix error log * Fix error log * remove unnecessary change * fix error log * merge main branch
* Add setting to OAuth handlers to skip local 2FA authentication (#16594)zeripath2021-09-101-0/+5
| | | | | | | | This PR adds a setting to OAuth and OpenID login sources to allow the source to skip local 2FA authentication. Fix #13939 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Refactor: Move login out of models (#16199)zeripath2021-07-241-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `models` does far too much. In particular it handles all `UserSignin`. It shouldn't be responsible for calling LDAP, SMTP or PAM for signing in. Therefore we should move this code out of `models`. This code has to depend on `models` - therefore it belongs in `services`. There is a package in `services` called `auth` and clearly this functionality belongs in there. Plan: - [x] Change `auth.Auth` to `auth.Method` - as they represent methods of authentication. - [x] Move `models.UserSignIn` into `auth` - [x] Move `models.ExternalUserLogin` - [x] Move most of the `LoginVia*` methods to `auth` or subpackages - [x] Move Resynchronize functionality to `auth` - Involved some restructuring of `models/ssh_key.go` to reduce the size of this massive file and simplify its files. - [x] Move the rest of the LDAP functionality in to the ldap subpackage - [x] Re-factor the login sources to express an interfaces `auth.Source`? - I've done this through some smaller interfaces Authenticator and Synchronizable - which would allow us to extend things in future - [x] Now LDAP is out of models - need to think about modules/auth/ldap and I think all of that functionality might just be moveable - [x] Similarly a lot Oauth2 functionality need not be in models too and should be moved to services/auth/source/oauth2 - [x] modules/auth/oauth2/oauth2.go uses xorm... This is naughty - probably need to move this into models. - [x] models/oauth2.go - mostly should be in modules/auth/oauth2 or services/auth/source/oauth2 - [x] More simplifications of login_source.go may need to be done - Allow wiring in of notify registration - *this can now easily be done - but I think we should do it in another PR* - see #16178 - More refactors...? - OpenID should probably become an auth Method but I think that can be left for another PR - Methods should also probably be cleaned up - again another PR I think. - SSPI still needs more refactors.* Rename auth.Auth auth.Method * Restructure ssh_key.go - move functions from models/user.go that relate to ssh_key to ssh_key - split ssh_key.go to try create clearer function domains for allow for future refactors here. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix missing storage init (#15589)Lunny Xiao2021-04-221-0/+5
|
* Code Formats, Nits & Unused Func/Var deletions (#15286)65432021-04-091-3/+3
| | | | | | | | | | | | | | | * _ to unused func options * rm useless brakets * rm trifial non used models functions * rm dead code * rm dead global vars * fix routers/api/v1/repo/issue.go * dont overload import module
* [Refactor] Passwort Hash/Set (#14282)65432021-01-101-3/+2
| | | | | | | | | * move SaltGeneration into HashPasswort and rename it to what it does * Migration: Where Password is Valid with Empty String delete it * prohibit empty password hash * let SetPassword("") unset pwd stuff
* CLI support for OAuth sources custom icons (#14166)Daniil Pankratov2020-12-281-0/+10
| | | Co-authored-by: Daniil Pankratov <daniil.pankratov@t-systems.com>
* fix label of --id in admin delete user (#14005)zeripath2020-12-171-6/+35
| | | | | | | | | | | | | | | | | | | | | * fix label of --id in admin delete user This pr fixes the label descriptor of `gitea admin delete user` but also adds a `--username` option. Fix #13995 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix-spacing Signed-off-by: Andrew Thornton <art27@cantab.net> * Add delete email support Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Whenever the password is updated ensure that the hash algorithm is too (#13966)zeripath2020-12-121-1/+1
| | | | | | | | | | | `user.HashPassword` may potentially - and in fact now likely does - change the `passwd_hash_algo` therefore whenever the `passwd` is updated, this also needs to be updated. Fix #13832 Thanks @fblaese for the hint Signed-off-by: Andrew Thornton <art27@cantab.net>
* Sendmail command (#13079)Maxim Zhiburt2020-10-241-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add SendSync method Usefull to have when you need to be confident that message was sent. * Add sendmail command * add checks that if either title or content is empty then error out * Add a confirmation step * Add --force option to bypass confirm step * Move implementation of runSendMail to a different file * Add copyrighting comment * Make content optional Print waring if it's empty or haven't been set up. The warning will be skiped if there's a `--force` flag. * Fix import style Co-authored-by: 6543 <6543@obermui.de> * Use batch when getting all users IterateUsers uses batching by default. Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Send emails one by one instead of as one chunck Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Send messages concurantly Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Use SendAsync+Flush instead of SendSync Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Add timeout parameter to sendemail command Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Fix spelling mistake Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * Update cmd/admin.go Co-authored-by: 6543 <6543@obermui.de> * Connect to a running Gitea instance * Fix mispelling * Add copyright comment Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Improve users management through the CLI (#6001) (#10492)ydelafollye2020-10-151-5/+84
| | | | | | | | | | * Fix images in wiki edit preview (#11546) Make sure wiki editor sets wiki to true so gitea renders it as a wiki page. Also change the context data attr for edit form. This looks wrong but everywhere else in our code assumes the urlPrefix to be just the repo url when rendering and manually adds /wiki to the rendered url regardless. Fixes #11540
* Check passwords against HaveIBeenPwned (#12716)John Olheiser2020-09-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement pwn Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update module Signed-off-by: jolheiser <john.olheiser@gmail.com> * Apply suggestions mrsdizzie Co-authored-by: mrsdizzie <info@mrsdizzie.com> * Add link to HIBP Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add more details to admin command Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add context to pwn Signed-off-by: jolheiser <john.olheiser@gmail.com> * Consistency and making some noise ;) Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: mrsdizzie <info@mrsdizzie.com> Co-authored-by: zeripath <art27@cantab.net>
* make `gitea admin auth list` formatting configurable (#10844)zeripath2020-03-271-1/+37
| | | | | | | | | * make admin auth list formatting configurable Signed-off-by: Andrew Thornton <art27@cantab.net> * As per @guillep2k Signed-off-by: Andrew Thornton <art27@cantab.net>
* API add/generalize pagination (#9452)SpaWn2KiLl2020-01-241-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * paginate results * fixed deadlock * prevented breaking change * updated swagger * go fmt * fixed find topic * go mod tidy * go mod vendor with go1.13.5 * fixed repo find topics * fixed unit test * added Limit method to Engine struct; use engine variable when provided; fixed gitignore * use ItemsPerPage for default pagesize; fix GetWatchers, getOrgUsersByOrgID and GetStargazers; fix GetAllCommits headers; reverted some changed behaviors * set Page value on Home route * improved memory allocations * fixed response headers * removed logfiles * fixed import order * import order * improved swagger * added function to get models.ListOptions from context * removed pagesize diff on unit test * fixed imports * removed unnecessary struct field * fixed go fmt * scoped PR * code improvements * code improvements * go mod tidy * fixed import order * fixed commit statuses session * fixed files headers * fixed headers; added pagination for notifications * go mod tidy * go fmt * removed Private from user search options; added setting.UI.IssuePagingNum as default valeu on repo's issues list * Apply suggestions from code review Co-Authored-By: 6543 <6543@obermui.de> Co-Authored-By: zeripath <art27@cantab.net> * fixed build error * CI.restart() * fixed merge conflicts resolve * fixed conflicts resolve * improved FindTrackedTimesOptions.ToOptions() method * added backwards compatibility on ListReleases request; fixed issue tracked time ToSession * fixed build error; fixed swagger template * fixed swagger template * fixed ListReleases backwards compatibility * added page to user search route Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* Refactor repository check and sync functions (#9854)Lunny Xiao2020-01-201-3/+4
| | | Move more general repository functions out of models/repo.go
* Fix #9530: admin auth list make readable and admin auth delete bug fix (#9628)Shashvat Kedia2020-01-071-2/+3
|
* Move some repository methods from models to modules/repository (#9353)Lunny Xiao2019-12-141-1/+2
| | | | | | * Move some repository methods from models to modules/repository * fix test
* Add Close() method to gogitRepository (#8901)zeripath2019-11-131-0/+3
| | | | | | | | | In investigating #7947 it has become clear that the storage component of go-git repositories needs closing. This PR adds this Close function and adds the Close functions as necessary. In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files. Fixes #7947
* Adjust the must-change-password help (#8755)zeripath2019-10-301-1/+1
|
* Password Complexity Checks (#6230)Maxim Tkachenko2019-10-141-9/+10
| | | | | | | | | Add password complexity checks. The default settings require a lowercase, uppercase, number and a special character within passwords. Co-Authored-By: T-M-A <maxim.tkachenko@gmail.com> Co-Authored-By: Lanre Adelowo <adelowomailbox@gmail.com> Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-Authored-By: Lauris BH <lauris@nix.lv>
* Add CLI commands to manage LDAP authentication source (#6681)ngourdon2019-06-171-1/+5
| | | | | | | | | | | | | | | | | | * add CLI commands to manage LDAP authentication source * delete Gogs copyright * remove unused return value of func parseLoginSource * fix comment Co-Authored-By: ngourdon <31291059+ngourdon@users.noreply.github.com> * remove config flag already present in global flags * remove config flag from ldap commands in docs * remove config flag handling
* Add golangci (#6418)kolaente2019-06-121-1/+1
|
* Generate access token in admin cli (#6847)Lanre Adelowo2019-05-041-2/+21
| | | | * add cli flag for access token while creating a user
* Make CustomPath, CustomConf and AppWorkPath configurable at build (#6631)zeripath2019-04-291-76/+0
|
* Add username flag in create-user command (#6534)ngourdon2019-04-091-3/+22
| | | | | | | | | | | | * Add username flag in create-user command * Fix the error message * Change name to username on flag of create-user command * Include create-user flags of both versions * delete deprecated example of create-user command
* move code.gitea.io/git to code.gitea.io/gitea/modules/git (#6364)Lunny Xiao2019-03-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * move code.gitea.io/git to code.gitea.io/gitea/modules/git * fix imports * fix fmt * fix misspell * remove wrong tests data * fix unit tests * fix tests * fix tests * fix tests * fix tests * fix tests * enable Debug to trace the failure tests * fix tests * fix tests * fix tests * fix tests * fix tests * comment commit count tests since git clone depth is 50 * fix tests * update from code.gitea.io/git * revert change to makefile
* Allow for user specific themes (#5668)Lanre Adelowo2019-01-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * add migration and basic UI for changing a user's theme * update user themem * use right text on button * load theme based on users' selection * load theme based on users' selection in pwa too * update sample config * delete older theme loading * implement AfterLoad to set users' theme properly * set up default theme when creating a user. This uses the installation wide theme * use flash messages for error * set default theme when creating a user from the cli * fix @lunny review
* fix password variable shadowing (#5405)Lanre Adelowo2018-11-261-1/+2
|
* Don't force a password change for the admin user when creating an account ↵Lanre Adelowo2018-11-251-0/+6
| | | | | | | | via cli (#5391) * don't force a password change for the admin user * don't totally dicard -must-change-password flag if creating the first (admin) user via the cli. Use flag if present but make sure to default to not forcing a password update
* Generate random password (#5023)Lanre Adelowo2018-10-301-2/+32
| | | | | | | | * add random-password flag * run make fmt * add length cli flag rather than use a default value
* Add must-change-password flag to cli for creating a user (#4955)Lanre Adelowo2018-10-211-5/+17
| | | | | | | | | | * add support for an admin to force a user to change his/her password from thee cli * use BoolFlag instead * default to true * simplify by removing unnneccessary if/else
* refactor: err != nil check, just return error instead (#5093)Bo-Yi Wu2018-10-181-15/+4
|
* Add/remove/list oauth providers via cli (#4591)techknowlogick2018-09-121-0/+286
|
* Add config path as an optional flag when changing pass via CLI (#4184)Fluf2018-06-091-0/+9
|
* Add cli commands to regen hooks & keys (#3979)techknowlogick2018-05-171-0/+58
| | | | | | | | | | * Add cli commands to regen hooks & keys * make fmt * Allow passing path to config as an option * add docs
* General refactor of the cmd package (#3328)Morgan Bazalgette2018-01-121-51/+27
| | | | | | | | * General refactor of the cmd package * Address breakage in runCreateUser * Place "common" functions into cmd.go
* Cleanup models.User.HashPassword (#3334)Kim "BKC" Carlbäcker2018-01-121-2/+1
|
* Change EncodePasswd to HashPassword (#3329)Morgan Bazalgette2018-01-081-1/+1
| | | | | | * Change EncodePasswd to HashPassword * Create test+benchmark for HashPassword
* Add repo-sync-releases admin command (#3254)Sandro Santilli2017-12-311-0/+75
| | | | | | | | | | | | | | | | | | * Add repo-sync-releases admin command Will help recovering corrupted database, see #3247 * Load repos in chunks of 10, exit with error if unable to get a list, scan private repos, fix typo * Fix debug output about num releases * Introduce RepositoryListDefaultPageSize constant, set to 64 Use it from the new admin command * Use RepositoryListDefaultPageSize in more places * Document RepositoryListDefaultPageSize
* Only update needed columns when update user (#2296)Lunny Xiao2017-08-121-1/+1
| | | | | | * only update needed columns when update user * fix missing update_unix column
* refactor: show command help message. (#1486)Bo-Yi Wu2017-04-121-2/+2
|
* Add change-password admin command (#1304)Sandro Santilli2017-03-201-0/+52
| | | * Add change-password admin command
* Fix typo (#990)Christoph König2017-02-211-1/+1
|
* Make Xorm log configurable (#174)Lunny Xiao2017-02-201-0/+2
| | | | | | | | | | * make xorm log configable * bug fixed for other sub commands except web * rebase and fix xorm log * bug fix for TrimSpace
* Handle SetModel error, fixes one errcheck report (#257)Sandro Santilli2017-02-121-1/+3
|
* Remove remaining Gogs reference on locales and cmd (#430)Joubert RedRat2016-12-211-1/+2
|
* Update import paths from github.com/go-gitea to code.gitea.io (#135)Sandro Santilli2016-11-101-2/+2
| | | | | | | - Update import paths from github.com/go-gitea to code.gitea.io - Fix import path for travis See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
* Improve formatting of admin commandMatthias Loibl2016-11-091-2/+4
| | | | Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>
* Use cli Flags directly and not some helper funcsMatthias Loibl2016-11-091-5/+22
| | | | Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>
* Made linter happy in cmd folderThomas Boerger2016-11-041-0/+1
|