environ['GIT_PATH_INFO'] = get_git_path_info(path_info) if environ.get('REMOTE_USER') is None: result = self.authenticate(environ) if not isinstance(result, str): # Request credentials if authentication fails return result(environ, start_response) environ['REMOTE_USER'] = result environ['AUTH_TYPE'] = self.scheme return self.application(environ, start_response) class WebRedirect(object): def __init__(self, application, **kw): self.application = application def __call__(self, environ, start_response): http_accept = environ.get('HTTP_ACCEPT') path_info = environ.get('PATH_INFO') proj_name = get_proj(path_info) if http_accept and 'text/html' in http_accept: start_response('301 Redirect', [ ('Location', '/%s/' % proj_name), ]) return [] return self.application(environ, start_response) app = assemble_WSGI_git_app(content_path=get_repo_root()) app = WebRedirect(app) app = HTTPAuth(app, DOUBAN_REALM, authfunc, BasicAuth)
def repo_path(self): return os.path.join(get_repo_root(), '%s.git' % self.id)
path_info = environ['PATH_INFO'] environ['GIT_PATH_INFO'] = get_git_path_info(path_info) if environ.get('REMOTE_USER') is None: result = self.authenticate(environ) if not isinstance(result, str): # Request credentials if authentication fails return result(environ, start_response) environ['REMOTE_USER'] = result environ['AUTH_TYPE'] = self.scheme return self.application(environ, start_response) class WebRedirect(object): def __init__(self, application, **kw): self.application = application def __call__(self, environ, start_response): http_accept = environ.get('HTTP_ACCEPT') path_info = environ.get('PATH_INFO') proj_name = get_proj(path_info) if http_accept and 'text/html' in http_accept: start_response('301 Redirect', [('Location', '/%s/' % proj_name), ]) return [] return self.application(environ, start_response) app = assemble_WSGI_git_app(content_path=get_repo_root()) app = WebRedirect(app) app = HTTPAuth(app, DOUBAN_REALM, authfunc, BasicAuth)