Documentation
¶
Overview ¶
Package proto contains structs used for client/server communication.
Index ¶
- Constants
- Variables
- func AddExecPermsForMkDir(mode fs.FileMode) fs.FileMode
- func PublicKeySha(key string) string
- type Auth
- type EncryptKey
- type ErrAuthFailed
- type FileInfo
- type Keys
- type Link
- type LinkHandler
- type LinkQueue
- type LinkStatus
- type LinkTransport
- type Message
- type News
- type PublicKey
- type SeqMsg
- type Token
- type UnlinkRequest
- type User
Constants ¶
const LinkTimeout = time.Minute
LinkTimeout is the length of time a Token is valid for.
Variables ¶
var ErrCouldNotUnlinkKey = errors.New("could not unlink key")
ErrCouldNotUnlinkKey is used when a key can't be deleted.
var ErrMalformedKey = errors.New("malformed key; is it missing the algorithm type at the beginning?")
ErrMalformedKey parsing error for bad ssh key.
var ErrMissingSSHAuth = errors.New("missing ssh auth")
ErrMissingSSHAuth is used when the user is missing SSH credentials.
var ErrMissingUser = errors.New("no user found")
ErrMissingUser is used when no user record is found.
var ErrNameInvalid = errors.New("invalid name")
ErrNameInvalid is used when a username is invalid.
var ErrNameTaken = errors.New("name already taken")
ErrNameTaken is used when a user attempts to set a username and that username is already taken.
var ErrPageOutOfBounds = errors.New("page must be a value of 1 or greater")
ErrPageOutOfBounds is an error for an invalid page number.
var ErrTokenExists = errors.New("token already exists")
ErrTokenExists is used when attempting to create a token that already exists.
var ErrUserExists = errors.New("user already exists for that key")
ErrUserExists is used when attempting to create a user with an existing global id.
Functions ¶
func AddExecPermsForMkDir ¶
Add execute permissions to an fs.FileMode to mirror read permissions.
func PublicKeySha ¶
PublicKeySha returns the SHA for a public key in hex format.
Types ¶
type Auth ¶
type Auth struct {
JWT string `json:"jwt"`
ID string `json:"charm_id"`
HTTPScheme string `json:"http_scheme"`
PublicKey string `json:"public_key,omitempty"`
EncryptKeys []*EncryptKey `json:"encrypt_keys,omitempty"`
}
Auth is the response to an authenticated connection. It contains tokens and keys required to access Charm Cloud services.
type EncryptKey ¶
type EncryptKey struct {
ID string `json:"id"`
Key string `json:"key"`
PublicKey string `json:"public_key,omitempty"`
CreatedAt *time.Time `json:"created_at"`
}
EncryptKey is the symmetric key used to encrypt data for a Charm user. An encrypt key will be encoded for every public key associated with a user's Charm account.
type ErrAuthFailed ¶
type ErrAuthFailed struct {
Err error
}
ErrAuthFailed indicates an authentication failure. The underlying error is wrapped.
func (ErrAuthFailed) Error ¶
func (e ErrAuthFailed) Error() string
Error returns the boxed error string.
type FileInfo ¶
type FileInfo struct {
Name string `json:"name"`
IsDir bool `json:"is_dir"`
Size int64 `json:"size"`
ModTime time.Time `json:"modtime"`
Mode fs.FileMode `json:"mode"`
Files []FileInfo `json:"files,omitempty"`
}
FileInfo describes a file and is returned by Stat.
type Keys ¶
Keys is the response returned when the user queries for the keys linked to their account.
type Link ¶
type Link struct {
Token Token `json:"token"`
RequestPubKey string `json:"request_pub_key"`
RequestAddr string `json:"request_addr"`
Host string `json:"host"`
Port int `json:"port"`
Status LinkStatus `json:"status"`
}
Link is the struct used to communicate state during the account linking process.
type LinkHandler ¶
type LinkHandler interface {
TokenCreated(*Link)
TokenSent(*Link)
ValidToken(*Link)
InvalidToken(*Link)
Request(*Link) bool
RequestDenied(*Link)
SameUser(*Link)
Success(*Link)
Timeout(*Link)
Error(*Link)
}
LinkHandler handles linking operations for the key to be linked.
type LinkQueue ¶ added in v0.10.0
type LinkQueue interface {
InitLinkRequest(t Token)
WaitLinkRequest(t Token) (chan *Link, error)
SendLinkRequest(lt LinkTransport, lc chan *Link, l *Link)
ValidateLinkRequest(t Token) bool
DeleteLinkRequest(t Token)
}
LinkQueue handles creating, validating, and sending link requests.
type LinkStatus ¶
type LinkStatus int
LinkStatus represents a state in the linking process.
const ( LinkStatusInit LinkStatus = iota LinkStatusTokenCreated LinkStatusTokenSent LinkStatusRequested LinkStatusRequestDenied LinkStatusSameUser LinkStatusDifferentUser LinkStatusSuccess LinkStatusTimedOut LinkStatusError LinkStatusValidTokenRequest LinkStatusInvalidTokenRequest )
LinkStatus values.
type LinkTransport ¶
type LinkTransport interface {
TokenCreated(Token)
TokenSent(*Link)
Requested(*Link) (bool, error)
LinkedSameUser(*Link)
LinkedDifferentUser(*Link)
Success(*Link)
TimedOut(*Link)
Error(*Link)
RequestStart(*Link)
RequestDenied(*Link)
RequestInvalidToken(*Link)
RequestValidToken(*Link)
User() *User
}
LinkTransport handles linking operations for the link generation.
type Message ¶
type Message struct {
Message string `json:"message"`
}
Message is used as a wrapper for simple client/server messages.
type News ¶
type News struct {
ID string `json:"id"`
Subject string `json:"subject"`
Tag string `json:"tag"`
Body string `json:"body,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
News entity.
type PublicKey ¶
type PublicKey struct {
ID int `json:"id"`
UserID int `json:"user_id,omitempty"`
Key string `json:"key"`
CreatedAt *time.Time `json:"created_at"`
}
PublicKey represents to public SSH key for a Charm user.
type SeqMsg ¶
type SeqMsg struct {
Seq uint64 `json:"seq"`
}
SeqMsg represents the results of a named sequence.
type UnlinkRequest ¶
type UnlinkRequest struct {
Key string `json:"key"`
}
UnlinkRequest is the message for unlinking an account from a key.