88594075b2
* initial zxcvbn Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * add api and port tests Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * more tests Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * add ui Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * update docs Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * add api diff Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Password Policy API Views"""
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
from authentik.core.api.used_by import UsedByMixin
|
|
from authentik.policies.api.policies import PolicySerializer
|
|
from authentik.policies.password.models import PasswordPolicy
|
|
|
|
|
|
class PasswordPolicySerializer(PolicySerializer):
|
|
"""Password Policy Serializer"""
|
|
|
|
class Meta:
|
|
model = PasswordPolicy
|
|
fields = PolicySerializer.Meta.fields + [
|
|
"password_field",
|
|
"amount_digits",
|
|
"amount_uppercase",
|
|
"amount_lowercase",
|
|
"amount_symbols",
|
|
"length_min",
|
|
"symbol_charset",
|
|
"error_message",
|
|
"check_static_rules",
|
|
"check_have_i_been_pwned",
|
|
"check_zxcvbn",
|
|
"hibp_allowed_count",
|
|
"zxcvbn_score_threshold",
|
|
]
|
|
|
|
|
|
class PasswordPolicyViewSet(UsedByMixin, ModelViewSet):
|
|
"""Password Policy Viewset"""
|
|
|
|
queryset = PasswordPolicy.objects.all()
|
|
serializer_class = PasswordPolicySerializer
|
|
filterset_fields = "__all__"
|
|
ordering = ["name"]
|
|
search_fields = ["name"]
|