entities

package
v0.0.0-...-1a3a2fa Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleUser        = "User"
	RoleSubmitter   = "Submitter"
	RoleAdmin       = "Admin"
	RoleSystem      = "System"
	RolePublic      = "Public"
	RoleShareGuest  = "ShareGuest"
	RoleTranscriber = "Transcriber"
	RoleSharer      = "Sharer"

	ResourceCall       = "Call"
	ResourceIncident   = "Incident"
	ResourceTalkgroup  = "Talkgroup"
	ResourceSystem     = "System" // P25 system
	ResourceAlert      = "Alert"
	ResourceShare      = "Share"
	ResourceAPIKey     = "APIKey"
	ResourceCallStats  = "CallStats"
	ResourceSetting    = "Setting"
	ResourceUser       = "User"
	ResourceNexus      = "Nexus"
	ResourcePushSub    = "PushSubscription"
	ResourceWebPushSub = "WebPushSubscription"

	ActionRead             = "read"
	ActionReadPrivileged   = "readPrivileged"
	ActionCreate           = "create"
	ActionUpdate           = "update"
	ActionDelete           = "delete"
	ActionShare            = "share"
	ActionUpdatePrivileged = "updatePrivileged"
	ActionTranscribe       = "updateTranscription"
	ActionSimulate         = "simulate"
	ActionTestNotify       = "testNotify"
	ActionMoveCallAudio    = "moveCallAudio"
	ActionConnect          = "connect"

	ScopeSubmit     = "submit"
	ScopeTranscribe = "transcribe"
)
View Source
const SubjectCtxKey subjectContextKey = "sub"

Variables

This section is empty.

Functions

func CtxWithServiceSubject

func CtxWithServiceSubject(ctx context.Context, name string) context.Context

func CtxWithSubject

func CtxWithSubject(ctx context.Context, sub Subject) context.Context

func HasRole

func HasRole(sub Subject, roles ...string) bool

HasRole returns whether the subject has any of the passed roles.

func IsSystemService

func IsSystemService(sub Subject) bool

func ValidateScopes

func ValidateScopes(scopes []string) bool

ValidateScopes validates that all scopes exist. If any are invalid, it returns false.

Types

type APIKeySubject

type APIKeySubject struct {
	Subject
	// contains filtered or unexported fields
}

func NewAPIKeySubject

func NewAPIKeySubject(user Subject, scope ...string) *APIKeySubject

func (*APIKeySubject) GetRoles

func (s *APIKeySubject) GetRoles() []string

func (*APIKeySubject) UnwrapSubject

func (s *APIKeySubject) UnwrapSubject() Subject

type LocalAdminSubject

type LocalAdminSubject struct {
}

func NewLocalAdminSubject

func NewLocalAdminSubject() *LocalAdminSubject

func (*LocalAdminSubject) GetName

func (s *LocalAdminSubject) GetName() string

func (*LocalAdminSubject) GetRoles

func (s *LocalAdminSubject) GetRoles() []string

func (*LocalAdminSubject) String

func (s *LocalAdminSubject) String() string

type PublicSubject

type PublicSubject struct {
	RemoteAddr string
}

func NewPublicSubject

func NewPublicSubject(r *http.Request) *PublicSubject

func (*PublicSubject) GetName

func (s *PublicSubject) GetName() string

func (*PublicSubject) GetRoles

func (s *PublicSubject) GetRoles() []string

func (*PublicSubject) String

func (s *PublicSubject) String() string

type Resource

type Resource interface {
	restrict.Resource
}

type Subject

type Subject interface {
	fmt.Stringer
	restrict.Subject
	GetName() string
}

func SubjectFrom

func SubjectFrom(ctx context.Context) Subject

type SubjectWrapper

type SubjectWrapper interface {
	UnwrapSubject() Subject
}

type SystemServiceSubject

type SystemServiceSubject struct {
	Name string
}

func (*SystemServiceSubject) GetName

func (s *SystemServiceSubject) GetName() string

func (*SystemServiceSubject) GetRoles

func (s *SystemServiceSubject) GetRoles() []string

func (*SystemServiceSubject) String

func (s *SystemServiceSubject) String() string

Jump to

Keyboard shortcuts

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