Перейти к основному контенту

GraphQL Middlewares

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',
поля: {
body: {
type: GraphQLString,
решить: (пост, арги, контекста, { rootValue }) => {
return postRepository. etBody(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:)

СреднееGraphQL реализацияАвторОписание
график-авторграфикаCasbinПолная авторизация middleware для graphql-go
graphql-casbinграфика@esmaeilpourAn implementation of using Graphql and Casbin together
пример gqlgencasbin_RBACgqlgen@WenyXu(пустой)