Documentation
¶
Overview ¶
Package credentials stores API keys for hosted providers in ~/.decsr/credentials.json (directory 0700, file 0600). A key is never logged, printed or included in an error; List only returns masked keys.
Index ¶
Constants ¶
const ( // Dirname is the directory under the home directory, shared with the config. Dirname = ".decsr" // Filename is the credentials file inside the directory. Filename = "credentials.json" // DisplayPath is how the file is shown to the user. DisplayPath = "~/.decsr/credentials.json" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cred ¶
type Cred struct {
APIKey string `json:"api_key"`
BaseURL string `json:"base_url,omitempty"`
SavedAt time.Time `json:"saved_at"`
}
Cred is one saved provider. BaseURL is only set for custom providers.
type PermError ¶
type PermError struct{ Path string }
PermError reports a credentials file that is readable by others.
type Store ¶
type Store struct {
// Dir is the directory holding credentials.json; "" means ~/.decsr.
Dir string
}
Store is a credentials file location. The zero value uses the home directory.
func Default ¶
func Default() Store
Default returns the store under the current user's home directory.
func (Store) CheckPerms ¶
CheckPerms returns a *PermError when the file exists with a mode broader than 0600 (always nil on Windows and when the file does not exist).
func (Store) Get ¶
Get returns the saved entry for name. A file with loose permissions is refused with a *PermError.