Documentation
¶
Overview ¶
Package identity provides the user identity: the user's SSH private key and certificate, and how a new certificate is obtained from the CA and added to the SSH agent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ObtainOption ¶
type ObtainOption int
ObtainOption changes how User.Obtain obtains a certificate
const ( // WithoutAgent does not add the new certificate to the SSH agent WithoutAgent ObtainOption = iota + 1 // WithoutInteractiveLogin only uses cached tokens or a refresh token, so // the request fails with [auth.ErrInteractiveLoginRequired] rather than // start an interactive login WithoutInteractiveLogin )
type Option ¶
type Option func(*options)
Option configures a User
func WithAuthHandler ¶
WithAuthHandler uses h to authenticate certificate requests instead of an OIDC login using conf
func WithLifetime ¶
WithLifetime sets the lifetime requested for new certificates. The default is cert.DefaultUserCertificateLifetime.
func WithLogger ¶
WithLogger sets the logger used for the OIDC login and for reporting stale certificates removed from the SSH agent
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is the user identity. By default the private key and certificate are kept in the system keyring and certificates are obtained after an OIDC login, with the refresh token also kept in the system keyring.
func NewUser ¶
func NewUser(conf *config.ClientConfig, opts ...Option) (*User, error)
NewUser creates the User for conf. Neither the CA nor the identity provider is contacted until a certificate is obtained.
func (*User) AddToAgent ¶
AddToAgent adds the current private key and certificate to the SSH agent, then removes any stale certificates from the agent. Failures adding to the agent are returned as cert.ErrAddingToAgent.
func (*User) Certificate ¶
func (u *User) Certificate() (*ssh.Certificate, error)
Certificate returns the current certificate, or an error wrapping cert.ErrCertificateNotFound if there is none
func (*User) GeneratePrivateKey ¶
GeneratePrivateKey generates a new private key, replacing any existing key and its certificate
func (*User) HasPrivateKey ¶
HasPrivateKey reports whether there is a private key
func (*User) Obtain ¶
func (u *User) Obtain(ctx context.Context, opts ...ObtainOption) error
Obtain requests a new certificate from the CA, saves it and adds it to the SSH agent, then removes any stale certificates from the agent. This blocks until any interactive login completes, times out or ctx is cancelled. If the certificate is saved but cannot be added to the agent the returned error wraps cert.ErrAddingToAgent.