Mercurial > kallithea
comparison rhodecode/lib/middleware/simplegit.py @ 3179:cd50d1b5f35b
merged with beta
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 21 Jan 2013 00:03:44 +0100 |
parents | a5f0bc867edc e7ba69286276 |
children | e351161b8734 |
comparison
equal
deleted
inserted
replaced
3113:a0737406ce26 | 3179:cd50d1b5f35b |
---|---|
107 if not is_git(environ): | 107 if not is_git(environ): |
108 return self.application(environ, start_response) | 108 return self.application(environ, start_response) |
109 if not self._check_ssl(environ, start_response): | 109 if not self._check_ssl(environ, start_response): |
110 return HTTPNotAcceptable('SSL REQUIRED !')(environ, start_response) | 110 return HTTPNotAcceptable('SSL REQUIRED !')(environ, start_response) |
111 | 111 |
112 ipaddr = self._get_ip_addr(environ) | 112 ip_addr = self._get_ip_addr(environ) |
113 username = None | 113 username = None |
114 self._git_first_op = False | 114 self._git_first_op = False |
115 # skip passing error to error controller | 115 # skip passing error to error controller |
116 environ['pylons.status_code_redirect'] = True | 116 environ['pylons.status_code_redirect'] = True |
117 | 117 |
138 #====================================================================== | 138 #====================================================================== |
139 if action in ['pull', 'push']: | 139 if action in ['pull', 'push']: |
140 anonymous_user = self.__get_user('default') | 140 anonymous_user = self.__get_user('default') |
141 username = anonymous_user.username | 141 username = anonymous_user.username |
142 anonymous_perm = self._check_permission(action, anonymous_user, | 142 anonymous_perm = self._check_permission(action, anonymous_user, |
143 repo_name) | 143 repo_name, ip_addr) |
144 | 144 |
145 if anonymous_perm is not True or anonymous_user.active is False: | 145 if anonymous_perm is not True or anonymous_user.active is False: |
146 if anonymous_perm is not True: | 146 if anonymous_perm is not True: |
147 log.debug('Not enough credentials to access this ' | 147 log.debug('Not enough credentials to access this ' |
148 'repository as anonymous user') | 148 'repository as anonymous user') |
180 except: | 180 except: |
181 log.error(traceback.format_exc()) | 181 log.error(traceback.format_exc()) |
182 return HTTPInternalServerError()(environ, start_response) | 182 return HTTPInternalServerError()(environ, start_response) |
183 | 183 |
184 #check permissions for this repository | 184 #check permissions for this repository |
185 perm = self._check_permission(action, user, repo_name) | 185 perm = self._check_permission(action, user, repo_name, ip_addr) |
186 if perm is not True: | 186 if perm is not True: |
187 return HTTPForbidden()(environ, start_response) | 187 return HTTPForbidden()(environ, start_response) |
188 | 188 |
189 # extras are injected into UI object and later available | 189 # extras are injected into UI object and later available |
190 # in hooks executed by rhodecode | 190 # in hooks executed by rhodecode |
191 from rhodecode import CONFIG | 191 from rhodecode import CONFIG |
192 server_url = get_server_url(environ) | 192 server_url = get_server_url(environ) |
193 extras = { | 193 extras = { |
194 'ip': ipaddr, | 194 'ip': ip_addr, |
195 'username': username, | 195 'username': username, |
196 'action': action, | 196 'action': action, |
197 'repository': repo_name, | 197 'repository': repo_name, |
198 'scm': 'git', | 198 'scm': 'git', |
199 'config': CONFIG['__file__'], | 199 'config': CONFIG['__file__'], |
231 # invalidate cache on push | 231 # invalidate cache on push |
232 if action == 'push': | 232 if action == 'push': |
233 self._invalidate_cache(repo_name) | 233 self._invalidate_cache(repo_name) |
234 self._handle_githooks(repo_name, action, baseui, environ) | 234 self._handle_githooks(repo_name, action, baseui, environ) |
235 | 235 |
236 log.info('%s action on GIT repo "%s"' % (action, repo_name)) | 236 log.info('%s action on GIT repo "%s" by "%s" from %s' % |
237 (action, repo_name, username, ip_addr)) | |
237 app = self.__make_app(repo_name, repo_path, extras) | 238 app = self.__make_app(repo_name, repo_path, extras) |
238 return app(environ, start_response) | 239 return app(environ, start_response) |
239 except HTTPLockedRC, e: | 240 except HTTPLockedRC, e: |
240 log.debug('Repositry LOCKED ret code 423!') | 241 log.debug('Repository LOCKED ret code 423!') |
241 return e(environ, start_response) | 242 return e(environ, start_response) |
242 except Exception: | 243 except Exception: |
243 log.error(traceback.format_exc()) | 244 log.error(traceback.format_exc()) |
244 return HTTPInternalServerError()(environ, start_response) | 245 return HTTPInternalServerError()(environ, start_response) |
245 | 246 |