Graphql-中间件
Casbin follows the officially suggested way to provide authorization for GraphQL endpoints by having a single source of truth for authorization: https://graphql.org/learn/authorization/. In other words, Casbin should be placed between the GraphQL layer and your business logic.
// 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);
}
}
}
});
Supported GraphQL Middlewares
A complete list of Casbin GraphQL middlewares is provided below. Any third-party contributions on a new GraphQL middleware are welcomed. Please inform us, and we will add it to this list:)
- Go
- Node.js
- Python
中间件 | GraphQL 实现 | 作者 | 描述 |
---|---|---|---|
graphql-authz | graphql | Casbin | 用于graphql-go 的授权中间件 |
graphql-casbin | graphql | @esmaeilpour | An implementation of using Graphql and Casbin together |
gqlgen_casbin_RBAC_example | gqlgen | @WenyXu | (empty) |
中间件 | GraphQL 实现 | 作者 | 描述 |
---|---|---|---|
graphql-authz | GraphQL.js | Casbin | 一个用于 GraphQL.js 的授权中间件 |
中间件 | GraphQL 实现 | 作者 | 描述 |
---|---|---|---|
graphql-authz | GraphQL-core 3 | @Checho3388 | 一个用于 GraphQL.js 的授权中间件 |