Documentation ¶
Overview ¶
Package repo provides KeyRepository
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blocklisted ¶
type Blocklisted struct { Repository KeyRepository Blocked []string // set of case-insensitive usernames that are blocked }
Blocklisted represents a KeyRepository that blocks a list of user for legal reasons
type Combo ¶
type Combo []KeyRepository
Combo combines an array of KeyRepositories by trying each in order. Keys for a specific user are always returned from a specific repository, and never combined.
type GitHubKeys ¶
GitHubKeys is an object that allows fetching ssh keys for GitHub Users using the GitHub API. It implements KeyRepository.
The zero value is not ready to use, the caller should instantiate a GitHubClient first. See also NewGitHubKeyRepo.
func NewGitHubKeys ¶
func NewGitHubKeys(opts GitHubKeysOptions) (*GitHubKeys, error)
NewGitHubKeys is a convenience method that instantiates NewGitHubKeys. It reads options from opts, and returns a new GitHubKeyRepo.
func (GitHubKeys) GetKeys ¶
func (gr GitHubKeys) GetKeys(context context.Context, username string) (string, []ssh.PublicKey, error)
GetKeys fetches keys from GitHub for the provided username. May internally cache results, as configured in the github.Client.
If this function determines that a user does not exist, returns UserNotFoundError.
type GitHubKeysOptions ¶
type GitHubKeysOptions struct { // Token for GitHub Authentication. // Leave blank for anonymous requests; these might be subject to rate limiting. Token string // Timeout is the Timeout for requests to GitHub. // The zero value indicates no timeout. Timeout time.Duration // MaxCacheSize is the maximum size of an internally used cache in bytes. // Leave blank to disable. MaxCacheSize int64 // MaxCacheAge is the maximum age for any value in the cache. // Leave blank to never expire cache entires. MaxCacheAge time.Duration }
GitHubKeysOptions represent options for a GitHubKeyRepo.
type KeyRepository ¶
type KeyRepository interface { // GetKeys resolves and returns the keys for the provided username. // It returns a repo-defined identifier for which source the user came from, along with the set of keys and an error. // // When this function determines that a user does not exist, it returns an error of type UserNotFoundError. // When the user is not available for legal reasons, it returns an error of type UserNotAvailableError. // It may return other error types for undefined errors GetKeys(context context.Context, username string) (source string, keys []ssh.PublicKey, err error) }
KeyRepository is an object that can fetch ssh keys for a given username from a remote source. Any implementation is assumed safe for concurrent access and may internally cache responses.
type UploadableKeys ¶
type UploadableKeys struct { Prefix string // Prefix is the prefix for new users AuthPassword, AuthUser string WriteSuffix func(w io.Writer) error // contains filtered or unexported fields }
UploadableKeys is an object that allows callers to upload keys to the server temporarily.
func (*UploadableKeys) GetKeys ¶
func (uk *UploadableKeys) GetKeys(context context.Context, username string) (string, []ssh.PublicKey, error)
GetKeys fetches keys from GitHub for the provided username.
If this function determines that a user does not exist, returns a UserNotFoundError.
func (*UploadableKeys) Register ¶
func (uk *UploadableKeys) Register(keys ...ssh.PublicKey) (username string, cleanup func())
Register registers a new set of keys from the user. The delete function will delete the user from the cache.
func (*UploadableKeys) ServeHTTP ¶
func (uk *UploadableKeys) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UserNotAvailableError ¶
type UserNotAvailableError struct {
// contains filtered or unexported fields
}
UserNotAvailableError indicates that the provided user has been blocked from the server
func (UserNotAvailableError) Error ¶
func (usr UserNotAvailableError) Error() string
type UserNotFoundError ¶
type UserNotFoundError struct {
// contains filtered or unexported fields
}
UserNotFoundError indicates that a KeyRepository was unable to find the provided user and is thus unable to return keys for it.
This type implements github.com/pkg/errors.Causer and go 1.13+ errors.
func (UserNotFoundError) Cause ¶
func (u UserNotFoundError) Cause() error
Cause returns the error that caused this error.
func (UserNotFoundError) Unwrap ¶
func (u UserNotFoundError) Unwrap() error
Unwrap unwraps this error