Prevent double-login for Git HTTP and LFS and simplify login #15303

Merged
lunny merged 17 commits from disable-basic-authentication-2 into main 2021-05-15 15:32:09 +00:00
Contributor

There are a number of inconsistencies with our current methods for logging in for git and lfs. The first is that there is a double login process. This is particularly evident in 1.13 where there are no less than 4 hash checks for basic authentication due to the previous IsPasswordSet behaviour.

This duplicated code had individual inconsistencies that were not helpful and caused confusion.

This PR does the following:

  • Remove the specific login code from the git and lfs handlers except for the lfs special bearer token.
  • Simplify the meaning of DisableBasicAuthentication to allow Token and Oauth2 sign-in.
  • The removal of the specific code from git http and LFS means that these both now have the same login semantics and can - if DisableBasicAuthentication is not set - login from external services. Further it allows Oauth2 token authentication as per our standard mechanisms.
  • The change in the recovery handler prevents the service from re-attempting to login - primarily because this could easily cause a further panic and it is wasteful.

This does have the slight changes but I think these result in much more consistent behaviour:

  • DisableBasicAuthentication does not prevent OAuth2 or Token auth using the Basic authentication header
  • You cannot use Basic authentication to access the UI - this was broken in any case as it didn't manage the session properly

However it does fix a number of bugs with LFS authentication relating to external user sign-on.

Extract from #15186

Signed-off-by: Andrew Thornton art27@cantab.net

There are a number of inconsistencies with our current methods for logging in for git and lfs. The first is that there is a double login process. This is particularly evident in 1.13 where there are no less than 4 hash checks for basic authentication due to the previous `IsPasswordSet` behaviour. This duplicated code had individual inconsistencies that were not helpful and caused confusion. This PR does the following: * Remove the specific login code from the git and lfs handlers except for the lfs special bearer token. * Simplify the meaning of DisableBasicAuthentication to allow Token and Oauth2 sign-in. * The removal of the specific code from git http and LFS means that these both now have the same login semantics and can - if `DisableBasicAuthentication` is not set - login from external services. Further it allows Oauth2 token authentication as per our standard mechanisms. * The change in the recovery handler prevents the service from re-attempting to login - primarily because this could easily cause a further panic and it is wasteful. This does have the slight changes but I think these result in much more consistent behaviour: * DisableBasicAuthentication does not prevent OAuth2 or Token auth using the Basic authentication header * You cannot use Basic authentication to access the UI - this was broken in any case as it didn't manage the session properly However it does fix a number of bugs with LFS authentication relating to external user sign-on. Extract from #15186 Signed-off-by: Andrew Thornton <art27@cantab.net>
silverwind (Migrated from github.com) approved these changes 2021-05-12 16:21:14 +00:00
techknowlogick approved these changes 2021-05-15 13:36:46 +00:00
This repo is archived. You cannot comment on pull requests.
No Milestone
No project
No Assignees
3 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#15303
No description provided.