// AuthKey authenticates based on a public key. func AuthKey(key ssh.PublicKey) (*ssh.Permissions, error) { log.Info("Starting ssh authentication") userInfo, err := controller.UserInfoFromKey(key) if err != nil { return nil, err } userInfo.Key = string(ssh.MarshalAuthorizedKey(key)) apps := strings.Join(userInfo.Apps, ", ") log.Debug("Key accepted for user %s.", userInfo.Username) perm := &ssh.Permissions{ Extensions: map[string]string{ "user": userInfo.Username, "fingerprint": userInfo.Fingerprint, "apps": apps, }, } return perm, nil }
// AuthKey authenticates based on a public key. // // Params: // - metadata (ssh.ConnMetadata) // - key (ssh.PublicKey) // // Returns: // *ssh.Permissions // func AuthKey(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) { log.Debugf(c, "Starting ssh authentication") key := p.Get("key", nil).(ssh.PublicKey) userInfo, err := controller.UserInfoFromKey(key) if err != nil { return nil, err } userInfo.Key = string(ssh.MarshalAuthorizedKey(key)) c.Put("userinfo", userInfo) log.Infof(c, "Key accepted for user %s.", userInfo.Username) perm := &ssh.Permissions{ Extensions: map[string]string{ "user": userInfo.Username, }, } return perm, nil }