1
0
Fork 0
gitea/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>
2021-07-24 11:16:34 +01:00
..
fixtures
migrations Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
access.go
access_test.go
action.go
action_list.go
action_test.go
admin.go
admin_test.go
attachment.go
attachment_test.go
avatar.go
avatar_test.go
branches.go
branches_test.go
commit_status.go
commit_status_test.go
consistency.go
consistency_test.go
context.go
convert.go
error.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
error_oauth2.go
external_login_user.go
fixture_generation.go
fixture_test.go
gpg_key.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
gpg_key_add.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
gpg_key_commit_verification.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
gpg_key_common.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
gpg_key_import.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
gpg_key_test.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
gpg_key_verify.go Add option to provide signature for a token to verify key ownership (#14054) 2021-07-13 15:28:07 +02:00
helper.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
helper_directory.go
helper_environment.go
index.go
index_test.go
issue.go
issue_assignees.go
issue_assignees_test.go
issue_comment.go
issue_comment_list.go
issue_comment_test.go
issue_dependency.go
issue_dependency_test.go
issue_label.go
issue_label_test.go
issue_list.go
issue_list_test.go
issue_lock.go
issue_milestone.go
issue_milestone_test.go
issue_reaction.go
issue_reaction_test.go
issue_stopwatch.go
issue_stopwatch_test.go
issue_test.go
issue_tracked_time.go
issue_tracked_time_test.go
issue_user.go
issue_user_test.go
issue_watch.go
issue_watch_test.go
issue_xref.go
issue_xref_test.go
lfs.go
lfs_lock.go
list_options.go
log.go
login_source.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
main_test.go
migrate.go
models.go
models_test.go
notification.go
notification_test.go
oauth2.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
oauth2_application.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
oauth2_application_test.go
org.go
org_team.go
org_team_test.go
org_test.go
project.go
project_board.go
project_issue.go
project_test.go
protected_tag.go
protected_tag_test.go
pull.go
pull_list.go
pull_sign.go
pull_test.go
release.go
repo.go Restore creation of git-daemon-export-ok files (#16508) 2021-07-22 12:53:54 +01:00
repo_activity.go
repo_archiver.go
repo_avatar.go
repo_branch.go
repo_collaboration.go
repo_collaboration_test.go
repo_generate.go
repo_generate_test.go
repo_indexer.go
repo_issue.go
repo_language_stats.go
repo_list.go
repo_list_test.go
repo_mirror.go
repo_permission.go
repo_permission_test.go
repo_pushmirror.go
repo_pushmirror_test.go
repo_redirect.go
repo_redirect_test.go
repo_sign.go
repo_test.go
repo_transfer.go Retry rename on lock induced failures (#16435) 2021-07-15 11:46:07 -04:00
repo_transfer_test.go
repo_unit.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
repo_watch.go
repo_watch_test.go
review.go
review_test.go
session.go
sql_postgres_with_schema.go
ssh_key.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_authorized_keys.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_authorized_principals.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_deploy.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_fingerprint.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_parse.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_principals.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
ssh_key_test.go
star.go
star_test.go
store.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
task.go
test_fixtures.go
token.go
token_test.go
topic.go
topic_test.go
twofactor.go
u2f.go
u2f_test.go
unit.go
unit_tests.go
update.go
upload.go
user.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
user_avatar.go
user_follow.go
user_follow_test.go
user_heatmap.go
user_heatmap_test.go
user_mail.go Fix activation of primary email addresses (#16385) 2021-07-13 22:59:27 +02:00
user_mail_test.go
user_openid.go
user_openid_test.go
user_redirect.go
user_redirect_test.go
user_test.go Refactor: Move login out of models (#16199) 2021-07-24 11:16:34 +01:00
userlist.go
userlist_test.go
webhook.go Add support for corporate WeChat webhooks (#15910) 2021-07-23 12:41:27 +08:00
webhook_test.go
wiki.go
wiki_test.go