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' %}">
|
||||
<a href="{% url 'passbook_admin:factors' %}">{% trans 'Factors' %}</a>
|
||||
</li>
|
||||
<li class="{% is_active 'passbook_admin:policys' '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>
|
||||
<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:policies' %}">{% trans 'Policies' %}</a>
|
||||
</li>
|
||||
<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>
|
||||
|
|
|
@ -15,7 +15,7 @@ from passbook.lib.utils.reflection import path_to_class
|
|||
|
||||
|
||||
class PolicyListView(AdminRequiredMixin, ListView):
|
||||
"""Show list of all policys"""
|
||||
"""Show list of all policies"""
|
||||
|
||||
model = Policy
|
||||
template_name = 'administration/policy/list.html'
|
||||
|
@ -33,7 +33,7 @@ class PolicyCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
|||
"""Create new Policy"""
|
||||
|
||||
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')
|
||||
|
||||
def get_form_class(self):
|
||||
|
@ -50,7 +50,7 @@ class PolicyUpdateView(SuccessMessageMixin, AdminRequiredMixin, UpdateView):
|
|||
|
||||
model = Policy
|
||||
template_name = 'generic/update.html'
|
||||
success_url = reverse_lazy('passbook_admin:policys')
|
||||
success_url = reverse_lazy('passbook_admin:policies')
|
||||
success_message = _('Successfully updated Policy')
|
||||
|
||||
def get_form_class(self):
|
||||
|
@ -67,7 +67,7 @@ class PolicyDeleteView(SuccessMessageMixin, AdminRequiredMixin, DeleteView):
|
|||
|
||||
model = Policy
|
||||
template_name = 'generic/delete.html'
|
||||
success_url = reverse_lazy('passbook_admin:policys')
|
||||
success_url = reverse_lazy('passbook_admin:policies')
|
||||
success_message = _('Successfully updated Policy')
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
|
|
|
@ -54,11 +54,13 @@ class AuthenticationView(UserPassesTestMixin, View):
|
|||
self.pending_factors = []
|
||||
for factor in _all_factors:
|
||||
if factor.passes(self.pending_user):
|
||||
self.pending_factors.append(_all_factors)
|
||||
# self.pending_factors = Factor
|
||||
self.pending_factors.append(factor.type)
|
||||
# Read and instantiate factor from session
|
||||
factor_class = None
|
||||
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]
|
||||
else:
|
||||
factor_class = request.session[AuthenticationView.SESSION_FACTOR]
|
||||
|
@ -110,6 +112,7 @@ class AuthenticationView(UserPassesTestMixin, View):
|
|||
LOGGER.debug("Logged in user %s", self.pending_user)
|
||||
# Cleanup
|
||||
self._cleanup()
|
||||
# TODO: ?next=...
|
||||
return redirect(reverse('passbook_core:overview'))
|
||||
|
||||
def _cleanup(self):
|
||||
|
|
|
@ -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'},
|
||||
),
|
||||
]
|
|
@ -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:
|
||||
"""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):
|
||||
return False
|
||||
return True
|
||||
|
@ -130,7 +130,7 @@ class UserSourceConnection(CreatedUpdatedModel):
|
|||
unique_together = (('user', 'source'),)
|
||||
|
||||
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."""
|
||||
|
||||
ACTION_ALLOW = 'allow'
|
||||
|
@ -222,9 +222,9 @@ class FieldMatcherPolicy(Policy):
|
|||
class Meta:
|
||||
|
||||
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"""
|
||||
|
||||
amount_uppercase = models.IntegerField(default=0)
|
||||
|
@ -233,7 +233,7 @@ class PasswordPolicyPolicy(Policy):
|
|||
length_min = models.IntegerField(default=0)
|
||||
symbol_charset = models.TextField(default=r"!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ")
|
||||
|
||||
form = 'passbook.core.forms.policies.PasswordPolicyPolicyForm'
|
||||
form = 'passbook.core.forms.policies.PasswordPolicyForm'
|
||||
|
||||
def passes(self, user: User) -> bool:
|
||||
# Only check if password is being set
|
||||
|
@ -254,8 +254,8 @@ class PasswordPolicyPolicy(Policy):
|
|||
|
||||
class Meta:
|
||||
|
||||
verbose_name = _('Password Policy Policy')
|
||||
verbose_name_plural = _('Password Policy Policys')
|
||||
verbose_name = _('Password Policy')
|
||||
verbose_name_plural = _('Password Policies')
|
||||
|
||||
|
||||
class WebhookPolicy(Policy):
|
||||
|
@ -291,7 +291,7 @@ class WebhookPolicy(Policy):
|
|||
class Meta:
|
||||
|
||||
verbose_name = _('Webhook Policy')
|
||||
verbose_name_plural = _('Webhook Policys')
|
||||
verbose_name_plural = _('Webhook Policies')
|
||||
|
||||
class DebugPolicy(Policy):
|
||||
"""Policy used for debugging the PolicyEngine. Returns a fixed result,
|
||||
|
@ -313,7 +313,7 @@ class DebugPolicy(Policy):
|
|||
class Meta:
|
||||
|
||||
verbose_name = _('Debug Policy')
|
||||
verbose_name_plural = _('Debug Policys')
|
||||
verbose_name_plural = _('Debug Policies')
|
||||
|
||||
class Invitation(UUIDModel):
|
||||
"""Single-use invitation link"""
|
||||
|
|
Reference in New Issue