auth

package
v2.42.5-go-mod+incompa... Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAuth = fmt.Errorf("invalid authentication")
View Source
var ErrInvalidUser = errors.New("invalid user")

Functions

func EnsureContextTODO

func EnsureContextTODO() context.Context

EnsureContextTODO returns a provisional context marked as pertaining to an Ensure loop. TODO: see Overlord.Loop to replace it with a proper context passed to all Ensures.

func IsEnsureContext

func IsEnsureContext(ctx context.Context) bool

IsEnsureContext returns whether context was marked as pertaining to an Ensure loop.

func MacaroonDeserialize

func MacaroonDeserialize(serializedMacaroon string) (*macaroon.Macaroon, error)

MacaroonDeserialize returns a deserialized macaroon from a given store-compatible serialization

func MacaroonSerialize

func MacaroonSerialize(m *macaroon.Macaroon) (string, error)

MacaroonSerialize returns a store-compatible serialized representation of the given macaroon

func RemoveUser

func RemoveUser(st *state.State, userID int) error

RemoveUser removes a user from the state given its ID

func UpdateUser

func UpdateUser(st *state.State, user *UserState) error

UpdateUser updates user in state

Types

type AuthState

type AuthState struct {
	LastID      int          `json:"last-id"`
	Users       []UserState  `json:"users"`
	Device      *DeviceState `json:"device,omitempty"`
	MacaroonKey []byte       `json:"macaroon-key,omitempty"`
}

AuthState represents current authenticated users as tracked in state

type CloudInfo

type CloudInfo struct {
	Name             string `json:"name"`
	Region           string `json:"region,omitempty"`
	AvailabilityZone string `json:"availability-zone,omitempty"`
}

CloudInfo reflects cloud information for the system (as captured in the core configuration).

type DeviceState

type DeviceState struct {
	// Brand refers to the brand-id
	Brand  string `json:"brand,omitempty"`
	Model  string `json:"model,omitempty"`
	Serial string `json:"serial,omitempty"`

	KeyID string `json:"key-id,omitempty"`

	SessionMacaroon string `json:"session-macaroon,omitempty"`
}

DeviceState represents the device's identity and store credentials

type UserState

type UserState struct {
	ID              int      `json:"id"`
	Username        string   `json:"username,omitempty"`
	Email           string   `json:"email,omitempty"`
	Macaroon        string   `json:"macaroon,omitempty"`
	Discharges      []string `json:"discharges,omitempty"`
	StoreMacaroon   string   `json:"store-macaroon,omitempty"`
	StoreDischarges []string `json:"store-discharges,omitempty"`
}

UserState represents an authenticated user

func CheckMacaroon

func CheckMacaroon(st *state.State, macaroon string, discharges []string) (*UserState, error)

CheckMacaroon returns the UserState for the given macaroon/discharges credentials

func NewUser

func NewUser(st *state.State, username, email, macaroon string, discharges []string) (*UserState, error)

NewUser tracks a new authenticated user and saves its details in the state

func User

func User(st *state.State, id int) (*UserState, error)

User returns a user from the state given its ID

func Users

func Users(st *state.State) ([]*UserState, error)

func (*UserState) HasStoreAuth

func (u *UserState) HasStoreAuth() bool

HasStoreAuth returns true if the user has store authorization.

Jump to

Keyboard shortcuts

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