当前位置: 首页 > 文档资料 > Casbin 中文文档 >

Graphql 中间件

优质
小牛编辑
118浏览
2023-12-01

Cassbin采用官方建议的方式为GraphQL终点提供授权,方法是采用单一的授权来源:https://graphql.org/learn/authorization/ 换句话说,Casbin应该放置在 GraphQL 层和您的商业逻辑之间。

// Casbin 授权逻辑在 postRepository 中
var postRepository = require('postRepository');

var postType = new GraphQLObjectType({
  name: ‘Post’,
  fields: {
    body: {
      type: GraphQLString,
      resolve: (post, args, context, { rootValue }) => {
        return postRepository.getBody(context.user, post);
      }
    }
  }
});

支持的 GraphQL 中间件

下面提供了Casbin GraphQL 中间件的完整列表。 我们欢迎来自第三方的中间件,请通知我们以将您的中间件加入列表中:)

GoNode.js
中间件GraphQL 实现作者说明
graphql-authzgraphqlCasbin用于graphql-go 的授权中间件
graphql-casbingraphql@esmaeilpour使用 Graphql 和 Casbin 共同实现
gqlgen_casbin_RBAC_examplegqlgen@WenyXu(empty)
中间件GraphQL 实现作者说明
graphql-authzGraphQL.jsCasbin一个用于 GraphQL.js 的授权中间件
← 中间件Cloud Native Middlewares →