Documentation
¶
Overview ¶
Package importer provides a means for importing public ssh keys from a well known internet based location such as Github or Launchpad.
NewImporter can be used to construct a new ssh public key importer. Currently Github (gh) and Launchpad (lp) are supported for importing public keys.
Examples of import subjects: - gh:tlm - gh:~wallyworld
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface { // Do is responsible for performing a [http.Request] and returning the // subsequent result. See [http.Client.Do] for documentation on this func. Do(*http.Request) (*http.Response, error) }
Client represents a http client capable of performing a http request.
type GithubResolver ¶
type GithubResolver struct { // Client is the http client to use for talking with Github. Client Client }
GithubResolver is an implementation of Resolver for retrieving the public keys of a Github user.
func (*GithubResolver) PublicKeysForSubject ¶
func (g *GithubResolver) PublicKeysForSubject( ctx context.Context, subject string, ) ([]string, error)
PublicKeysForSubject implements the Resolver interface by taking a Github subject in this case a user and returning all of the public ssh keys the user has for their profile. The following errors can be expected: - importererrors.SubjectNotFound when the subject being asked for does not exist in the resolvers domain.
type Importer ¶
type Importer struct {
// contains filtered or unexported fields
}
Importer is responsible for providing a pattern for importing a subjects public keys from multiple sources.
func NewImporter ¶
NewImporter constructs a new Importer for importing a subject's public key.
func (*Importer) FetchPublicKeysForSubject ¶
func (i *Importer) FetchPublicKeysForSubject( ctx context.Context, subject *url.URL, ) ([]string, error)
FetchPublicKeysForSubject takes a uri subject to fetch public keys for. The schema of the URI defines the resolver to use and the opqaue data defines the subject to fetch public key data for. Example URI's: - gh:tlm - lp:~wallyworld
The following errors can be expected: - errors.NotValid when the opaque data for the URI is empty. - importererrors.NoResolver when no resolver is defined for the schema of the URI. - importererrors.SubjectNotFound when no subject exists for the Resolver.
type LaunchpadResolver ¶
type LaunchpadResolver struct { // Client is the http client to use for talking with Launchpad. Client Client }
LaunchpadResolver is an implementation of Resolver for retrieving the public keys of a Launchpad user.
func (*LaunchpadResolver) PublicKeysForSubject ¶
func (l *LaunchpadResolver) PublicKeysForSubject( ctx context.Context, subject string, ) ([]string, error)
PublicKeysForSubject implements the Resolver interface by taking a Launchpad subject in this case a user and returning all of the public ssh keys the user has for their profile. The following errors can be expected: - importererrors.SubjectNotFound when the subject being asked for does not exist in the resolvers domain.
type Resolver ¶
type Resolver interface { // PublicKeysForSubject is responsible for taking a subject that exists // within this resolver's domain and returning all of the public ssh keys // for that subject. // The following errors can be expected: // - [SubjectNotFound] when the subject being asked for does not exist in // the resolvers domain. PublicKeysForSubject(context.Context, string) ([]string, error) }
Resolver describes a service that can fetch public key information for a supplied subject.