Files
edx-platform/common/djangoapps/third_party_auth/saml_configuration/views.py
edx-pipeline-bot afceb27231 fix: Make SAMLConfiguration viewset readonly (#247) (#30259)
The ony use is a GET request in admin portal so this view need not be post/put friendly right now.
It may actually get removed in an upcoming iteration, or stay readonly.

Fixes: SEC-1418

Co-authored-by: Binod Pant <bpant@edx.org>
2022-04-15 18:03:50 +00:00

32 lines
968 B
Python

"""
Viewset for auth/saml/v0/saml_configuration
"""
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
from rest_framework import permissions, viewsets
from rest_framework.authentication import SessionAuthentication
from ..models import SAMLConfiguration
from .serializers import SAMLConfigurationSerializer
class SAMLConfigurationMixin:
authentication_classes = (JwtAuthentication, SessionAuthentication,)
permission_classes = (permissions.IsAuthenticated,)
serializer_class = SAMLConfigurationSerializer
class SAMLConfigurationViewSet(SAMLConfigurationMixin, viewsets.ReadOnlyModelViewSet):
"""
A View to handle SAMLConfiguration GETs
Usage:
GET /auth/saml/v0/saml_configuration/
"""
def get_queryset(self):
"""
Find and return all saml configurations that are listed as public.
"""
return SAMLConfiguration.objects.current_set().filter(is_public=True)