Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidAuth = fmt.Errorf("invalid authentication")
View Source
var ( // ErrNoSerial indicates that a device serial is not set yet. ErrNoSerial = errors.New("no device serial yet") )
Functions ¶
func RemoveUser ¶
RemoveUser removes a user from the state given its ID
Types ¶
type AuthContext ¶
type AuthContext interface { Device() (*DeviceState, error) UpdateDeviceAuth(device *DeviceState, sessionMacaroon string) (actual *DeviceState, err error) UpdateUserAuth(user *UserState, discharges []string) (actual *UserState, err error) StoreID(fallback string) (string, error) DeviceSessionRequest(nonce string) (devSessionRequest []byte, serial []byte, err error) }
An AuthContext exposes authorization data and handles its updates.
func NewAuthContext ¶
func NewAuthContext(st *state.State, deviceAsserts DeviceAssertions) AuthContext
NewAuthContext returns an AuthContext for state.
type AuthState ¶
type AuthState struct { LastID int `json:"last-id"` Users []UserState `json:"users"` Device *DeviceState `json:"device,omitempty"` }
AuthState represents current authenticated users as tracked in state
type DeviceAssertions ¶
type DeviceAssertions interface { // Model returns the device model assertion. Model() (*asserts.Model, error) // Serial returns the device model assertion. Serial() (*asserts.Serial, error) // DeviceSessionRequest produces a device-session-request with the given nonce, it also returns the device serial assertion. DeviceSessionRequest(nonce string) (*asserts.DeviceSessionRequest, *asserts.Serial, error) }
DeviceAssertions helps exposing the assertions about device identity. All methods should return state.ErrNoState if the underlying needed information is not (yet) available.
type DeviceState ¶
type DeviceState struct { 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"` 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 ¶
CheckMacaroon returns the UserState for the given macaroon/discharges credentials
Click to show internal directories.
Click to hide internal directories.