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/models
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
..
fixtures Add Visible modes function from Organisation to Users too (#16069) 3 years ago
migrations Refactor: Move login out of models (#16199) 3 years ago
access.go chore(models): rewrite code format. (#14754) 3 years ago
access_test.go Fix "access" fixtures and tests (#10247) 4 years ago
action.go Improve notifications for WIP draft PR's (#14663) 3 years ago
action_list.go refactor: reduce sql query in retrieveFeeds (#3547) 6 years ago
action_test.go Clarify the suffices and prefixes of setting.AppSubURL and setting.AppURL (#12999) 3 years ago
admin.go improve empty notice (#15890) 3 years ago
admin_test.go Fix tests code to prevent some runtime errors (#2381) 7 years ago
attachment.go Add size to Save function (#15264) 3 years ago
attachment_test.go Fixed assert statements. (#16089) 3 years ago
avatar.go Double the avatar size factor (#15941) 3 years ago
avatar_test.go Fix individual tests (addition to #15802) (#15818) 3 years ago
branches.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
branches_test.go Add deleted_branch table fixture (#2832) 7 years ago
commit_status.go chore(models): rewrite code format. (#14754) 3 years ago
commit_status_test.go Fix bug about ListOptions and stars/watchers pagnation (#14556) 3 years ago
consistency.go Update milestone counters on new issue. (#16183) 3 years ago
consistency_test.go Fix orphaned objects deletion bug (#15657) 3 years ago
context.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
convert.go just add some unit tests (#16291) 3 years ago
error.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
error_oauth2.go gofmt (#1662) 7 years ago
external_login_user.go chore(models): rewrite code format. (#14754) 3 years ago
fixture_generation.go chore(models): rewrite code format. (#14754) 3 years ago
fixture_test.go Move fixture generation to contrib and add test (#10277) 4 years ago
gpg_key.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
gpg_key_add.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
gpg_key_commit_verification.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
gpg_key_common.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
gpg_key_import.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
gpg_key_test.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
gpg_key_verify.go Add option to provide signature for a token to verify key ownership (#14054) 3 years ago
helper.go Refactor: Move login out of models (#16199) 3 years ago
helper_directory.go Re-attempt to delete temporary upload if the file is locked by another process (#12447) 4 years ago
helper_environment.go chore(models): rewrite code format. (#14754) 3 years ago
index.go Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599) 3 years ago
index_test.go Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599) 3 years ago
issue.go Validate Issue Index before querying DB (#16406) 3 years ago
issue_assignees.go chore(models): rewrite code format. (#14754) 3 years ago
issue_assignees_test.go Fix individual tests (addition to #15802) (#15818) 3 years ago
issue_comment.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
issue_comment_list.go chore(models): rewrite code format. (#14754) 3 years ago
issue_comment_test.go Pull request review/approval and comment on code (#3748) 6 years ago
issue_dependency.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
issue_dependency_test.go Refactor comment (#9330) 5 years ago
issue_label.go Code Formats, Nits & Unused Func/Var deletions (#15286) 3 years ago
issue_label_test.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
issue_list.go Performance improvement for list pull requests (#15447) 3 years ago
issue_list_test.go Add Organization Wide Labels (#10814) 4 years ago
issue_lock.go chore(models): rewrite code format. (#14754) 3 years ago
issue_milestone.go Update milestone counters on new issue. (#16183) 3 years ago
issue_milestone_test.go Update milestone counters on new issue. (#16183) 3 years ago
issue_reaction.go chore(models): rewrite code format. (#14754) 3 years ago
issue_reaction_test.go Migrate reactions when migrating repository from github (#9599) 5 years ago
issue_stopwatch.go chore(models): rewrite code format. (#14754) 3 years ago
issue_stopwatch_test.go Fixed assert statements. (#16089) 3 years ago
issue_test.go Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599) 3 years ago
issue_tracked_time.go chore(models): rewrite code format. (#14754) 3 years ago
issue_tracked_time_test.go chore(models): rewrite code format. (#14754) 3 years ago
issue_user.go Mail assignee when issue/pull request is assigned (#8546) 5 years ago
issue_user_test.go Add "Update Branch" button to Pull Requests (#9784) 5 years ago
issue_watch.go chore(models): rewrite code format. (#14754) 3 years ago
issue_watch_test.go Fixed assert statements. (#16089) 3 years ago
issue_xref.go don't record error when loading ref comment but ref comment id is zero (#15820) 3 years ago
issue_xref_test.go Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599) 3 years ago
lfs.go Code Formats, Nits & Unused Func/Var deletions (#15286) 3 years ago
lfs_lock.go chore(models): rewrite code format. (#14754) 3 years ago
list_options.go Fix list_options GetStartEnd (#16303) 3 years ago
log.go Fix xorm log stack level (#15285) 3 years ago
login_source.go Refactor: Move login out of models (#16199) 3 years ago
main_test.go Add gitea-vet (#10948) 4 years ago
migrate.go Fix delete nonexist oauth application 500 and prevent deadlock (#15384) 3 years ago
models.go Add tag protection (#15629) 3 years ago
models_test.go Fix setting version table in dump (#15753) 3 years ago
notification.go Improve notifications for WIP draft PR's (#14663) 3 years ago
notification_test.go add request review from specific reviewers feature in pull request (#10756) 4 years ago
oauth2.go Refactor: Move login out of models (#16199) 3 years ago
oauth2_application.go Refactor: Move login out of models (#16199) 3 years ago
oauth2_application_test.go Fixed assert statements. (#16089) 3 years ago
org.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
org_team.go chore(models): rewrite code format. (#14754) 3 years ago
org_team_test.go chore(models): rewrite code format. (#14754) 3 years ago
org_test.go Add Visible modes function from Organisation to Users too (#16069) 3 years ago
project.go chore(models): rewrite code format. (#14754) 3 years ago
project_board.go chore(models): rewrite code format. (#14754) 3 years ago
project_issue.go chore(models): rewrite code format. (#14754) 3 years ago
project_test.go chore(models): rewrite code format. (#14754) 3 years ago
protected_tag.go Add tag protection (#15629) 3 years ago
protected_tag_test.go Add tag protection (#15629) 3 years ago
pull.go Improve notifications for WIP draft PR's (#14663) 3 years ago
pull_list.go API add/generalize pagination (#9452) 4 years ago
pull_sign.go Add configurable Trust Models (#11712) 4 years ago
pull_test.go Display conflict-free merge messages for pull requests (#15773) 3 years ago
release.go [API] ListReleases add filter for draft and pre-releases (#16175) 3 years ago
repo.go Restore creation of git-daemon-export-ok files (#16508) 3 years ago
repo_activity.go Add top author stats to activity page (#9615) 5 years ago
repo_archiver.go Fix archive error when rename repo or user (#16399) 3 years ago
repo_avatar.go Avatars and Repo avatars support storing in minio (#12516) 4 years ago
repo_branch.go Move newbranch to standalone package (#9627) 5 years ago
repo_collaboration.go Save TimeStamps for Star, Label, Follow, Watch and Collaboration to Database (#13124) 4 years ago
repo_collaboration_test.go API add/generalize pagination (#9452) 4 years ago
repo_generate.go Refactor renders (#15175) 3 years ago
repo_generate_test.go Fixed assert statements. (#16089) 3 years ago
repo_indexer.go Index code and stats only for non-empty repositories (#10251) 4 years ago
repo_issue.go Add EnableTimetracking option to app settings (#3719) 6 years ago
repo_language_stats.go chore(models): rewrite code format. (#14754) 3 years ago
repo_list.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
repo_list_test.go chore(models): rewrite code format. (#14754) 3 years ago
repo_mirror.go Add push to remote mirror repository (#15157) 3 years ago
repo_permission.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
repo_permission_test.go fix bug when update owner team then visit team's repo return 404 (#6119) 5 years ago
repo_pushmirror.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
repo_pushmirror_test.go Add push to remote mirror repository (#15157) 3 years ago
repo_redirect.go Redirect on changed user and org name (#11649) 3 years ago
repo_redirect_test.go Redirect on changed user and org name (#11649) 3 years ago
repo_sign.go Add configurable Trust Models (#11712) 4 years ago
repo_test.go Fixed assert statements. (#16089) 3 years ago
repo_transfer.go Retry rename on lock induced failures (#16435) 3 years ago
repo_transfer_test.go chore(models): rewrite code format. (#14754) 3 years ago
repo_unit.go Refactor: Move login out of models (#16199) 3 years ago
repo_watch.go chore(models): rewrite code format. (#14754) 3 years ago
repo_watch_test.go API add/generalize pagination (#9452) 4 years ago
review.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
review_test.go Ensure review dismissal only dismisses the correct review (#15477) 3 years ago
session.go Fix DB session cleanup (#15697) 3 years ago
sql_postgres_with_schema.go Ensure that schema search path is set with every connection on postgres (#14131) 4 years ago
ssh_key.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_authorized_keys.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_authorized_principals.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_deploy.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_fingerprint.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_parse.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_principals.go Refactor: Move login out of models (#16199) 3 years ago
ssh_key_test.go Add support for ed25519_sk and ecdsa_sk SSH keys (#13462) 3 years ago
star.go Save TimeStamps for Star, Label, Follow, Watch and Collaboration to Database (#13124) 4 years ago
star_test.go API add/generalize pagination (#9452) 4 years ago
store.go Refactor: Move login out of models (#16199) 3 years ago
task.go Add Status Updates whilst Gitea migrations are occurring (#15076) 3 years ago
test_fixtures.go Create Proper Migration Tests (#15116) 3 years ago
token.go Only check access tokens if they are likely to be tokens (#16164) 3 years ago
token_test.go chore(models): rewrite code format. (#14754) 3 years ago
topic.go Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
topic_test.go Fixed assert statements. (#16089) 3 years ago
twofactor.go Use single shared random string generation function (#15741) 3 years ago
u2f.go Display ui time with customize time location (#7792) 5 years ago
u2f_test.go Add gitea-vet (#10948) 4 years ago
unit.go Kanban board (#8346) 4 years ago
unit_tests.go Rework repository archive (#14723) 3 years ago
update.go Remove Unused Functions (#10516) 4 years ago
upload.go Handle and propagate errors when checking if paths are Dirs, Files or Exist (#13186) 4 years ago
user.go Refactor: Move login out of models (#16199) 3 years ago
user_avatar.go Send size to /avatars if requested (#15459) 3 years ago
user_follow.go Save TimeStamps for Star, Label, Follow, Watch and Collaboration to Database (#13124) 4 years ago
user_follow_test.go Add gitea-vet (#10948) 4 years ago
user_heatmap.go Fix heatmap activity (#15252) 3 years ago
user_heatmap_test.go Fix heatmap activity (#15252) 3 years ago
user_mail.go Fix activation of primary email addresses (#16385) 3 years ago
user_mail_test.go Always store primary email address into email_address table and also the state (#15956) 3 years ago
user_openid.go Code Formats, Nits & Unused Func/Var deletions (#15286) 3 years ago
user_openid_test.go Fixed assert statements. (#16089) 3 years ago
user_redirect.go Redirect on changed user and org name (#11649) 3 years ago
user_redirect_test.go Redirect on changed user and org name (#11649) 3 years ago
user_test.go Refactor: Move login out of models (#16199) 3 years ago
userlist.go chore(models): rewrite code format. (#14754) 3 years ago
userlist_test.go chore(models): rewrite code format. (#14754) 3 years ago
webhook.go Add support for corporate WeChat webhooks (#15910) 3 years ago
webhook_test.go Refactor Webhook + Add X-Hub-Signature (#16176) 3 years ago
wiki.go Handle and propagate errors when checking if paths are Dirs, Files or Exist (#13186) 4 years ago
wiki_test.go Move wiki related funtions from models to services/wiki (#9355) 5 years ago