From 0a2c0cb2c6445422f26c300cae6932881f1b47fd Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Oct 05 2018 13:55:44 +0000 Subject: Allow anonymous cloning if gitolite is in use Signed-off-by: Patrick Uiterwijk --- diff --git a/doc/configuration.rst b/doc/configuration.rst index eb35b98..61c2aaf 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1467,6 +1467,15 @@ serves this URL. Defaults to: ``True`` +ANON_HTTP_PULL_USER +~~~~~~~~~~~~~~~~~~~ + +This configures a username used to pass gitolite as anonymous user for HTTP cloning. +If unset, anonymous cloning won't work via HTTPS. + +Defaults to: ``None`` + + ALLOW_HTTP_PUSH ~~~~~~~~~~~~~~~ diff --git a/pagure/default_config.py b/pagure/default_config.py index 05b4c86..9a95227 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -483,6 +483,8 @@ _REACTIONS_DICT = dict(REACTIONS) # HTTP pull/push options # Whether to allow Git HTTP proxying ALLOW_HTTP_PULL_PUSH = True +# Anonymous HTTP pull user. Should be a reserved user. +ANON_HTTP_PULL_USER = None # Whether to allow pushing via HTTP ALLOW_HTTP_PUSH = False # Path to Gitolite-shell if using that, None to use Git directly diff --git a/pagure/ui/clone.py b/pagure/ui/clone.py index 3a42a84..8406f33 100644 --- a/pagure/ui/clone.py +++ b/pagure/ui/clone.py @@ -41,9 +41,12 @@ def proxy_raw_git(): """ # We are going to shell out to gitolite-shell. Prepare the env it needs. gitenv = { + # Let's also provide PATH + "PATH": os.environ.get("PATH"), # These are the vars git-http-backend needs "PATH_INFO": flask.request.path, - "REMOTE_USER": flask.request.remote_user, + "REMOTE_USER": flask.request.remote_user + or pagure_config["ANON_HTTP_PULL_USER"], "REMOTE_ADDR": flask.request.remote_addr, "CONTENT_TYPE": flask.request.content_type, "QUERY_STRING": flask.request.query_string, @@ -77,6 +80,7 @@ def proxy_raw_git(): "CONTENT_TYPE", "QUERY_STRING", "PYTHONPATH", + "PATH", ): if not gitenv[key]: del gitenv[key]