You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/modules
zeripath 5d2e11eedb
Refactor: Move login out of models (#16199)
`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>
3 years ago
..
analyze Speed up `enry.IsVendor` (#15213) 3 years ago
auth Refactor: Move login out of models (#16199) 3 years ago
avatar Add Image Diff for SVG files (#14867) 3 years ago
base Fixed assert statements. (#16089) 3 years ago
cache Add LRU mem cache implementation (#16226) 3 years ago
charset Refactor renders (#15175) 3 years ago
context Refactor: Move login out of models (#16199) 3 years ago
convert Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
cron Refactor: Move login out of models (#16199) 3 years ago
csv Refactor renders (#15175) 3 years ago
doctor Restore creation of git-daemon-export-ok files (#16508) 3 years ago
emoji Run processors on whole of text (#16155) 3 years ago
eventsource Hold the event source when there are no listeners (#15725) 3 years ago
generate Add asymmetric JWT signing (#16010) 3 years ago
git Make cancel from CatFileBatch and CatFileBatchCheck wait for the command to end (#16479) 3 years ago
gitgraph Fix bug on commit graph (#15517) 3 years ago
graceful Support HTTP/2 in Let's Encrypt (#16371) 3 years ago
hcaptcha hCaptcha Support (#12594) 4 years ago
highlight Replace ARCCache with TwoQueueCache to avoid patent issue (#16240) 3 years ago
httpcache Add ETag header (#15370) 3 years ago
httplib Second attempt at preventing zombies (#16326) 3 years ago
indexer Fix data race in bleve indexer (#16474) 3 years ago
lfs Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
log Fix race in log (#16490) 3 years ago
markup modules/markup/markdown: fix dropped test error (#16438) 3 years ago
matchlist Add Allow-/Block-List for Migrate & Mirrors (#13610) 4 years ago
metrics Prometheus endpoint (#5256) 6 years ago
migrations Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
nosql Fix setting redis db path (#15698) 3 years ago
notification Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
options Add StatDir and replace com.StatDir (#14099) 4 years ago
password Fixed assert statements. (#16089) 3 years ago
pprof Add golangci (#6418) 5 years ago
private Second attempt at preventing zombies (#16326) 3 years ago
process Code Formats, Nits & Unused Func/Var deletions (#15286) 3 years ago
public Improve assets handler middleware (#15961) 3 years ago
queue Fix race in log (#16490) 3 years ago
recaptcha Migrate to use jsoniter instead of encoding/json (#14841) 3 years ago
references Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
repofiles Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
repository Fix archive error when rename repo or user (#16399) 3 years ago
secret Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
session Migrate to use jsoniter instead of encoding/json (#14841) 3 years ago
setting Make Mermaid.js limit configurable (#16519) 3 years ago
ssh Second attempt at preventing zombies (#16326) 3 years ago
storage Retry rename on lock induced failures (#16435) 3 years ago
structs Add support for corporate WeChat webhooks (#15910) 3 years ago
svg Fix filepath basename on Windows for SVG bindata (#12241) 4 years ago
sync Fix missing unlock in uniquequeue (#9790) 5 years ago
task Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
templates Make Mermaid.js limit configurable (#16519) 3 years ago
test Move middlewares to web/middleware (#14480) 3 years ago
timeutil Fix display since time round (#14226) 3 years ago
translation Use index of the supported tags to choose user lang (#15452) 3 years ago
typesniffer Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
upload Update golangci-lint to version 1.31.0 (#13102) 4 years ago
uri Dump github/gitlab/gitea repository data to a local directory and restore to gitea (#12244) 4 years ago
user Add gitea-vet (#10948) 4 years ago
util Make cancel from CatFileBatch and CatFileBatchCheck wait for the command to end (#16479) 3 years ago
validation Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
web Restore CORS on git smart http protocol (#16496) 3 years ago