Merge branch 'master' into ldap-rewrite

This commit is contained in:
Langhammer, Jens 2019-10-11 12:53:56 +02:00
commit e972f2b289
8 changed files with 46 additions and 7 deletions

View File

@ -11,7 +11,7 @@ class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ['username', 'name', 'email', 'is_staff', 'is_active']
fields = ['username', 'name', 'email', 'is_staff', 'is_active', 'attributes']
widgets = {
'name': forms.TextInput
}

View File

@ -60,7 +60,8 @@ class AuditEntry(UUIDModel):
# User 255.255.255.255 as fallback if IP cannot be determined
request_ip=client_ip or '255.255.255.255',
context=kwargs)
LOGGER.debug("Logged %s from %s (%s)", action, user, client_ip)
LOGGER.debug("Created Audit entry", action=action,
user=user, from_ip=client_ip, context=kwargs)
return entry
def save(self, *args, **kwargs):

View File

@ -26,7 +26,7 @@ class GroupForm(forms.ModelForm):
class Meta:
model = Group
fields = ['name', 'parent', 'members', 'tags']
fields = ['name', 'parent', 'members', 'attributes']
widgets = {
'name': forms.TextInput(),
}

View File

@ -0,0 +1,29 @@
# Generated by Django 2.2.6 on 2019-10-11 09:14
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passbook_core', '0002_nonce_description'),
]
operations = [
migrations.RenameField(
model_name='group',
old_name='tags',
new_name='attributes',
),
migrations.AddField(
model_name='source',
name='property_mappings',
field=models.ManyToManyField(blank=True, default=None, to='passbook_core.PropertyMapping'),
),
migrations.AddField(
model_name='user',
name='attributes',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict),
),
]

View File

@ -32,7 +32,7 @@ class Group(UUIDModel):
name = models.CharField(_('name'), max_length=80)
parent = models.ForeignKey('Group', blank=True, null=True,
on_delete=models.SET_NULL, related_name='children')
tags = JSONField(default=dict, blank=True)
attributes = JSONField(default=dict, blank=True)
def __str__(self):
return f"Group {self.name}"
@ -51,6 +51,8 @@ class User(AbstractUser):
groups = models.ManyToManyField('Group')
password_change_date = models.DateTimeField(auto_now_add=True)
attributes = JSONField(default=dict, blank=True)
def set_password(self, password):
if self.pk:
password_changed.send(sender=self, user=self, password=password)
@ -143,6 +145,7 @@ class Source(PolicyModel):
name = models.TextField()
slug = models.SlugField()
enabled = models.BooleanField(default=True)
property_mappings = models.ManyToManyField('PropertyMapping', default=None, blank=True)
form = '' # ModelForm-based class ued to create/edit instance

View File

@ -30,7 +30,7 @@ def authenticate(request, backends, **credentials) -> Optional[User]:
signature = Signature.from_callable(backend.authenticate)
signature.bind(request, **credentials)
except TypeError:
LOGGER.debug("Backend doesn't accept our arguments", backend=backend)
LOGGER.warning("Backend doesn't accept our arguments", backend=backend)
# This backend doesn't accept these credentials as arguments. Try the next one.
continue
LOGGER.debug('Attempting authentication...', backend=backend)

View File

@ -134,7 +134,7 @@ class AuthenticationView(UserPassesTestMixin, View):
LOGGER.debug("Rendering Factor", next_factor=next_factor)
return _redirect_with_qs('passbook_core:auth-process', self.request.GET)
# User passed all factors
LOGGER.debug("User passed all factors, logging in")
LOGGER.debug("User passed all factors, logging in", user=self.pending_user)
return self._user_passed()
def user_invalid(self):

View File

@ -307,7 +307,12 @@ if any('test' in arg for arg in sys.argv):
CELERY_TASK_ALWAYS_EAGER = True
_DISALLOWED_ITEMS = ['INSTALLED_APPS', 'MIDDLEWARE', 'AUTHENTICATION_BACKENDS']
_DISALLOWED_ITEMS = [
'INSTALLED_APPS',
'MIDDLEWARE',
'AUTHENTICATION_BACKENDS',
'CELERY_BEAT_SCHEDULE'
]
# Load subapps's INSTALLED_APPS
for _app in INSTALLED_APPS:
if _app.startswith('passbook'):
@ -318,6 +323,7 @@ for _app in INSTALLED_APPS:
INSTALLED_APPS.extend(getattr(app_settings, 'INSTALLED_APPS', []))
MIDDLEWARE.extend(getattr(app_settings, 'MIDDLEWARE', []))
AUTHENTICATION_BACKENDS.extend(getattr(app_settings, 'AUTHENTICATION_BACKENDS', []))
CELERY_BEAT_SCHEDULE.update(getattr(app_settings, 'CELERY_BEAT_SCHEDULE', {}))
for _attr in dir(app_settings):
if not _attr.startswith('__') and _attr not in _DISALLOWED_ITEMS:
globals()[_attr] = getattr(app_settings, _attr)