##// END OF EJS Templates
merge pull request #32 from codingtony
marcink -
r2061:9f0fe677 beta
parent child Browse files
Show More
@@ -1,536 +1,536 b''
1 1 .. _changelog:
2 2
3 3 Changelog
4 4 =========
5 5
6 6
7 7 1.3.2 (**2012-XX-XX**)
8 8 ----------------------
9 9
10 10 :status: in-progress
11 11 :branch: beta
12 12
13 13 news
14 14 ++++
15 15
16 16
17 17 fixes
18 18 +++++
19 19
20 20 - fixed git protocol issues with repos-groups
21 21 - fixed git remote repos validator that prevented from cloning remote git repos
22 22 - fixes #370 ending slashes fixes for repo and groups
23 #- fixes #368 improved git-protocol detection to handle other clients
23 - fixes #368 improved git-protocol detection to handle other clients
24 24 - fixes #366 When Setting Repository Group To Blank Repo Group Wont Be
25 25 Moved To Root
26 26
27 27 1.3.1 (**2012-02-27**)
28 28 ----------------------
29 29
30 30 news
31 31 ++++
32 32
33 33
34 34 fixes
35 35 +++++
36 36
37 37 - redirection loop occurs when remember-me wasn't checked during login
38 38 - fixes issues with git blob history generation
39 39 - don't fetch branch for git in file history dropdown. Causes unneeded slowness
40 40
41 41 1.3.0 (**2012-02-26**)
42 42 ----------------------
43 43
44 44 news
45 45 ++++
46 46
47 47 - code review, inspired by github code-comments
48 48 - #215 rst and markdown README files support
49 49 - #252 Container-based and proxy pass-through authentication support
50 50 - #44 branch browser. Filtering of changelog by branches
51 51 - mercurial bookmarks support
52 52 - new hover top menu, optimized to add maximum size for important views
53 53 - configurable clone url template with possibility to specify protocol like
54 54 ssh:// or http:// and also manually alter other parts of clone_url.
55 55 - enabled largefiles extension by default
56 56 - optimized summary file pages and saved a lot of unused space in them
57 57 - #239 option to manually mark repository as fork
58 58 - #320 mapping of commit authors to RhodeCode users
59 59 - #304 hashes are displayed using monospace font
60 60 - diff configuration, toggle white lines and context lines
61 61 - #307 configurable diffs, whitespace toggle, increasing context lines
62 62 - sorting on branches, tags and bookmarks using YUI datatable
63 63 - improved file filter on files page
64 64 - implements #330 api method for listing nodes ar particular revision
65 65 - #73 added linking issues in commit messages to chosen issue tracker url
66 66 based on user defined regular expression
67 67 - added linking of changesets in commit messages
68 68 - new compact changelog with expandable commit messages
69 69 - firstname and lastname are optional in user creation
70 70 - #348 added post-create repository hook
71 71 - #212 global encoding settings is now configurable from .ini files
72 72 - #227 added repository groups permissions
73 73 - markdown gets codehilite extensions
74 74 - new API methods, delete_repositories, grante/revoke permissions for groups
75 75 and repos
76 76
77 77
78 78 fixes
79 79 +++++
80 80
81 81 - rewrote dbsession management for atomic operations, and better error handling
82 82 - fixed sorting of repo tables
83 83 - #326 escape of special html entities in diffs
84 84 - normalized user_name => username in api attributes
85 85 - fixes #298 ldap created users with mixed case emails created conflicts
86 86 on saving a form
87 87 - fixes issue when owner of a repo couldn't revoke permissions for users
88 88 and groups
89 89 - fixes #271 rare JSON serialization problem with statistics
90 90 - fixes #337 missing validation check for conflicting names of a group with a
91 91 repositories group
92 92 - #340 fixed session problem for mysql and celery tasks
93 93 - fixed #331 RhodeCode mangles repository names if the a repository group
94 94 contains the "full path" to the repositories
95 95 - #355 RhodeCode doesn't store encrypted LDAP passwords
96 96
97 97 1.2.5 (**2012-01-28**)
98 98 ----------------------
99 99
100 100 news
101 101 ++++
102 102
103 103 fixes
104 104 +++++
105 105
106 106 - #340 Celery complains about MySQL server gone away, added session cleanup
107 107 for celery tasks
108 108 - #341 "scanning for repositories in None" log message during Rescan was missing
109 109 a parameter
110 110 - fixed creating archives with subrepos. Some hooks were triggered during that
111 111 operation leading to crash.
112 112 - fixed missing email in account page.
113 113 - Reverted Mercurial to 2.0.1 for windows due to bug in Mercurial that makes
114 114 forking on windows impossible
115 115
116 116 1.2.4 (**2012-01-19**)
117 117 ----------------------
118 118
119 119 news
120 120 ++++
121 121
122 122 - RhodeCode is bundled with mercurial series 2.0.X by default, with
123 123 full support to largefiles extension. Enabled by default in new installations
124 124 - #329 Ability to Add/Remove Groups to/from a Repository via AP
125 125 - added requires.txt file with requirements
126 126
127 127 fixes
128 128 +++++
129 129
130 130 - fixes db session issues with celery when emailing admins
131 131 - #331 RhodeCode mangles repository names if the a repository group
132 132 contains the "full path" to the repositories
133 133 - #298 Conflicting e-mail addresses for LDAP and RhodeCode users
134 134 - DB session cleanup after hg protocol operations, fixes issues with
135 135 `mysql has gone away` errors
136 136 - #333 doc fixes for get_repo api function
137 137 - #271 rare JSON serialization problem with statistics enabled
138 138 - #337 Fixes issues with validation of repository name conflicting with
139 139 a group name. A proper message is now displayed.
140 140 - #292 made ldap_dn in user edit readonly, to get rid of confusion that field
141 141 doesn't work
142 142 - #316 fixes issues with web description in hgrc files
143 143
144 144 1.2.3 (**2011-11-02**)
145 145 ----------------------
146 146
147 147 news
148 148 ++++
149 149
150 150 - added option to manage repos group for non admin users
151 151 - added following API methods for get_users, create_user, get_users_groups,
152 152 get_users_group, create_users_group, add_user_to_users_groups, get_repos,
153 153 get_repo, create_repo, add_user_to_repo
154 154 - implements #237 added password confirmation for my account
155 155 and admin edit user.
156 156 - implements #291 email notification for global events are now sent to all
157 157 administrator users, and global config email.
158 158
159 159 fixes
160 160 +++++
161 161
162 162 - added option for passing auth method for smtp mailer
163 163 - #276 issue with adding a single user with id>10 to usergroups
164 164 - #277 fixes windows LDAP settings in which missing values breaks the ldap auth
165 165 - #288 fixes managing of repos in a group for non admin user
166 166
167 167 1.2.2 (**2011-10-17**)
168 168 ----------------------
169 169
170 170 news
171 171 ++++
172 172
173 173 - #226 repo groups are available by path instead of numerical id
174 174
175 175 fixes
176 176 +++++
177 177
178 178 - #259 Groups with the same name but with different parent group
179 179 - #260 Put repo in group, then move group to another group -> repo becomes unavailable
180 180 - #258 RhodeCode 1.2 assumes egg folder is writable (lockfiles problems)
181 181 - #265 ldap save fails sometimes on converting attributes to booleans,
182 182 added getter and setter into model that will prevent from this on db model level
183 183 - fixed problems with timestamps issues #251 and #213
184 184 - fixes #266 RhodeCode allows to create repo with the same name and in
185 185 the same parent as group
186 186 - fixes #245 Rescan of the repositories on Windows
187 187 - fixes #248 cannot edit repos inside a group on windows
188 188 - fixes #219 forking problems on windows
189 189
190 190 1.2.1 (**2011-10-08**)
191 191 ----------------------
192 192
193 193 news
194 194 ++++
195 195
196 196
197 197 fixes
198 198 +++++
199 199
200 200 - fixed problems with basic auth and push problems
201 201 - gui fixes
202 202 - fixed logger
203 203
204 204 1.2.0 (**2011-10-07**)
205 205 ----------------------
206 206
207 207 news
208 208 ++++
209 209
210 210 - implemented #47 repository groups
211 211 - implemented #89 Can setup google analytics code from settings menu
212 212 - implemented #91 added nicer looking archive urls with more download options
213 213 like tags, branches
214 214 - implemented #44 into file browsing, and added follow branch option
215 215 - implemented #84 downloads can be enabled/disabled for each repository
216 216 - anonymous repository can be cloned without having to pass default:default
217 217 into clone url
218 218 - fixed #90 whoosh indexer can index chooses repositories passed in command
219 219 line
220 220 - extended journal with day aggregates and paging
221 221 - implemented #107 source code lines highlight ranges
222 222 - implemented #93 customizable changelog on combined revision ranges -
223 223 equivalent of githubs compare view
224 224 - implemented #108 extended and more powerful LDAP configuration
225 225 - implemented #56 users groups
226 226 - major code rewrites optimized codes for speed and memory usage
227 227 - raw and diff downloads are now in git format
228 228 - setup command checks for write access to given path
229 229 - fixed many issues with international characters and unicode. It uses utf8
230 230 decode with replace to provide less errors even with non utf8 encoded strings
231 231 - #125 added API KEY access to feeds
232 232 - #109 Repository can be created from external Mercurial link (aka. remote
233 233 repository, and manually updated (via pull) from admin panel
234 234 - beta git support - push/pull server + basic view for git repos
235 235 - added followers page and forks page
236 236 - server side file creation (with binary file upload interface)
237 237 and edition with commits powered by codemirror
238 238 - #111 file browser file finder, quick lookup files on whole file tree
239 239 - added quick login sliding menu into main page
240 240 - changelog uses lazy loading of affected files details, in some scenarios
241 241 this can improve speed of changelog page dramatically especially for
242 242 larger repositories.
243 243 - implements #214 added support for downloading subrepos in download menu.
244 244 - Added basic API for direct operations on rhodecode via JSON
245 245 - Implemented advanced hook management
246 246
247 247 fixes
248 248 +++++
249 249
250 250 - fixed file browser bug, when switching into given form revision the url was
251 251 not changing
252 252 - fixed propagation to error controller on simplehg and simplegit middlewares
253 253 - fixed error when trying to make a download on empty repository
254 254 - fixed problem with '[' chars in commit messages in journal
255 255 - fixed #99 Unicode errors, on file node paths with non utf-8 characters
256 256 - journal fork fixes
257 257 - removed issue with space inside renamed repository after deletion
258 258 - fixed strange issue on formencode imports
259 259 - fixed #126 Deleting repository on Windows, rename used incompatible chars.
260 260 - #150 fixes for errors on repositories mapped in db but corrupted in
261 261 filesystem
262 262 - fixed problem with ascendant characters in realm #181
263 263 - fixed problem with sqlite file based database connection pool
264 264 - whoosh indexer and code stats share the same dynamic extensions map
265 265 - fixes #188 - relationship delete of repo_to_perm entry on user removal
266 266 - fixes issue #189 Trending source files shows "show more" when no more exist
267 267 - fixes issue #197 Relative paths for pidlocks
268 268 - fixes issue #198 password will require only 3 chars now for login form
269 269 - fixes issue #199 wrong redirection for non admin users after creating a repository
270 270 - fixes issues #202, bad db constraint made impossible to attach same group
271 271 more than one time. Affects only mysql/postgres
272 272 - fixes #218 os.kill patch for windows was missing sig param
273 273 - improved rendering of dag (they are not trimmed anymore when number of
274 274 heads exceeds 5)
275 275
276 276 1.1.8 (**2011-04-12**)
277 277 ----------------------
278 278
279 279 news
280 280 ++++
281 281
282 282 - improved windows support
283 283
284 284 fixes
285 285 +++++
286 286
287 287 - fixed #140 freeze of python dateutil library, since new version is python2.x
288 288 incompatible
289 289 - setup-app will check for write permission in given path
290 290 - cleaned up license info issue #149
291 291 - fixes for issues #137,#116 and problems with unicode and accented characters.
292 292 - fixes crashes on gravatar, when passed in email as unicode
293 293 - fixed tooltip flickering problems
294 294 - fixed came_from redirection on windows
295 295 - fixed logging modules, and sql formatters
296 296 - windows fixes for os.kill issue #133
297 297 - fixes path splitting for windows issues #148
298 298 - fixed issue #143 wrong import on migration to 1.1.X
299 299 - fixed problems with displaying binary files, thanks to Thomas Waldmann
300 300 - removed name from archive files since it's breaking ui for long repo names
301 301 - fixed issue with archive headers sent to browser, thanks to Thomas Waldmann
302 302 - fixed compatibility for 1024px displays, and larger dpi settings, thanks to
303 303 Thomas Waldmann
304 304 - fixed issue #166 summary pager was skipping 10 revisions on second page
305 305
306 306
307 307 1.1.7 (**2011-03-23**)
308 308 ----------------------
309 309
310 310 news
311 311 ++++
312 312
313 313 fixes
314 314 +++++
315 315
316 316 - fixed (again) #136 installation support for FreeBSD
317 317
318 318
319 319 1.1.6 (**2011-03-21**)
320 320 ----------------------
321 321
322 322 news
323 323 ++++
324 324
325 325 fixes
326 326 +++++
327 327
328 328 - fixed #136 installation support for FreeBSD
329 329 - RhodeCode will check for python version during installation
330 330
331 331 1.1.5 (**2011-03-17**)
332 332 ----------------------
333 333
334 334 news
335 335 ++++
336 336
337 337 - basic windows support, by exchanging pybcrypt into sha256 for windows only
338 338 highly inspired by idea of mantis406
339 339
340 340 fixes
341 341 +++++
342 342
343 343 - fixed sorting by author in main page
344 344 - fixed crashes with diffs on binary files
345 345 - fixed #131 problem with boolean values for LDAP
346 346 - fixed #122 mysql problems thanks to striker69
347 347 - fixed problem with errors on calling raw/raw_files/annotate functions
348 348 with unknown revisions
349 349 - fixed returned rawfiles attachment names with international character
350 350 - cleaned out docs, big thanks to Jason Harris
351 351
352 352 1.1.4 (**2011-02-19**)
353 353 ----------------------
354 354
355 355 news
356 356 ++++
357 357
358 358 fixes
359 359 +++++
360 360
361 361 - fixed formencode import problem on settings page, that caused server crash
362 362 when that page was accessed as first after server start
363 363 - journal fixes
364 364 - fixed option to access repository just by entering http://server/<repo_name>
365 365
366 366 1.1.3 (**2011-02-16**)
367 367 ----------------------
368 368
369 369 news
370 370 ++++
371 371
372 372 - implemented #102 allowing the '.' character in username
373 373 - added option to access repository just by entering http://server/<repo_name>
374 374 - celery task ignores result for better performance
375 375
376 376 fixes
377 377 +++++
378 378
379 379 - fixed ehlo command and non auth mail servers on smtp_lib. Thanks to
380 380 apollo13 and Johan Walles
381 381 - small fixes in journal
382 382 - fixed problems with getting setting for celery from .ini files
383 383 - registration, password reset and login boxes share the same title as main
384 384 application now
385 385 - fixed #113: to high permissions to fork repository
386 386 - fixed problem with '[' chars in commit messages in journal
387 387 - removed issue with space inside renamed repository after deletion
388 388 - db transaction fixes when filesystem repository creation failed
389 389 - fixed #106 relation issues on databases different than sqlite
390 390 - fixed static files paths links to use of url() method
391 391
392 392 1.1.2 (**2011-01-12**)
393 393 ----------------------
394 394
395 395 news
396 396 ++++
397 397
398 398
399 399 fixes
400 400 +++++
401 401
402 402 - fixes #98 protection against float division of percentage stats
403 403 - fixed graph bug
404 404 - forced webhelpers version since it was making troubles during installation
405 405
406 406 1.1.1 (**2011-01-06**)
407 407 ----------------------
408 408
409 409 news
410 410 ++++
411 411
412 412 - added force https option into ini files for easier https usage (no need to
413 413 set server headers with this options)
414 414 - small css updates
415 415
416 416 fixes
417 417 +++++
418 418
419 419 - fixed #96 redirect loop on files view on repositories without changesets
420 420 - fixed #97 unicode string passed into server header in special cases (mod_wsgi)
421 421 and server crashed with errors
422 422 - fixed large tooltips problems on main page
423 423 - fixed #92 whoosh indexer is more error proof
424 424
425 425 1.1.0 (**2010-12-18**)
426 426 ----------------------
427 427
428 428 news
429 429 ++++
430 430
431 431 - rewrite of internals for vcs >=0.1.10
432 432 - uses mercurial 1.7 with dotencode disabled for maintaining compatibility
433 433 with older clients
434 434 - anonymous access, authentication via ldap
435 435 - performance upgrade for cached repos list - each repository has its own
436 436 cache that's invalidated when needed.
437 437 - performance upgrades on repositories with large amount of commits (20K+)
438 438 - main page quick filter for filtering repositories
439 439 - user dashboards with ability to follow chosen repositories actions
440 440 - sends email to admin on new user registration
441 441 - added cache/statistics reset options into repository settings
442 442 - more detailed action logger (based on hooks) with pushed changesets lists
443 443 and options to disable those hooks from admin panel
444 444 - introduced new enhanced changelog for merges that shows more accurate results
445 445 - new improved and faster code stats (based on pygments lexers mapping tables,
446 446 showing up to 10 trending sources for each repository. Additionally stats
447 447 can be disabled in repository settings.
448 448 - gui optimizations, fixed application width to 1024px
449 449 - added cut off (for large files/changesets) limit into config files
450 450 - whoosh, celeryd, upgrade moved to paster command
451 451 - other than sqlite database backends can be used
452 452
453 453 fixes
454 454 +++++
455 455
456 456 - fixes #61 forked repo was showing only after cache expired
457 457 - fixes #76 no confirmation on user deletes
458 458 - fixes #66 Name field misspelled
459 459 - fixes #72 block user removal when he owns repositories
460 460 - fixes #69 added password confirmation fields
461 461 - fixes #87 RhodeCode crashes occasionally on updating repository owner
462 462 - fixes #82 broken annotations on files with more than 1 blank line at the end
463 463 - a lot of fixes and tweaks for file browser
464 464 - fixed detached session issues
465 465 - fixed when user had no repos he would see all repos listed in my account
466 466 - fixed ui() instance bug when global hgrc settings was loaded for server
467 467 instance and all hgrc options were merged with our db ui() object
468 468 - numerous small bugfixes
469 469
470 470 (special thanks for TkSoh for detailed feedback)
471 471
472 472
473 473 1.0.2 (**2010-11-12**)
474 474 ----------------------
475 475
476 476 news
477 477 ++++
478 478
479 479 - tested under python2.7
480 480 - bumped sqlalchemy and celery versions
481 481
482 482 fixes
483 483 +++++
484 484
485 485 - fixed #59 missing graph.js
486 486 - fixed repo_size crash when repository had broken symlinks
487 487 - fixed python2.5 crashes.
488 488
489 489
490 490 1.0.1 (**2010-11-10**)
491 491 ----------------------
492 492
493 493 news
494 494 ++++
495 495
496 496 - small css updated
497 497
498 498 fixes
499 499 +++++
500 500
501 501 - fixed #53 python2.5 incompatible enumerate calls
502 502 - fixed #52 disable mercurial extension for web
503 503 - fixed #51 deleting repositories don't delete it's dependent objects
504 504
505 505
506 506 1.0.0 (**2010-11-02**)
507 507 ----------------------
508 508
509 509 - security bugfix simplehg wasn't checking for permissions on commands
510 510 other than pull or push.
511 511 - fixed doubled messages after push or pull in admin journal
512 512 - templating and css corrections, fixed repo switcher on chrome, updated titles
513 513 - admin menu accessible from options menu on repository view
514 514 - permissions cached queries
515 515
516 516 1.0.0rc4 (**2010-10-12**)
517 517 --------------------------
518 518
519 519 - fixed python2.5 missing simplejson imports (thanks to Jens BΓ€ckman)
520 520 - removed cache_manager settings from sqlalchemy meta
521 521 - added sqlalchemy cache settings to ini files
522 522 - validated password length and added second try of failure on paster setup-app
523 523 - fixed setup database destroy prompt even when there was no db
524 524
525 525
526 526 1.0.0rc3 (**2010-10-11**)
527 527 -------------------------
528 528
529 529 - fixed i18n during installation.
530 530
531 531 1.0.0rc2 (**2010-10-11**)
532 532 -------------------------
533 533
534 534 - Disabled dirsize in file browser, it's causing nasty bug when dir renames
535 535 occure. After vcs is fixed it'll be put back again.
536 536 - templating/css rewrites, optimized css. No newline at end of file
@@ -1,258 +1,247 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 rhodecode.lib.middleware.simplegit
4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 6 SimpleGit middleware for handling git protocol request (push/clone etc.)
7 7 It's implemented with basic auth function
8 8
9 9 :created_on: Apr 28, 2010
10 10 :author: marcink
11 11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
12 12 :license: GPLv3, see COPYING for more details.
13 13 """
14 14 # This program is free software: you can redistribute it and/or modify
15 15 # it under the terms of the GNU General Public License as published by
16 16 # the Free Software Foundation, either version 3 of the License, or
17 17 # (at your option) any later version.
18 18 #
19 19 # This program is distributed in the hope that it will be useful,
20 20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 22 # GNU General Public License for more details.
23 23 #
24 24 # You should have received a copy of the GNU General Public License
25 25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 26
27 27 import os
28 28 import re
29 29 import logging
30 30 import traceback
31 31
32 32 from dulwich import server as dulserver
33 33
34 34
35 35 class SimpleGitUploadPackHandler(dulserver.UploadPackHandler):
36 36
37 37 def handle(self):
38 38 write = lambda x: self.proto.write_sideband(1, x)
39 39
40 40 graph_walker = dulserver.ProtocolGraphWalker(self,
41 41 self.repo.object_store,
42 42 self.repo.get_peeled)
43 43 objects_iter = self.repo.fetch_objects(
44 44 graph_walker.determine_wants, graph_walker, self.progress,
45 45 get_tagged=self.get_tagged)
46 46
47 47 # Do they want any objects?
48 48 if objects_iter is None or len(objects_iter) == 0:
49 49 return
50 50
51 51 self.progress("counting objects: %d, done.\n" % len(objects_iter))
52 52 dulserver.write_pack_objects(dulserver.ProtocolFile(None, write),
53 53 objects_iter, len(objects_iter))
54 54 messages = []
55 55 messages.append('thank you for using rhodecode')
56 56
57 57 for msg in messages:
58 58 self.progress(msg + "\n")
59 59 # we are done
60 60 self.proto.write("0000")
61 61
62 62 dulserver.DEFAULT_HANDLERS = {
63 63 'git-upload-pack': SimpleGitUploadPackHandler,
64 64 'git-receive-pack': dulserver.ReceivePackHandler,
65 65 }
66 66
67 67 from dulwich.repo import Repo
68 68 from dulwich.web import HTTPGitApplication
69 69
70 70 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
71 71
72 72 from rhodecode.lib import safe_str
73 73 from rhodecode.lib.base import BaseVCSController
74 74 from rhodecode.lib.auth import get_container_username
75 75 from rhodecode.lib.utils import is_valid_repo
76 76 from rhodecode.model.db import User
77 77
78 78 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
79 79
80 80 log = logging.getLogger(__name__)
81 81
82 82
83 GIT_PROTO_PAT = re.compile(r'git-upload-pack|git-receive-pack|info\/refs')
83 GIT_PROTO_PAT = re.compile(r'^/(.+)/(info/refs|git-upload-pack|git-receive-pack)')
84 84
85 85
86 86 def is_git(environ):
87 """Returns True if request's target is git server.
88 ``HTTP_USER_AGENT`` would then have git client version given.
89
90 :param environ:
91 """
92 http_user_agent = environ.get('HTTP_USER_AGENT')
93 if http_user_agent and http_user_agent.startswith('git'):
94 return True
95 return False
87 path_info = environ['PATH_INFO']
88 isgit_path = GIT_PROTO_PAT.match(path_info)
89 log.debug('is a git path %s pathinfo : %s' % (isgit_path, path_info))
90 return isgit_path
96 91
97 92
98 93 class SimpleGit(BaseVCSController):
99 94
100 95 def _handle_request(self, environ, start_response):
96
101 97 if not is_git(environ):
102 98 return self.application(environ, start_response)
103 99
104 100 proxy_key = 'HTTP_X_REAL_IP'
105 101 def_key = 'REMOTE_ADDR'
106 102 ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0'))
107 103 username = None
108 104 # skip passing error to error controller
109 105 environ['pylons.status_code_redirect'] = True
110 106
111 107 #======================================================================
112 108 # EXTRACT REPOSITORY NAME FROM ENV
113 109 #======================================================================
114 110 try:
115 111 repo_name = self.__get_repository(environ)
116 112 log.debug('Extracted repo name is %s' % repo_name)
117 113 except:
118 114 return HTTPInternalServerError()(environ, start_response)
119 115
120 116 #======================================================================
121 117 # GET ACTION PULL or PUSH
122 118 #======================================================================
123 119 action = self.__get_action(environ)
124 120
125 121 #======================================================================
126 122 # CHECK ANONYMOUS PERMISSION
127 123 #======================================================================
128 124 if action in ['pull', 'push']:
129 125 anonymous_user = self.__get_user('default')
130 126 username = anonymous_user.username
131 127 anonymous_perm = self._check_permission(action, anonymous_user,
132 128 repo_name)
133 129
134 130 if anonymous_perm is not True or anonymous_user.active is False:
135 131 if anonymous_perm is not True:
136 132 log.debug('Not enough credentials to access this '
137 133 'repository as anonymous user')
138 134 if anonymous_user.active is False:
139 135 log.debug('Anonymous access is disabled, running '
140 136 'authentication')
141 137 #==============================================================
142 138 # DEFAULT PERM FAILED OR ANONYMOUS ACCESS IS DISABLED SO WE
143 139 # NEED TO AUTHENTICATE AND ASK FOR AUTH USER PERMISSIONS
144 140 #==============================================================
145 141
146 142 # Attempting to retrieve username from the container
147 143 username = get_container_username(environ, self.config)
148 144
149 145 # If not authenticated by the container, running basic auth
150 146 if not username:
151 147 self.authenticate.realm = \
152 148 safe_str(self.config['rhodecode_realm'])
153 149 result = self.authenticate(environ)
154 150 if isinstance(result, str):
155 151 AUTH_TYPE.update(environ, 'basic')
156 152 REMOTE_USER.update(environ, result)
157 153 username = result
158 154 else:
159 155 return result.wsgi_application(environ, start_response)
160 156
161 157 #==============================================================
162 158 # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME
163 159 #==============================================================
164 160 if action in ['pull', 'push']:
165 161 try:
166 162 user = self.__get_user(username)
167 163 if user is None or not user.active:
168 164 return HTTPForbidden()(environ, start_response)
169 165 username = user.username
170 166 except:
171 167 log.error(traceback.format_exc())
172 168 return HTTPInternalServerError()(environ,
173 169 start_response)
174 170
175 171 #check permissions for this repository
176 172 perm = self._check_permission(action, user,
177 173 repo_name)
178 174 if perm is not True:
179 175 return HTTPForbidden()(environ, start_response)
180 176
181 177 #===================================================================
182 178 # GIT REQUEST HANDLING
183 179 #===================================================================
184 180
185 181 repo_path = safe_str(os.path.join(self.basepath, repo_name))
186 182 log.debug('Repository path is %s' % repo_path)
187 183
188 184 # quick check if that dir exists...
189 185 if is_valid_repo(repo_name, self.basepath) is False:
190 186 return HTTPNotFound()(environ, start_response)
191 187
192 188 try:
193 189 #invalidate cache on push
194 190 if action == 'push':
195 191 self._invalidate_cache(repo_name)
196 192 log.info('%s action on GIT repo "%s"' % (action, repo_name))
197 193 app = self.__make_app(repo_name, repo_path)
198 194 return app(environ, start_response)
199 195 except Exception:
200 196 log.error(traceback.format_exc())
201 197 return HTTPInternalServerError()(environ, start_response)
202 198
203 199 def __make_app(self, repo_name, repo_path):
204 200 """
205 201 Make an wsgi application using dulserver
206 202
207 203 :param repo_name: name of the repository
208 204 :param repo_path: full path to the repository
209 205 """
210 206
211 207 _d = {'/' + repo_name: Repo(repo_path)}
212 208 backend = dulserver.DictBackend(_d)
213 209 gitserve = HTTPGitApplication(backend)
214 210
215 211 return gitserve
216 212
217 213 def __get_repository(self, environ):
218 214 """
219 215 Get's repository name out of PATH_INFO header
220 216
221 217 :param environ: environ where PATH_INFO is stored
222 218 """
223 219 try:
224 220 environ['PATH_INFO'] = self._get_by_id(environ['PATH_INFO'])
225 repo_name = '/'.join(environ['PATH_INFO'].split('/')[1:])
226 repo_name = GIT_PROTO_PAT.split(repo_name)
227 if repo_name:
228 repo_name = repo_name[0]
229
230 if repo_name.endswith('/'):
231 repo_name = repo_name.rstrip('/')
221 repo_name = GIT_PROTO_PAT.match(environ['PATH_INFO']).group(1)
232 222 except:
233 223 log.error(traceback.format_exc())
234 224 raise
235 225
236 226 return repo_name
237 227
238 228 def __get_user(self, username):
239 229 return User.get_by_username(username)
240 230
241 231 def __get_action(self, environ):
242 """
243 Maps git request commands into a pull or push command.
232 """Maps git request commands into a pull or push command.
244 233
245 234 :param environ:
246 235 """
247 236 service = environ['QUERY_STRING'].split('=')
248 237 if len(service) > 1:
249 238 service_cmd = service[1]
250 239 mapping = {
251 240 'git-receive-pack': 'push',
252 241 'git-upload-pack': 'pull',
253 242 }
254 243
255 244 return mapping.get(service_cmd,
256 245 service_cmd if service_cmd else 'other')
257 246 else:
258 247 return 'other'
General Comments 0
You need to be logged in to leave comments. Login now