privacy

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextKeyViewer = contextKey("viewer")

Functions

func AdminRoleAsString

func AdminRoleAsString() string

func EmployeeRoleAsString

func EmployeeRoleAsString() string

func NewViewerContext added in v0.0.4

func NewViewerContext(parent context.Context, role Role, scopes []string) context.Context

NewViewerContext returns a copy of parent context with a new constructed Viewer attached with it.

func NewViewerWithIdContext added in v0.0.6

func NewViewerWithIdContext(parent context.Context, role Role, userid string, scopes []string) context.Context

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 FromContext

func FromContext(ctx context.Context) (UserViewer, bool)

FromContext returns the Viewer stored in a context.

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) IsEmpty added in v0.0.4

func (v *UserViewer) IsEmpty() bool

func (*UserViewer) Owner

func (v *UserViewer) Owner() bool

func (*UserViewer) SetRole added in v0.0.4

func (v *UserViewer) SetRole(role int) error

func (*UserViewer) SetRoleAsString added in v0.0.4

func (v *UserViewer) SetRoleAsString(role string) error

func (*UserViewer) SetUserID

func (v *UserViewer) SetUserID(id string)

func (*UserViewer) ToContext added in v0.0.4

func (v *UserViewer) ToContext(ctx context.Context) context.Context

ToContext sets the Viewer on the given context.

type Viewer

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

Viewer describes the query/mutation viewer-context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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