https://github.com/casbin/graphql-authz
graphql-authz is an authorization middleware for graphql-go
https://github.com/casbin/graphql-authz
abac acl authorization casbin graphql middleware plugin rbac
Last synced: about 1 year ago
JSON representation
graphql-authz is an authorization middleware for graphql-go
- Host: GitHub
- URL: https://github.com/casbin/graphql-authz
- Owner: casbin
- License: apache-2.0
- Created: 2021-06-19T15:26:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-10T07:54:04.000Z (almost 5 years ago)
- Last Synced: 2024-10-29T12:34:14.260Z (over 1 year ago)
- Topics: abac, acl, authorization, casbin, graphql, middleware, plugin, rbac
- Language: Go
- Homepage: https://github.com/graphql-go/graphql
- Size: 13.7 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-authz
[](https://coveralls.io/github/casbin/graphql-authz?branch=master)
[](https://github.com/casbin/graphql-authz/actions/workflows/ci.yml)
[](https://github.com/casbin/graphql-authz/releases/latest)
[](https://goreportcard.com/report/github.com/casbin/graphql-authz)
graphql-authz is a casbin binding of graphql, something like restful api. There're actions, like `enforce`, `getPolicies`, `addPolicy`, `removePolicy`, `updatePolicy`.
## Install
```bash
go get -u github.com/casbin/graphql-authz
```
## Usage
Enforce Example:
```go
e, _ := casbin.NewEnforcer("./examples/model.conf", "./examples/policy.csv")
schema := authz.InitType(e)
result := authz.Execute(`{enforce(sub:"alice" obj:"data1" act:"read"){sub obj act ok}}`, schema)
```
More info, please refer to [graphql](https://github.com/graphql/graphql-js) and [basic usage](./authz_test.go)