Mercurial > kallithea
comparison rhodecode/lib/middleware/simplegit.py @ 1283:d6524f3025e8 beta
small fixes for gitmiddleware
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 24 Apr 2011 23:20:58 +0200 |
parents | 2723276285ae |
children | ae5b07e75ffd |
comparison
equal
deleted
inserted
replaced
1282:faaadfc3c359 | 1283:d6524f3025e8 |
---|---|
125 return HTTPInternalServerError()(environ, start_response) | 125 return HTTPInternalServerError()(environ, start_response) |
126 | 126 |
127 #====================================================================== | 127 #====================================================================== |
128 # CHECK ANONYMOUS PERMISSION | 128 # CHECK ANONYMOUS PERMISSION |
129 #====================================================================== | 129 #====================================================================== |
130 if self.action in ['pull', 'push'] or self.action: | 130 if self.action in ['pull', 'push']: |
131 anonymous_user = self.__get_user('default') | 131 anonymous_user = self.__get_user('default') |
132 self.username = anonymous_user.username | 132 self.username = anonymous_user.username |
133 anonymous_perm = self.__check_permission(self.action, | 133 anonymous_perm = self.__check_permission(self.action, |
134 anonymous_user, | 134 anonymous_user, |
135 self.repo_name) | 135 self.repo_name) |
159 #============================================================== | 159 #============================================================== |
160 # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME FROM | 160 # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME FROM |
161 # BASIC AUTH | 161 # BASIC AUTH |
162 #============================================================== | 162 #============================================================== |
163 | 163 |
164 if self.action in ['pull', 'push'] or self.action: | 164 if self.action in ['pull', 'push']: |
165 username = REMOTE_USER(environ) | 165 username = REMOTE_USER(environ) |
166 try: | 166 try: |
167 user = self.__get_user(username) | 167 user = self.__get_user(username) |
168 self.username = user.username | 168 self.username = user.username |
169 except: | 169 except: |
173 | 173 |
174 #check permissions for this repository | 174 #check permissions for this repository |
175 perm = self.__check_permission(self.action, user, | 175 perm = self.__check_permission(self.action, user, |
176 self.repo_name) | 176 self.repo_name) |
177 if perm is not True: | 177 if perm is not True: |
178 print 'not allowed' | |
179 return HTTPForbidden()(environ, start_response) | 178 return HTTPForbidden()(environ, start_response) |
180 | 179 |
181 self.extras = {'ip': self.ipaddr, | 180 self.extras = {'ip': self.ipaddr, |
182 'username': self.username, | 181 'username': self.username, |
183 'action': self.action, | 182 'action': self.action, |
198 return HTTPInternalServerError()(environ, start_response) | 197 return HTTPInternalServerError()(environ, start_response) |
199 | 198 |
200 #invalidate cache on push | 199 #invalidate cache on push |
201 if self.action == 'push': | 200 if self.action == 'push': |
202 self.__invalidate_cache(self.repo_name) | 201 self.__invalidate_cache(self.repo_name) |
203 messages = [] | 202 |
204 messages.append('thank you for using rhodecode') | 203 return app(environ, start_response) |
205 return app(environ, start_response) | |
206 else: | |
207 return app(environ, start_response) | |
208 | 204 |
209 def __make_app(self): | 205 def __make_app(self): |
210 _d = {'/' + self.repo_name: Repo(self.repo_path)} | 206 _d = {'/' + self.repo_name: Repo(self.repo_path)} |
211 backend = dulserver.DictBackend(_d) | 207 backend = dulserver.DictBackend(_d) |
212 gitserve = HTTPGitApplication(backend) | 208 gitserve = HTTPGitApplication(backend) |