@@ -53,27 +53,33 @@ class SummaryController(BaseController):
def index(self):
hg_model = HgModel()
c.repo_info = hg_model.get_repo(c.repo_name)
def url_generator(**kw):
return url('shortlog_home', repo_name=c.repo_name, **kw)
c.repo_changesets = Page(c.repo_info, page=1, items_per_page=10,
url=url_generator)
e = request.environ
uri = u'%(protocol)s://%(user)s@%(host)s%(prefix)s/%(repo_name)s' % {
if self.rhodecode_user.username == 'default':
password = ':default'
else:
password = ''
uri = u'%(protocol)s://%(user)s%(password)s@%(host)s%(prefix)s/%(repo_name)s' % {
'protocol': e.get('wsgi.url_scheme'),
'user':str(c.rhodecode_user.username),
'password':password,
'host':e.get('HTTP_HOST'),
'prefix':e.get('SCRIPT_NAME'),
'repo_name':c.repo_name, }
c.clone_repo_url = uri
c.repo_tags = OrderedDict()
for name, hash in c.repo_info.tags.items()[:10]:
try:
c.repo_tags[name] = c.repo_info.get_changeset(hash)
except ChangesetError:
c.repo_tags[name] = EmptyChangeset(hash)
c.repo_branches = OrderedDict()
@@ -68,25 +68,30 @@ def get_crypt_password(password):
:param password: password to hash
"""
return bcrypt.hashpw(password, bcrypt.gensalt(10))
def check_password(password, hashed):
return bcrypt.hashpw(password, hashed) == hashed
def authfunc(environ, username, password):
user = UserModel().get_by_username(username, cache=False)
if user:
if user.active:
if user.username == username and check_password(password, user.password):
if user.username == 'default' and user.active:
log.info('user %s authenticated correctly', username)
return True
elif user.username == username and check_password(password, user.password):
log.error('user %s is disabled', username)
return False
class AuthUser(object):
A simple object that handles a mercurial username for authentication
def __init__(self):
@@ -37,25 +37,25 @@ from rhodecode.model.user import UserMod
from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
import logging
import os
import traceback
log = logging.getLogger(__name__)
class SimpleHg(object):
def __init__(self, application, config):
self.application = application
self.config = config
#authenticate this mercurial request using
#authenticate this mercurial request using authfunc
self.authenticate = AuthBasicAuthenticator('', authfunc)
self.ipaddr = '0.0.0.0'
self.repository = None
self.username = None
self.action = None
def __call__(self, environ, start_response):
if not is_mercurial(environ):
return self.application(environ, start_response)
proxy_key = 'HTTP_X_REAL_IP'
def_key = 'REMOTE_ADDR'
Status change: