git-lfs: fixed bug #5399 git-lfs application failed to generate HTTPS urls properly.

This commit is contained in:
Daniel Dourvaris 2019-07-02 15:08:39 +02:00
parent 337cdc8014
commit 6793d652e0
6 changed files with 18 additions and 7 deletions

View file

@ -142,7 +142,7 @@ class SimpleGit(simplevcs.SimpleVCS):
return self.scm_app.create_git_wsgi_app(
repo_path, repo_name, config)
def _create_config(self, extras, repo_name):
def _create_config(self, extras, repo_name, scheme='http'):
extras['git_update_server_info'] = utils2.str2bool(
rhodecode.CONFIG.get('git_update_server_info'))
@ -152,4 +152,5 @@ class SimpleGit(simplevcs.SimpleVCS):
extras['git_lfs_enabled'] = utils2.str2bool(
config.get('vcs_git_lfs', 'enabled'))
extras['git_lfs_store_path'] = custom_store or default_lfs_store()
extras['git_lfs_http_scheme'] = scheme
return extras

View file

@ -153,7 +153,7 @@ class SimpleHg(simplevcs.SimpleVCS):
def _create_wsgi_app(self, repo_path, repo_name, config):
return self.scm_app.create_hg_wsgi_app(repo_path, repo_name, config)
def _create_config(self, extras, repo_name):
def _create_config(self, extras, repo_name, scheme='http'):
config = utils.make_db_config(repo=repo_name)
config.set('rhodecode', 'RC_SCM_DATA', json.dumps(extras))

View file

@ -219,7 +219,7 @@ class SimpleSvn(simplevcs.SimpleVCS):
conf = self.repo_vcs_config
return str2bool(conf.get('vcs_svn_proxy', 'http_requests_enabled'))
def _create_config(self, extras, repo_name):
def _create_config(self, extras, repo_name, scheme='http'):
conf = self.repo_vcs_config
server_url = conf.get('vcs_svn_proxy', 'http_server_url')
server_url = server_url or self.DEFAULT_HTTP_SERVER

View file

@ -360,6 +360,13 @@ class SimpleVCS(object):
return perm_result
def _get_http_scheme(self, environ):
try:
return environ['wsgi.url_scheme']
except Exception:
log.exception('Failed to read http scheme')
return 'http'
def _check_ssl(self, environ, start_response):
"""
Checks the SSL check flag and returns False if SSL is not present
@ -597,7 +604,9 @@ class SimpleVCS(object):
extras, environ, action, txn_id=txn_id)
log.debug('HOOKS extras is %s', extras)
config = self._create_config(extras, self.acl_repo_name)
http_scheme = self._get_http_scheme(environ)
config = self._create_config(extras, self.acl_repo_name, scheme=http_scheme)
app = self._create_wsgi_app(repo_path, self.url_repo_name, config)
with callback_daemon:
app.rc_extras = extras
@ -643,7 +652,7 @@ class SimpleVCS(object):
"""Return the WSGI app that will finally handle the request."""
raise NotImplementedError()
def _create_config(self, extras, repo_name):
def _create_config(self, extras, repo_name, scheme='http'):
"""Create a safe config representation."""
raise NotImplementedError()

View file

@ -121,7 +121,8 @@ def test_get_config(user_util, baseapp, request_stub):
expected_config.update({
'git_update_server_info': False,
'git_lfs_enabled': False,
'git_lfs_store_path': git_config['git_lfs_store_path']
'git_lfs_store_path': git_config['git_lfs_store_path'],
'git_lfs_http_scheme': 'http'
})
assert git_config == expected_config

View file

@ -69,7 +69,7 @@ class StubVCSController(simplevcs.SimpleVCS):
return self.stub_response_body
return fake_app
def _create_config(self, extras, repo_name):
def _create_config(self, extras, repo_name, scheme='http'):
return None