# HG changeset patch # User Marcin Kuzminski # Date 2013-06-20 22:36:01 # Node ID c3245a0452a36e495414532d2a67a82274a53673 # Parent 4eaeae84f4747f52d6218a76fb2414a6fa1ceb7d Added --no-public-access / --public-access flags into setup-rhodecode command to enable setup without public access diff --git a/rhodecode/lib/db_manage.py b/rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py +++ b/rhodecode/lib/db_manage.py @@ -696,10 +696,18 @@ class DbManage(object): def create_default_user(self): log.info('creating default user') # create default user for handling default permissions. - UserModel().create_or_update(username='default', - password=str(uuid.uuid1())[:8], - email='anonymous@rhodecode.org', - firstname='Anonymous', lastname='User') + user = UserModel().create_or_update(username=User.DEFAULT_USER, + password=str(uuid.uuid1())[:20], + email='anonymous@rhodecode.org', + firstname='Anonymous', + lastname='User') + # based on configuration options activate/deactive this user which + # controlls anonymous access + if self.cli_args.get('public_access') is False: + log.info('Public access disabled') + user.active = False + Session().add(user) + Session().commit() def create_permissions(self): """ diff --git a/rhodecode/lib/paster_commands/setup_rhodecode.py b/rhodecode/lib/paster_commands/setup_rhodecode.py --- a/rhodecode/lib/paster_commands/setup_rhodecode.py +++ b/rhodecode/lib/paster_commands/setup_rhodecode.py @@ -64,7 +64,16 @@ class Command(AbstractInstallCommand): dest='force_ask', default=None, help='Force no to every question') - + parser.add_option('--public-access', + action='store_true', + dest='public_access', + default=None, + help='Enable public access on this installation (default)') + parser.add_option('--no-public-access', + action='store_false', + dest='public_access', + default=None, + help='Disable public access on this installation ') def command(self): config_spec = self.args[0] section = self.options.section_name diff --git a/rhodecode/tests/scripts/create_rc.sh b/rhodecode/tests/scripts/create_rc.sh --- a/rhodecode/tests/scripts/create_rc.sh +++ b/rhodecode/tests/scripts/create_rc.sh @@ -1,6 +1,6 @@ psql -U postgres -h localhost -c 'drop database if exists rhodecode;' psql -U postgres -h localhost -c 'create database rhodecode;' -paster setup-rhodecode rc.ini --force-yes --user=marcink --password=qweqwe --email=marcin@python-blog.com --repos=/home/marcink/repos +paster setup-rhodecode rc.ini --force-yes --user=marcink --password=qweqwe --email=marcin@python-blog.com --repos=/home/marcink/repos --no-public-access API_KEY=`psql -R " " -A -U postgres -h localhost -c "select api_key from users where admin=TRUE" -d rhodecode | awk '{print $2}'` echo "run those after running server" paster serve rc.ini --pid-file=rc.pid --daemon