authz

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

graphql-authz

Coverage StatusGoReleaseGo Report Card

graphql-authz is a casbin binding of graphql, something like restful api. There're actions, like enforce, getPolicies, addPolicy, removePolicy, updatePolicy.

Install

go get -u github.com/casbin/graphql-authz

Usage

Enforce Example:

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 and basic usage

Documentation

Overview

package graphql_authz

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(query string, schema graphql.Schema) *graphql.Result

func InitType

func InitType(e *casbin.Enforcer) graphql.Schema

Types

type Policy

type Policy struct {
	Sub string `json:"sub"`
	Obj string `json:"obj"`
	Act string `json:"act"`
}

func StringArrToPolicy

func StringArrToPolicy(arr []string) Policy

type Request

type Request struct {
	Sub string `json:"sub"`
	Obj string `json:"obj"`
	Act string `json:"act"`
	OK  bool   `json:"ok"`
}

type UpdatePolicy

type UpdatePolicy struct {
	Sub string `json:"sub"`
	Obj string `json:"obj"`
	Act string `json:"act"`

	OldSub string `json:"osub"`
	OldObj string `json:"oobj"`
	OldAct string `json:"oact"`
	Ok     bool   `json:"ok"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL