auth

package
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MPL-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CredentialTypeBasic  = CredentialType("BASIC")
	CredentialTypeAPIKey = CredentialType("API_KEY")
)
View Source
const (
	RoleSuperUser = RoleType("super_user")
	RoleUIAdmin   = RoleType("ui_admin")
	RoleAdmin     = RoleType("admin")
	RoleAPI       = RoleType("api")
)

Variables

View Source
var (
	ErrCredentialNotFound = errors.New("credential not found")
)

Functions

This section is empty.

Types

type AuthenticatedUser

type AuthenticatedUser struct {
	AuthenticatedByRealm string     `json:"-"` // Name of realm that authenticated this user
	Credential           Credential `json:"credential"`
	Role                 Role       `json:"role"`
}

type Credential

type Credential struct {
	Type     CredentialType `json:"type"`
	Username string         `json:"username"`
	Password string         `json:"password"`
	APIKey   string         `json:"api_key"`
}

type CredentialType

type CredentialType string

func (CredentialType) String

func (c CredentialType) String() string

type Realm

type Realm interface {
	GetName() string
	Authenticate(cred *Credential) (*AuthenticatedUser, error)
}

type Role

type Role struct {
	Type   RoleType `json:"type"`
	Groups []string `json:"groups"`
}

Role represents the permission a user is given, if the Type is RoleSuperUser, Then the user will have access to everything regardless of the value of Groups.

type RoleType

type RoleType string

func (RoleType) Is

func (r RoleType) Is(rt RoleType) bool

func (RoleType) IsValid

func (r RoleType) IsValid() bool

func (RoleType) String

func (r RoleType) String() string

func (*RoleType) UnmarshalJSON

func (r *RoleType) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
realm

Jump to

Keyboard shortcuts

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