This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2020-08-19 08:32:44 +00:00
|
|
|
"""OAuth2Provider API Views"""
|
|
|
|
from rest_framework.serializers import ModelSerializer
|
|
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
|
|
|
|
from passbook.providers.oauth2.models import OAuth2Provider, ScopeMapping
|
|
|
|
|
|
|
|
|
|
|
|
class OAuth2ProviderSerializer(ModelSerializer):
|
|
|
|
"""OAuth2Provider Serializer"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = OAuth2Provider
|
|
|
|
fields = [
|
|
|
|
"pk",
|
|
|
|
"name",
|
|
|
|
"authorization_flow",
|
|
|
|
"client_type",
|
|
|
|
"client_id",
|
|
|
|
"client_secret",
|
|
|
|
"response_type",
|
|
|
|
"jwt_alg",
|
|
|
|
"rsa_key",
|
|
|
|
"redirect_uris",
|
2020-09-15 18:54:42 +00:00
|
|
|
"sub_mode",
|
2020-08-19 08:32:44 +00:00
|
|
|
"property_mappings",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class OAuth2ProviderViewSet(ModelViewSet):
|
|
|
|
"""OAuth2Provider Viewset"""
|
|
|
|
|
|
|
|
queryset = OAuth2Provider.objects.all()
|
|
|
|
serializer_class = OAuth2ProviderSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class ScopeMappingSerializer(ModelSerializer):
|
|
|
|
"""ScopeMapping Serializer"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = ScopeMapping
|
|
|
|
fields = ["pk", "name", "scope_name", "description", "expression"]
|
|
|
|
|
|
|
|
|
|
|
|
class ScopeMappingViewSet(ModelViewSet):
|
|
|
|
"""ScopeMapping Viewset"""
|
|
|
|
|
|
|
|
queryset = ScopeMapping.objects.all()
|
|
|
|
serializer_class = ScopeMappingSerializer
|