Documentation ¶
Overview ¶
Package client manages authorization, identity and keys for a Charm Cloud user. It also offers low-level HTTP and SSH APIs for accessing the Charm Cloud server.
Index ¶
- func RandomArt(k charm.PublicKey) (string, error)
- func ValidateName(name string) bool
- type Client
- func (cc *Client) Auth() (*charm.Auth, error)
- func (cc *Client) AuthKeyPaths() []string
- func (cc *Client) AuthedJSONRequest(method string, path string, reqBody interface{}, respBody interface{}) error
- func (cc *Client) AuthedRawRequest(method string, path string) (*http.Response, error)
- func (cc *Client) AuthedRequest(method string, path string, headers http.Header, reqBody io.Reader) (*http.Response, error)
- func (cc *Client) AuthorizedKeys() (string, error)
- func (cc *Client) AuthorizedKeysWithMetadata() (*charm.Keys, error)
- func (cc *Client) Bio() (*charm.User, error)
- func (cc *Client) DataPath() (string, error)
- func (cc *Client) DefaultEncryptKey() (*charm.EncryptKey, error)
- func (cc *Client) EncryptKeys() ([]*charm.EncryptKey, error)
- func (cc *Client) ID() (string, error)
- func (cc *Client) InvalidateAuth()
- func (cc *Client) JWT(aud ...string) (string, error)
- func (cc *Client) KeyForID(gid string) (*charm.EncryptKey, error)
- func (cc *Client) Link(lh charm.LinkHandler, code string) error
- func (cc *Client) LinkGen(lh charm.LinkHandler) error
- func (cc *Client) News(id string) (*charm.News, error)
- func (cc *Client) NewsList(tags []string, page int) ([]*charm.News, error)
- func (cc *Client) SetName(name string) (*charm.User, error)
- func (cc *Client) SyncEncryptKeys() error
- func (cc *Client) UnlinkAuthorizedKey(key string) error
- type Config
- type ErrRequestTooLarge
- type Fingerprint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { Config *Config // contains filtered or unexported fields }
Client is the Charm client.
func NewClientWithDefaults ¶
NewClientWithDefaults creates a new Charm client with default values.
func (*Client) Auth ¶
Auth will authenticate a client and cache the result. It will return a proto.Auth with the JWT and encryption keys for a user.
func (*Client) AuthKeyPaths ¶
AuthKeyPaths returns the full file path of the Charm auth SSH keys.
func (*Client) AuthedJSONRequest ¶
func (cc *Client) AuthedJSONRequest(method string, path string, reqBody interface{}, respBody interface{}) error
AuthedRequest sends an authorized JSON request to the Charm and Glow HTTP servers.
func (*Client) AuthedRawRequest ¶
AuthedRawRequest sends an authorized request with no request body to the Charm and Glow HTTP servers.
func (*Client) AuthedRequest ¶
func (cc *Client) AuthedRequest(method string, path string, headers http.Header, reqBody io.Reader) (*http.Response, error)
AuthedRequest sends an authorized request to the Charm and Glow HTTP servers.
func (*Client) AuthorizedKeys ¶
AuthorizedKeys returns the keys linked to a user's account.
func (*Client) AuthorizedKeysWithMetadata ¶
AuthorizedKeysWithMetadata fetches keys linked to a user's account, with metadata.
func (*Client) DataPath ¶ added in v0.11.0
DataPath return the directory a Charm user's data is stored. It will default to XDG-HOME/$CHARM_HOST.
func (*Client) DefaultEncryptKey ¶
func (cc *Client) DefaultEncryptKey() (*charm.EncryptKey, error)
DefaultEncryptKey returns the default EncryptKey for an authed user.
func (*Client) EncryptKeys ¶ added in v0.10.0
func (cc *Client) EncryptKeys() ([]*charm.EncryptKey, error)
EncryptKeys returns all of the symmetric encrypt keys for the authed user.
func (*Client) InvalidateAuth ¶
func (cc *Client) InvalidateAuth()
InvalidateAuth clears the JWT auth cache, forcing subsequent Auth() to fetch a new JWT from the server.
func (*Client) KeyForID ¶
func (cc *Client) KeyForID(gid string) (*charm.EncryptKey, error)
KeyForID returns the decrypted EncryptKey for a given key ID.
func (*Client) Link ¶
func (cc *Client) Link(lh charm.LinkHandler, code string) error
Link joins in on a linking session initiated by LinkGen.
func (*Client) LinkGen ¶
func (cc *Client) LinkGen(lh charm.LinkHandler) error
LinkGen initiates a linking session.
func (*Client) SyncEncryptKeys ¶
SyncEncryptKeys re-encodes all of the encrypt keys associated for this public key with all other linked public keys.
func (*Client) UnlinkAuthorizedKey ¶
UnlinkAuthorizedKey removes an authorized key from the user's Charm account.
type Config ¶
type Config struct { Host string `env:"CHARM_HOST" envDefault:"cloud.charm.sh"` SSHPort int `env:"CHARM_SSH_PORT" envDefault:"35353"` HTTPPort int `env:"CHARM_HTTP_PORT" envDefault:"35354"` Debug bool `env:"CHARM_DEBUG" envDefault:"false"` Logfile string `env:"CHARM_LOGFILE" envDefault:""` KeyType string `env:"CHARM_KEY_TYPE" envDefault:"ed25519"` DataDir string `env:"CHARM_DATA_DIR" envDefault:""` IdentityKey string `env:"CHARM_IDENTITY_KEY" envDefault:""` }
Config contains the Charm client configuration.
func ConfigFromEnv ¶
ConfigFromEnv loads the configuration from the environment.
func (*Config) KeygenType ¶ added in v0.10.0
KeygenType returns the keygen key type.
type ErrRequestTooLarge ¶
ErrRequestTooLarge is an error for a request that is too large.
func (ErrRequestTooLarge) Error ¶
func (err ErrRequestTooLarge) Error() string
type Fingerprint ¶
Fingerprint is the fingerprint of an SSH key.
func FingerprintSHA256 ¶
func FingerprintSHA256(k charm.PublicKey) (Fingerprint, error)
FingerprintSHA256 returns the algorithm and SHA256 fingerprint for the given key.
func (Fingerprint) String ¶
func (f Fingerprint) String() string
String outputs a string representation of the fingerprint.