Documentation ¶
Index ¶
- Variables
- func AdminRoleAsString() string
- func EmployeeRoleAsString() string
- func NewViewerContext(parent context.Context, role Role, scopes []string) context.Context
- func NewViewerWithIdContext(parent context.Context, role Role, userid string, scopes []string) context.Context
- func OwnerRoleAsString() string
- func ViewerRole() int
- func ViewerRoleAsString() string
- type Role
- type UserViewer
- func (v *UserViewer) Admin() bool
- func (v *UserViewer) Employee() bool
- func (v *UserViewer) GetUserID() string
- func (v *UserViewer) HasScope(scope string) bool
- func (v *UserViewer) HasScopes() bool
- func (v *UserViewer) IsEmpty() bool
- func (v *UserViewer) Owner() bool
- func (v *UserViewer) SetRole(role int) error
- func (v *UserViewer) SetRoleAsString(role string) error
- func (v *UserViewer) SetUserID(id string)
- func (v *UserViewer) ToContext(ctx context.Context) context.Context
- type Viewer
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
NewViewerContext returns a copy of parent context with a new constructed Viewer attached with it.
func NewViewerWithIdContext ¶ added in v0.0.6
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)
Click to show internal directories.
Click to hide internal directories.