security

package
v0.30.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var System = system{}

System defines a singleton principal that can be used to bypass security checks. e.g. internal service to service interactions

View Source
var SystemSubject = systemSubject{[]any{System}}

Functions

func Credentials added in v0.30.2

func Credentials(cs ...any) func(Subject)

Credentials configures a Subject with initial credentials.

func HasAllPrincipals added in v0.30.2

func HasAllPrincipals(subject Subject, ps ...any) bool

HasAllPrincipals return true if the subject possess all principals.

func HasAnyPrincipals added in v0.30.2

func HasAnyPrincipals(subject Subject, ps ...any) bool

HasAnyPrincipals return true if the subject possess any principals.

func Principals added in v0.30.2

func Principals(ps ...any) func(Subject)

Principals configures a Subject with initial principals.

Types

type Group added in v0.30.2

type Group struct {
	Name string
}

Group organizes users having common capabilities.

type Role

type Role struct {
	Name string
}

Role represents a certain level of authorization.

type Subject

type Subject interface {
	// Principals return the identities of this Subject.
	// e.g. UserId, Username, Group or Role
	Principals() []any

	// Credentials return security-related attributes of this Subject.
	// e.g. passwords, certificates, claims
	Credentials() []any

	// AddPrincipals adds the principals if not present.
	AddPrincipals(ps ...any)

	// AddCredentials add credentials if not present.
	AddCredentials(cs ...any)
}

Subject is any entity that requests access to a resource. e.g. Process, Machine, Service or User

func NewSubject added in v0.30.2

func NewSubject(config ...func(Subject)) Subject

NewSubject creates a new Subject with optional principals and credentials.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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