django - 跳过 Graphql 查询的 DRF 身份验证
问题描述
我正在尝试在我的 Django 项目中的 GraphQl api 上添加我现有的身份验证。我做了以下事情:
class DRFAuthenticatedGraphQLView(GraphQLView):
@classmethod
def as_view(cls, *args, **kwargs):
view = super(DRFAuthenticatedGraphQLView, cls).as_view(*args, **kwargs)
view = permission_classes((IsAuthenticated,))(view)
view = authentication_classes((TokenAuthentication, ))(view)
view = api_view(['POST','GET'])(view)
return view
urlpatterns = [
path('graphql', csrf_exempt(DRFAuthenticatedGraphQLView.as_view(graphiql=True)))
]
这将对 GraphQl 的所有突变和查询应用身份验证检查。
我希望 1 个查询没有身份验证检查。如何跳过该查询?
解决方案
推荐阅读
- ios - 点击时 SwiftUI 按钮不灰显
- ssl - 让我们在 ECS Fargate 上使用 traefick 加密 SSL
- c# - 与 Identity Server 集成的 ASP.NET Core Razor 页面
- java - JSP、HTML 和 Servlet
- r - mutate 和 d recode 的语法
- java - okta oauth2 Spring security 所有受保护的页面重定向到登录
- azure - Azure 机器学习实验无法将 Blob 存储装载到计算群集
- typescript - 类在 typecirpt 中实现接口
- c# - .NET CORE Worker Service 不会读取控制器
- c# - 如何在产品 ASP.NET 上应用正确的折扣