acl

package
v25.0.0-custom-qt-impr... Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OpRead   = "Read"
	OpWrite  = "Write"
	OpModify = "Modify"
)
View Source
var (
	// Read is used when doing a query.
	Read = &Operation{
		Code: 4,
		Name: OpRead,
	}
	// Write is used when mutating data.
	Write = &Operation{
		Code: 2,
		Name: OpWrite,
	}
	// Modify is used when altering the schema or dropping data.
	Modify = &Operation{
		Code: 1,
		Name: OpModify,
	}
)
View Source
var (
	// CmdAcl is the sub-command used to manage the ACL system.
	CmdAcl x.SubCommand
)

Functions

func CreateGroupNQuads

func CreateGroupNQuads(groupId string) []*api.NQuad

CreateGroupNQuads cretes NQuads needed to store a group with the give ID.

func CreateUserNQuads

func CreateUserNQuads(userId, password string) []*api.NQuad

CreateUserNQuads creates the NQuads needed to store a user with the given ID and password in the ACL system.

func GetGroupIDs

func GetGroupIDs(groups []Group) []string

GetGroupIDs returns a slice containing the group ids of all the given groups.

Types

type Acl

type Acl struct {
	Predicate string `json:"dgraph.rule.predicate"`
	Perm      int32  `json:"dgraph.rule.permission"`
}

Acl represents the permissions in the ACL system. An Acl can have a predicate and permission for that predicate.

type AclEntity

type AclEntity interface {
	// GetUid returns the UID of the entity.
	// The implementation of GetUid must check the case that the entity is nil
	// and return an empty string accordingly.
	GetUid() string
}

AclEntity is an interface that must be met by all the types of entities (i.e users, groups) in the ACL system.

type Group

type Group struct {
	Uid     string `json:"uid"`
	GroupID string `json:"dgraph.xid"`
	Users   []User `json:"~dgraph.user.group"`
	Rules   []Acl  `json:"dgraph.acl.rule"`
}

Group represents a group in the ACL system.

func UnmarshalGroup

func UnmarshalGroup(input []byte, groupKey string) (group *Group, err error)

UnmarshalGroup extracts the first Group pointed by the groupKey in the query response.

func UnmarshalGroups

func UnmarshalGroups(input []byte, groupKey string) (group []Group, err error)

UnmarshalGroups extracts a sequence of groups from the input.

func (*Group) GetUid

func (g *Group) GetUid() string

GetUid returns the UID of the group.

type Operation

type Operation struct {
	Code int32
	Name string
}

Operation represents a Dgraph data operation (e.g write or read).

type User

type User struct {
	Uid           string  `json:"uid"`
	UserID        string  `json:"dgraph.xid"`
	Password      string  `json:"dgraph.password"`
	Namespace     uint64  `json:"namespace"`
	PasswordMatch bool    `json:"password_match"`
	Groups        []Group `json:"dgraph.user.group"`
}

User represents a user in the ACL system.

func UnmarshalUser

func UnmarshalUser(resp *api.Response, userKey string) (user *User, err error)

UnmarshalUser extracts the first User pointed by the userKey in the query response.

func (*User) GetUid

func (u *User) GetUid() string

GetUid returns the UID of the user.

Jump to

Keyboard shortcuts

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