policies: add API for policybindings
This commit is contained in:
parent
fe503c8de0
commit
9859c5db0a
|
@ -18,6 +18,7 @@ from passbook.core.api.sources import SourceViewSet
|
|||
from passbook.core.api.users import UserViewSet
|
||||
from passbook.flows.api import FlowStageBindingViewSet, FlowViewSet, StageViewSet
|
||||
from passbook.lib.utils.reflection import get_apps
|
||||
from passbook.policies.api import PolicyBindingViewSet
|
||||
from passbook.policies.expiry.api import PasswordExpiryPolicyViewSet
|
||||
from passbook.policies.expression.api import ExpressionPolicyViewSet
|
||||
from passbook.policies.hibp.api import HaveIBeenPwendPolicyViewSet
|
||||
|
@ -62,6 +63,7 @@ router.register("sources/ldap", LDAPSourceViewSet)
|
|||
router.register("sources/oauth", OAuthSourceViewSet)
|
||||
|
||||
router.register("policies/all", PolicyViewSet)
|
||||
router.register("policies/bindings", PolicyBindingViewSet)
|
||||
router.register("policies/expression", ExpressionPolicyViewSet)
|
||||
router.register("policies/haveibeenpwned", HaveIBeenPwendPolicyViewSet)
|
||||
router.register("policies/password", PasswordPolicyViewSet)
|
||||
|
|
21
passbook/policies/api.py
Normal file
21
passbook/policies/api.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""policy API Views"""
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from passbook.policies.models import PolicyBinding
|
||||
|
||||
|
||||
class PolicyBindingSerializer(ModelSerializer):
|
||||
"""PolicyBinding Serializer"""
|
||||
|
||||
class Meta:
|
||||
|
||||
model = PolicyBinding
|
||||
fields = ["policy", "target", "enabled", "order"]
|
||||
|
||||
|
||||
class PolicyBindingViewSet(ModelViewSet):
|
||||
"""PolicyBinding Viewset"""
|
||||
|
||||
queryset = PolicyBinding.objects.all()
|
||||
serializer_class = PolicyBindingSerializer
|
|
@ -7,7 +7,7 @@ from passbook.lib.models import UUIDModel
|
|||
|
||||
|
||||
class PolicyBindingModel(models.Model):
|
||||
"""Base Model for objects which have Policies applied to them"""
|
||||
"""Base Model for objects that have policies applied to them."""
|
||||
|
||||
policies = models.ManyToManyField(
|
||||
Policy, through="PolicyBinding", related_name="+", blank=True
|
||||
|
|
Reference in a new issue