Help us shape the future of Go! Take the 2026 Go Developer Survey

perm

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithPerm

func CtxWithPerm(ctx context.Context, perm *RolePermissions) context.Context

Types

type Definitions

type Definitions interface {
	ForName(name string) *ast.Definition
}

type Permission

type Permission struct {
	Object   string         `json:"type_name"`
	Field    string         `json:"field_name"`
	Hidden   bool           `json:"hidden"`
	Disabled bool           `json:"disabled"`
	Filter   map[string]any `json:"filter"`
	Data     map[string]any `json:"data"`
}

type RolePermissions

type RolePermissions struct {
	Name        string       `json:"name"`
	Disabled    bool         `json:"disabled"`
	Permissions []Permission `json:"permissions"`
}

func PermissionsFromCtx

func PermissionsFromCtx(ctx context.Context) *RolePermissions

func (*RolePermissions) CheckMutationInput

func (r *RolePermissions) CheckMutationInput(defs Definitions, inputName string, data map[string]any) error

func (*RolePermissions) CheckQuery

func (r *RolePermissions) CheckQuery(query *ast.Field) error

func (*RolePermissions) DataArgument

func (r *RolePermissions) DataArgument(ctx context.Context, object, field string) map[string]any

func (*RolePermissions) Enabled

func (r *RolePermissions) Enabled(object, field string) (*Permission, bool)

func (*RolePermissions) FilterArgument

func (r *RolePermissions) FilterArgument(ctx context.Context, object, field string) map[string]any

func (*RolePermissions) Visible

func (r *RolePermissions) Visible(object, field string) (*Permission, bool)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(qe types.Querier) *Service

func (*Service) ContextWithPermissions

func (s *Service) ContextWithPermissions(ctx context.Context) (context.Context, error)

func (*Service) RolePermissions

func (s *Service) RolePermissions(ctx context.Context) (RolePermissions, error)

type Store

type Store interface {
	// ContextWithPermissions returns a new context with the permissions of the user.
	ContextWithPermissions(ctx context.Context) (context.Context, error)
	RolePermissions(ctx context.Context) (RolePermissions, error)
}

Store manager that provides methods to to retrieve Role permissions info from context.

Jump to

Keyboard shortcuts

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