fix inconsistent naming again
This commit is contained in:
parent
744a320731
commit
df45797b4a
|
@ -20,8 +20,8 @@
|
||||||
<li class="{% is_active 'passbook_admin:factors' 'passbook_admin:factor-create' 'passbook_admin:factor-update' 'passbook_admin:factor-delete' %}">
|
<li class="{% is_active 'passbook_admin:factors' 'passbook_admin:factor-create' 'passbook_admin:factor-update' 'passbook_admin:factor-delete' %}">
|
||||||
<a href="{% url 'passbook_admin:factors' %}">{% trans 'Factors' %}</a>
|
<a href="{% url 'passbook_admin:factors' %}">{% trans 'Factors' %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="{% is_active 'passbook_admin:policys' 'passbook_admin:policy-create' 'passbook_admin:policy-update' 'passbook_admin:policy-delete' 'passbook_admin:policy-test' %}">
|
<li class="{% is_active 'passbook_admin:policies' 'passbook_admin:policy-create' 'passbook_admin:policy-update' 'passbook_admin:policy-delete' 'passbook_admin:policy-test' %}">
|
||||||
<a href="{% url 'passbook_admin:policys' %}">{% trans 'Policies' %}</a>
|
<a href="{% url 'passbook_admin:policies' %}">{% trans 'Policies' %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="{% is_active 'passbook_admin:invitations' 'passbook_admin:invitation-create' 'passbook_admin:invitation-update' 'passbook_admin:invitation-delete' 'passbook_admin:invitation-test' %}">
|
<li class="{% is_active 'passbook_admin:invitations' 'passbook_admin:invitation-create' 'passbook_admin:invitation-update' 'passbook_admin:invitation-delete' 'passbook_admin:invitation-test' %}">
|
||||||
<a href="{% url 'passbook_admin:invitations' %}">{% trans 'Invitations' %}</a>
|
<a href="{% url 'passbook_admin:invitations' %}">{% trans 'Invitations' %}</a>
|
||||||
|
|
|
@ -15,7 +15,7 @@ from passbook.lib.utils.reflection import path_to_class
|
||||||
|
|
||||||
|
|
||||||
class PolicyListView(AdminRequiredMixin, ListView):
|
class PolicyListView(AdminRequiredMixin, ListView):
|
||||||
"""Show list of all policys"""
|
"""Show list of all policies"""
|
||||||
|
|
||||||
model = Policy
|
model = Policy
|
||||||
template_name = 'administration/policy/list.html'
|
template_name = 'administration/policy/list.html'
|
||||||
|
@ -33,7 +33,7 @@ class PolicyCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
||||||
"""Create new Policy"""
|
"""Create new Policy"""
|
||||||
|
|
||||||
template_name = 'generic/create_inheritance.html'
|
template_name = 'generic/create_inheritance.html'
|
||||||
success_url = reverse_lazy('passbook_admin:policys')
|
success_url = reverse_lazy('passbook_admin:policies')
|
||||||
success_message = _('Successfully created Policy')
|
success_message = _('Successfully created Policy')
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
|
@ -50,7 +50,7 @@ class PolicyUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
|
||||||
|
|
||||||
model = Policy
|
model = Policy
|
||||||
template_name = 'generic/update.html'
|
template_name = 'generic/update.html'
|
||||||
success_url = reverse_lazy('passbook_admin:policys')
|
success_url = reverse_lazy('passbook_admin:policies')
|
||||||
success_message = _('Successfully updated Policy')
|
success_message = _('Successfully updated Policy')
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
|
@ -67,7 +67,7 @@ class PolicyDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
|
||||||
|
|
||||||
model = Policy
|
model = Policy
|
||||||
template_name = 'generic/delete.html'
|
template_name = 'generic/delete.html'
|
||||||
success_url = reverse_lazy('passbook_admin:policys')
|
success_url = reverse_lazy('passbook_admin:policies')
|
||||||
success_message = _('Successfully updated Policy')
|
success_message = _('Successfully updated Policy')
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
|
|
|
@ -54,11 +54,13 @@ class AuthenticationView(UserPassesTestMixin, View):
|
||||||
self.pending_factors = []
|
self.pending_factors = []
|
||||||
for factor in _all_factors:
|
for factor in _all_factors:
|
||||||
if factor.passes(self.pending_user):
|
if factor.passes(self.pending_user):
|
||||||
self.pending_factors.append(_all_factors)
|
self.pending_factors.append(factor.type)
|
||||||
# self.pending_factors = Factor
|
|
||||||
# Read and instantiate factor from session
|
# Read and instantiate factor from session
|
||||||
factor_class = None
|
factor_class = None
|
||||||
if AuthenticationView.SESSION_FACTOR not in request.session:
|
if AuthenticationView.SESSION_FACTOR not in request.session:
|
||||||
|
# Case when no factors apply to user, return error denied
|
||||||
|
if not self.pending_factors:
|
||||||
|
return self.user_invalid()
|
||||||
factor_class = self.pending_factors[0]
|
factor_class = self.pending_factors[0]
|
||||||
else:
|
else:
|
||||||
factor_class = request.session[AuthenticationView.SESSION_FACTOR]
|
factor_class = request.session[AuthenticationView.SESSION_FACTOR]
|
||||||
|
@ -110,6 +112,7 @@ class AuthenticationView(UserPassesTestMixin, View):
|
||||||
LOGGER.debug("Logged in user %s", self.pending_user)
|
LOGGER.debug("Logged in user %s", self.pending_user)
|
||||||
# Cleanup
|
# Cleanup
|
||||||
self._cleanup()
|
self._cleanup()
|
||||||
|
# TODO: ?next=...
|
||||||
return redirect(reverse('passbook_core:overview'))
|
return redirect(reverse('passbook_core:overview'))
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
|
|
29
passbook/core/migrations/0002_auto_20190216_1002.py
Normal file
29
passbook/core/migrations/0002_auto_20190216_1002.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# Generated by Django 2.1.7 on 2019-02-16 10:02
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('passbook_core', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='debugpolicy',
|
||||||
|
options={'verbose_name': 'Debug Policy', 'verbose_name_plural': 'Debug Policies'},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='fieldmatcherpolicy',
|
||||||
|
options={'verbose_name': 'Field matcher Policy', 'verbose_name_plural': 'Field matcher Policies'},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='passwordpolicypolicy',
|
||||||
|
options={'verbose_name': 'Password Policy Policy', 'verbose_name_plural': 'Password Policy Policies'},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='webhookpolicy',
|
||||||
|
options={'verbose_name': 'Webhook Policy', 'verbose_name_plural': 'Webhook Policies'},
|
||||||
|
),
|
||||||
|
]
|
17
passbook/core/migrations/0003_auto_20190216_1004.py
Normal file
17
passbook/core/migrations/0003_auto_20190216_1004.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 2.1.7 on 2019-02-16 10:04
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('passbook_core', '0002_auto_20190216_1002'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name='PasswordPolicyPolicy',
|
||||||
|
new_name='PasswordPolicy',
|
||||||
|
),
|
||||||
|
]
|
|
@ -56,7 +56,7 @@ class PolicyModel(UUIDModel, CreatedUpdatedModel):
|
||||||
|
|
||||||
def passes(self, user: User) -> bool:
|
def passes(self, user: User) -> bool:
|
||||||
"""Return true if user passes, otherwise False or raise Exception"""
|
"""Return true if user passes, otherwise False or raise Exception"""
|
||||||
for policy in self.policies:
|
for policy in self.policies.all():
|
||||||
if not policy.passes(user):
|
if not policy.passes(user):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -130,7 +130,7 @@ class UserSourceConnection(CreatedUpdatedModel):
|
||||||
unique_together = (('user', 'source'),)
|
unique_together = (('user', 'source'),)
|
||||||
|
|
||||||
class Policy(UUIDModel, CreatedUpdatedModel):
|
class Policy(UUIDModel, CreatedUpdatedModel):
|
||||||
"""Policys which specify if a user is authorized to use an Application. Can be overridden by
|
"""Policies which specify if a user is authorized to use an Application. Can be overridden by
|
||||||
other types to add other fields, more logic, etc."""
|
other types to add other fields, more logic, etc."""
|
||||||
|
|
||||||
ACTION_ALLOW = 'allow'
|
ACTION_ALLOW = 'allow'
|
||||||
|
@ -222,9 +222,9 @@ class FieldMatcherPolicy(Policy):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
verbose_name = _('Field matcher Policy')
|
verbose_name = _('Field matcher Policy')
|
||||||
verbose_name_plural = _('Field matcher Policys')
|
verbose_name_plural = _('Field matcher Policies')
|
||||||
|
|
||||||
class PasswordPolicyPolicy(Policy):
|
class PasswordPolicy(Policy):
|
||||||
"""Policy to make sure passwords have certain properties"""
|
"""Policy to make sure passwords have certain properties"""
|
||||||
|
|
||||||
amount_uppercase = models.IntegerField(default=0)
|
amount_uppercase = models.IntegerField(default=0)
|
||||||
|
@ -233,7 +233,7 @@ class PasswordPolicyPolicy(Policy):
|
||||||
length_min = models.IntegerField(default=0)
|
length_min = models.IntegerField(default=0)
|
||||||
symbol_charset = models.TextField(default=r"!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ")
|
symbol_charset = models.TextField(default=r"!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ")
|
||||||
|
|
||||||
form = 'passbook.core.forms.policies.PasswordPolicyPolicyForm'
|
form = 'passbook.core.forms.policies.PasswordPolicyForm'
|
||||||
|
|
||||||
def passes(self, user: User) -> bool:
|
def passes(self, user: User) -> bool:
|
||||||
# Only check if password is being set
|
# Only check if password is being set
|
||||||
|
@ -254,8 +254,8 @@ class PasswordPolicyPolicy(Policy):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
verbose_name = _('Password Policy Policy')
|
verbose_name = _('Password Policy')
|
||||||
verbose_name_plural = _('Password Policy Policys')
|
verbose_name_plural = _('Password Policies')
|
||||||
|
|
||||||
|
|
||||||
class WebhookPolicy(Policy):
|
class WebhookPolicy(Policy):
|
||||||
|
@ -291,7 +291,7 @@ class WebhookPolicy(Policy):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
verbose_name = _('Webhook Policy')
|
verbose_name = _('Webhook Policy')
|
||||||
verbose_name_plural = _('Webhook Policys')
|
verbose_name_plural = _('Webhook Policies')
|
||||||
|
|
||||||
class DebugPolicy(Policy):
|
class DebugPolicy(Policy):
|
||||||
"""Policy used for debugging the PolicyEngine. Returns a fixed result,
|
"""Policy used for debugging the PolicyEngine. Returns a fixed result,
|
||||||
|
@ -313,7 +313,7 @@ class DebugPolicy(Policy):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
verbose_name = _('Debug Policy')
|
verbose_name = _('Debug Policy')
|
||||||
verbose_name_plural = _('Debug Policys')
|
verbose_name_plural = _('Debug Policies')
|
||||||
|
|
||||||
class Invitation(UUIDModel):
|
class Invitation(UUIDModel):
|
||||||
"""Single-use invitation link"""
|
"""Single-use invitation link"""
|
||||||
|
|
Reference in a new issue