diff --git a/passbook/captcha_factor/settings.py b/passbook/captcha_factor/settings.py index cfc90dc45..0b888f511 100644 --- a/passbook/captcha_factor/settings.py +++ b/passbook/captcha_factor/settings.py @@ -5,3 +5,4 @@ NOCAPTCHA = True INSTALLED_APPS = [ 'captcha' ] +SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error'] diff --git a/passbook/core/management/__init__.py b/passbook/core/management/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/passbook/core/management/commands/__init__.py b/passbook/core/management/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/passbook/core/management/commands/web.py b/passbook/core/management/commands/web.py new file mode 100644 index 000000000..da8c66879 --- /dev/null +++ b/passbook/core/management/commands/web.py @@ -0,0 +1,34 @@ +"""passbook Webserver management command""" + +from logging import getLogger + +import cherrypy +from django.conf import settings +from django.core.management.base import BaseCommand + +from passbook.core.wsgi import application + +LOGGER = getLogger(__name__) + + +class Command(BaseCommand): + """Run CherryPy webserver""" + + def handle(self, *args, **options): + """passbook cherrypy server""" + config = settings.CHERRYPY_SERVER + config.update(**options) + cherrypy.config.update(config) + cherrypy.tree.graft(application, '/') + # Mount NullObject to serve static files + cherrypy.tree.mount(None, '/static', config={ + '/': { + 'tools.staticdir.on': True, + 'tools.staticdir.dir': settings.STATIC_ROOT, + 'tools.expires.on': True, + 'tools.expires.secs': 86400, + 'tools.gzip.on': True, + } + }) + cherrypy.engine.start() + cherrypy.engine.block() diff --git a/passbook/core/management/commands/worker.py b/passbook/core/management/commands/worker.py new file mode 100644 index 000000000..446d32eaa --- /dev/null +++ b/passbook/core/management/commands/worker.py @@ -0,0 +1,17 @@ +"""passbook Worker management command""" + +from logging import getLogger + +from django.core.management.base import BaseCommand + +from passbook.core.celery import CELERY_APP + +LOGGER = getLogger(__name__) + + +class Command(BaseCommand): + """Run Celery Worker""" + + def handle(self, *args, **options): + """celery worker""" + CELERY_APP.worker_main(['worker', '--autoscale=10,3', '-E']) diff --git a/passbook/core/migrations/0001_initial.py b/passbook/core/migrations/0001_initial.py index 9f3b0b662..5f9c05129 100644 --- a/passbook/core/migrations/0001_initial.py +++ b/passbook/core/migrations/0001_initial.py @@ -1,13 +1,12 @@ -# Generated by Django 2.1.4 on 2018-12-10 09:15 - -import uuid +# Generated by Django 2.1.5 on 2019-02-08 10:42 +from django.conf import settings import django.contrib.auth.models import django.contrib.auth.validators +from django.db import migrations, models import django.db.models.deletion import django.utils.timezone -from django.conf import settings -from django.db import migrations, models +import uuid class Migration(migrations.Migration): @@ -34,8 +33,6 @@ class Migration(migrations.Migration): ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('uuid', models.UUIDField(default=uuid.uuid4, editable=False)), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], options={ 'verbose_name': 'user', @@ -46,6 +43,29 @@ class Migration(migrations.Migration): ('objects', django.contrib.auth.models.UserManager()), ], ), + migrations.CreateModel( + name='Group', + fields=[ + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('name', models.CharField(max_length=80, verbose_name='name')), + ('extra_data', models.TextField(blank=True)), + ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='children', to='passbook_core.Group')), + ], + ), + migrations.CreateModel( + name='Invitation', + fields=[ + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('expires', models.DateTimeField(blank=True, default=None, null=True)), + ('fixed_username', models.TextField(blank=True, default=None)), + ('fixed_email', models.TextField(blank=True, default=None)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Invitation', + 'verbose_name_plural': 'Invitations', + }, + ), migrations.CreateModel( name='Provider', fields=[ @@ -92,6 +112,7 @@ class Migration(migrations.Migration): fields=[ ('rulemodel_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.RuleModel')), ('name', models.TextField()), + ('slug', models.SlugField()), ('launch_url', models.URLField(blank=True, null=True)), ('icon_url', models.TextField(blank=True, null=True)), ('skip_authorization', models.BooleanField(default=False)), @@ -120,7 +141,7 @@ class Migration(migrations.Migration): name='FieldMatcherRule', fields=[ ('rule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Rule')), - ('user_field', models.TextField()), + ('user_field', models.TextField(choices=[('username', 'username'), ('first_name', 'first_name'), ('last_name', 'last_name'), ('email', 'email'), ('is_staff', 'is_staff'), ('is_active', 'is_active'), ('data_joined', 'data_joined')])), ('match_action', models.CharField(choices=[('startswith', 'Starts with'), ('endswith', 'Ends with'), ('endswith', 'Contains'), ('regexp', 'Regexp'), ('exact', 'Exact')], max_length=50)), ('value', models.TextField()), ], @@ -165,11 +186,25 @@ class Migration(migrations.Migration): name='rules', field=models.ManyToManyField(blank=True, to='passbook_core.Rule'), ), + migrations.AddField( + model_name='user', + name='groups', + field=models.ManyToManyField(to='passbook_core.Group'), + ), + migrations.AddField( + model_name='user', + name='user_permissions', + field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'), + ), migrations.AddField( model_name='usersourceconnection', name='source', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='passbook_core.Source'), ), + migrations.AlterUniqueTogether( + name='group', + unique_together={('name', 'parent')}, + ), migrations.AddField( model_name='user', name='applications', diff --git a/passbook/core/migrations/0002_auto_20181210_1011.py b/passbook/core/migrations/0002_auto_20181210_1011.py deleted file mode 100644 index 176a4590b..000000000 --- a/passbook/core/migrations/0002_auto_20181210_1011.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-10 10:11 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='fieldmatcherrule', - name='user_field', - field=models.TextField(choices=[('username', 'username'), ('first_name', 'first_name'), ('last_name', 'last_name'), ('email', 'email'), ('is_staff', 'is_staff'), ('is_active', 'is_active'), ('data_joined', 'data_joined')]), - ), - ] diff --git a/passbook/core/migrations/0003_invite.py b/passbook/core/migrations/0003_invite.py deleted file mode 100644 index 5b18c87b2..000000000 --- a/passbook/core/migrations/0003_invite.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-10 12:13 - -import uuid - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0002_auto_20181210_1011'), - ] - - operations = [ - migrations.CreateModel( - name='Invitation', - fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('expires', models.DateTimeField(blank=True, default=None, null=True)), - ('fixed_username', models.TextField(blank=True, default=None)), - ('fixed_email', models.TextField(blank=True, default=None)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'verbose_name': 'Invitation', - 'verbose_name_plural': 'Invitations', - }, - ), - ] diff --git a/passbook/core/migrations/0004_application_slug.py b/passbook/core/migrations/0004_application_slug.py deleted file mode 100644 index a7ce4477d..000000000 --- a/passbook/core/migrations/0004_application_slug.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-26 15:52 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0003_invite'), - ] - - operations = [ - migrations.AddField( - model_name='application', - name='slug', - field=models.SlugField(default=''), - preserve_default=False, - ), - ] diff --git a/passbook/core/migrations/0005_auto_20181226_2115.py b/passbook/core/migrations/0005_auto_20181226_2115.py deleted file mode 100644 index 9e9b19067..000000000 --- a/passbook/core/migrations/0005_auto_20181226_2115.py +++ /dev/null @@ -1,35 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-26 21:15 - -import uuid - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('auth', '0009_alter_user_last_name_max_length'), - ('passbook_core', '0004_application_slug'), - ] - - operations = [ - migrations.CreateModel( - name='Group', - fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=80, verbose_name='name')), - ('parent_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='passbook_core.Group')), - ('permissions', models.ManyToManyField(blank=True, related_name='_group_permissions_+', to='auth.Permission')), - ], - ), - migrations.AlterField( - model_name='user', - name='groups', - field=models.ManyToManyField(to='passbook_core.Group'), - ), - migrations.AlterUniqueTogether( - name='group', - unique_together={('name', 'parent_group')}, - ), - ] diff --git a/passbook/core/migrations/0006_group_extra_data.py b/passbook/core/migrations/0006_group_extra_data.py deleted file mode 100644 index 7345bcc1c..000000000 --- a/passbook/core/migrations/0006_group_extra_data.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-26 21:32 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0005_auto_20181226_2115'), - ] - - operations = [ - migrations.AddField( - model_name='group', - name='extra_data', - field=models.TextField(blank=True), - ), - ] diff --git a/passbook/core/migrations/0007_auto_20181226_2142.py b/passbook/core/migrations/0007_auto_20181226_2142.py deleted file mode 100644 index 5fd764b35..000000000 --- a/passbook/core/migrations/0007_auto_20181226_2142.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-26 21:42 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0006_group_extra_data'), - ] - - operations = [ - migrations.AddField( - model_name='group', - name='children', - field=models.ManyToManyField(blank=True, to='passbook_core.Group'), - ), - migrations.AlterUniqueTogether( - name='group', - unique_together=set(), - ), - migrations.RemoveField( - model_name='group', - name='parent_group', - ), - migrations.RemoveField( - model_name='group', - name='permissions', - ), - ] diff --git a/passbook/core/migrations/0008_auto_20181226_2200.py b/passbook/core/migrations/0008_auto_20181226_2200.py deleted file mode 100644 index d820a3089..000000000 --- a/passbook/core/migrations/0008_auto_20181226_2200.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-26 22:00 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0007_auto_20181226_2142'), - ] - - operations = [ - migrations.AddField( - model_name='group', - name='parent', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='children', to='passbook_core.Group'), - ), - migrations.RemoveField( - model_name='group', - name='children', - ), - migrations.AlterUniqueTogether( - name='group', - unique_together={('name', 'parent')}, - ), - ] diff --git a/passbook/core/requirements.txt b/passbook/core/requirements.txt index c8d507efe..c3989e55a 100644 --- a/passbook/core/requirements.txt +++ b/passbook/core/requirements.txt @@ -10,3 +10,4 @@ celery redis<3.0 pymysql idna<2.8,>=2.5 +cherrypy diff --git a/passbook/core/settings.py b/passbook/core/settings.py index cbe6ea7c2..f36233b4e 100644 --- a/passbook/core/settings.py +++ b/passbook/core/settings.py @@ -31,9 +31,9 @@ STATIC_ROOT = BASE_DIR + '/static' SECRET_KEY = CONFIG.get('secret_key') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = CONFIG.get('debug') INTERNAL_IPS = ['127.0.0.1'] -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = CONFIG.get('domains') LOGIN_URL = 'passbook_core:auth-login' # CSRF_FAILURE_VIEW = 'passbook.core.views.errors.CSRFErrorView.as_view' @@ -189,6 +189,16 @@ CELERY_TASK_DEFAULT_QUEUE = 'passbook' CELERY_BROKER_URL = 'redis://%s' % CONFIG.get('redis') CELERY_RESULT_BACKEND = 'redis://%s' % CONFIG.get('redis') +# CherryPY settings +with CONFIG.cd('web'): + CHERRYPY_SERVER = { + 'server.socket_host': CONFIG.get('listen', '0.0.0.0'), # nosec + 'server.socket_port': CONFIG.get('port', 8000), + 'server.thread_pool': CONFIG.get('threads', 30), + 'log.screen': False, + 'log.access_file': '', + 'log.error_file': '', + } # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ diff --git a/passbook/core/templates/login/test.html b/passbook/core/templates/login/test.html new file mode 100644 index 000000000..9dc470f0c --- /dev/null +++ b/passbook/core/templates/login/test.html @@ -0,0 +1,131 @@ +{% load static %} + + + + + + + Login Social Account (two column) - Red Hat® Common User Experience + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + These examples are included for development testing purposes. For official documentation, see https://www.patternfly.org and http://getbootstrap.com. +
+
+ + +
+
+ +
+
+ + + + +
+
+
+ +
+
+ +
+ + + + + diff --git a/passbook/core/views/authentication.py b/passbook/core/views/authentication.py index f90361e84..e67986f04 100644 --- a/passbook/core/views/authentication.py +++ b/passbook/core/views/authentication.py @@ -44,7 +44,7 @@ class LoginView(UserPassesTestMixin, FormView): kwargs['show_password_forget_notice'] = CONFIG.y('passbook.password_reset.enabled') kwargs['sources'] = Source.objects.filter(enabled=True).select_subclasses() if any(source.is_link for source in kwargs['sources']): - self.template_name = 'login/with_sources.html' + self.template_name = 'login/test.html' return super().get_context_data(**kwargs) def get_user(self, uid_value) -> User: