mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
ssh/tailssh: do the full auth flow during ssh auth
Fixes #5091 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -38,9 +38,11 @@ type Server struct {
|
||||
HostSigners []Signer // private keys for the host key, must have at least one
|
||||
Version string // server version to be sent before the initial handshake
|
||||
|
||||
KeyboardInteractiveHandler KeyboardInteractiveHandler // keyboard-interactive authentication handler
|
||||
KeyboardInteractiveHandler KeyboardInteractiveHandler // keyboard-interactive authentication handler
|
||||
BannerHandler BannerHandler
|
||||
PasswordHandler PasswordHandler // password authentication handler
|
||||
PublicKeyHandler PublicKeyHandler // public key authentication handler
|
||||
NoClientAuthHandler NoClientAuthHandler // no client authentication handler
|
||||
PtyCallback PtyCallback // callback for allowing PTY sessions, allows all if nil
|
||||
ConnCallback ConnCallback // optional callback for wrapping net.Conn before handling
|
||||
LocalPortForwardingCallback LocalPortForwardingCallback // callback for allowing local port forwarding, denies all if nil
|
||||
@@ -160,6 +162,21 @@ func (srv *Server) config(ctx Context) *gossh.ServerConfig {
|
||||
return ctx.Permissions().Permissions, nil
|
||||
}
|
||||
}
|
||||
if srv.NoClientAuthHandler != nil {
|
||||
config.NoClientAuthCallback = func(conn gossh.ConnMetadata) (*gossh.Permissions, error) {
|
||||
applyConnMetadata(ctx, conn)
|
||||
if err := srv.NoClientAuthHandler(ctx); err != nil {
|
||||
return ctx.Permissions().Permissions, err
|
||||
}
|
||||
return ctx.Permissions().Permissions, nil
|
||||
}
|
||||
}
|
||||
if srv.BannerHandler != nil {
|
||||
config.BannerCallback = func(conn gossh.ConnMetadata) string {
|
||||
applyConnMetadata(ctx, conn)
|
||||
return srv.BannerHandler(ctx)
|
||||
}
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
|
@@ -38,6 +38,10 @@ type Handler func(Session)
|
||||
// PublicKeyHandler is a callback for performing public key authentication.
|
||||
type PublicKeyHandler func(ctx Context, key PublicKey) error
|
||||
|
||||
type NoClientAuthHandler func(ctx Context) error
|
||||
|
||||
type BannerHandler func(ctx Context) string
|
||||
|
||||
// PasswordHandler is a callback for performing password authentication.
|
||||
type PasswordHandler func(ctx Context, password string) bool
|
||||
|
||||
|
Reference in New Issue
Block a user