46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""
|
|
GraphQL Views for Exchange API.
|
|
|
|
Authentication is handled by GRAPHENE MIDDLEWARE in settings.py
|
|
"""
|
|
from graphene_django.views import GraphQLView
|
|
|
|
from .graphql_middleware import (
|
|
M2MNoAuthMiddleware,
|
|
PublicNoAuthMiddleware,
|
|
TeamJWTMiddleware,
|
|
UserJWTMiddleware,
|
|
)
|
|
|
|
|
|
class PublicGraphQLView(GraphQLView):
|
|
"""Public endpoint - no authentication required."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
kwargs['middleware'] = [PublicNoAuthMiddleware()]
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
class UserGraphQLView(GraphQLView):
|
|
"""User endpoint - requires ID Token."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
kwargs['middleware'] = [UserJWTMiddleware()]
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
class TeamGraphQLView(GraphQLView):
|
|
"""Team endpoint - requires Organization Access Token."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
kwargs['middleware'] = [TeamJWTMiddleware()]
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
class M2MGraphQLView(GraphQLView):
|
|
"""M2M endpoint - internal services only."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
kwargs['middleware'] = [M2MNoAuthMiddleware()]
|
|
super().__init__(*args, **kwargs)
|