comparison rhodecode/lib/middleware/simplegit.py @ 2668:f0851f37d6be beta

Implementes #509 require SSL flag now works for both git and mercurial. - check is done at earlies possible stage - if detected protocol is not https and flag require is there RhodeCode will return HTTP Error 406: Not Acceptable, before even checking credentials - removed push_ssl flag from mercurial UI objects since that would duplicate logic
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 26 Jul 2012 23:03:26 +0200
parents d24c70ec9312
children 4c71667160e5
comparison
equal deleted inserted replaced
2667:129beb0062c2 2668:f0851f37d6be
72 # not used for now until dulwich get's fixed 72 # not used for now until dulwich get's fixed
73 #from dulwich.repo import Repo 73 #from dulwich.repo import Repo
74 #from dulwich.web import make_wsgi_chain 74 #from dulwich.web import make_wsgi_chain
75 75
76 from paste.httpheaders import REMOTE_USER, AUTH_TYPE 76 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
77 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
78 HTTPBadRequest, HTTPNotAcceptable
77 79
78 from rhodecode.lib.utils2 import safe_str 80 from rhodecode.lib.utils2 import safe_str
79 from rhodecode.lib.base import BaseVCSController 81 from rhodecode.lib.base import BaseVCSController
80 from rhodecode.lib.auth import get_container_username 82 from rhodecode.lib.auth import get_container_username
81 from rhodecode.lib.utils import is_valid_repo, make_ui 83 from rhodecode.lib.utils import is_valid_repo, make_ui
82 from rhodecode.model.db import User, RhodeCodeUi 84 from rhodecode.model.db import User, RhodeCodeUi
83
84 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
85 85
86 log = logging.getLogger(__name__) 86 log = logging.getLogger(__name__)
87 87
88 88
89 GIT_PROTO_PAT = re.compile(r'^/(.+)/(info/refs|git-upload-pack|git-receive-pack)') 89 GIT_PROTO_PAT = re.compile(r'^/(.+)/(info/refs|git-upload-pack|git-receive-pack)')
102 102
103 def _handle_request(self, environ, start_response): 103 def _handle_request(self, environ, start_response):
104 104
105 if not is_git(environ): 105 if not is_git(environ):
106 return self.application(environ, start_response) 106 return self.application(environ, start_response)
107 107 if not self._check_ssl(environ, start_response):
108 return HTTPNotAcceptable('SSL REQUIRED !')(environ, start_response)
108 ipaddr = self._get_ip_addr(environ) 109 ipaddr = self._get_ip_addr(environ)
109 username = None 110 username = None
110 self._git_first_op = False 111 self._git_first_op = False
111 # skip passing error to error controller 112 # skip passing error to error controller
112 environ['pylons.status_code_redirect'] = True 113 environ['pylons.status_code_redirect'] = True