privacy

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminRoleAsString

func AdminRoleAsString() string

func EmployeeRoleAsString

func EmployeeRoleAsString() string

func NewContext

func NewContext(parent context.Context, v Viewer) context.Context

NewContext returns a copy of parent context with the given Viewer attached with it.

func OwnerRoleAsString

func OwnerRoleAsString() string

func ViewerRole

func ViewerRole() int

func ViewerRoleAsString

func ViewerRoleAsString() string

Types

type Role

type Role int

Role for viewer actions.

const (
	Admin Role
	Owner
	Employee
	View
)

List of roles.

type UserViewer

type UserViewer struct {
	Role   Role     // Attached roles.
	Scopes []string // Attached businesses for this role
	Claims map[string]string
}

UserViewer describes a user-viewer.

func (*UserViewer) Admin

func (v *UserViewer) Admin() bool

func (*UserViewer) Employee

func (v *UserViewer) Employee() bool

func (*UserViewer) GetUserID

func (v *UserViewer) GetUserID() string

func (*UserViewer) HasScope

func (v *UserViewer) HasScope(scope string) bool

func (*UserViewer) HasScopes

func (v *UserViewer) HasScopes() bool

func (*UserViewer) Owner

func (v *UserViewer) Owner() bool

func (*UserViewer) SetUserID

func (v *UserViewer) SetUserID(id string)

type Viewer

type Viewer interface {
	Admin() bool // If viewer is admin.
	Owner() bool
	Employee() bool
	HasScopes() bool
	HasScope(scope string) bool
	GetUserID() string
}

Viewer describes the query/mutation viewer-context.

func FromContext

func FromContext(ctx context.Context) Viewer

FromContext returns the Viewer stored in a context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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