Skip to content

Commit

Permalink
feat(server): use keyboard-interactive auth instead of password
Browse files Browse the repository at this point in the history
no need to enter a password for keyless users
  • Loading branch information
aymanbagabas committed Oct 24, 2022
1 parent dc1f295 commit b2c6401
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

gm "github.com/charmbracelet/wish/git"
"github.com/gliderlabs/ssh"
gossh "golang.org/x/crypto/ssh"
)

// Push registers Git push functionality for the given repo and key.
Expand Down Expand Up @@ -47,6 +48,11 @@ func (cfg *Config) PasswordHandler(ctx ssh.Context, password string) bool {
return (cfg.AnonAccess != "no-access") && cfg.AllowKeyless
}

// KeyboardInteractiveHandler returns whether or not keyboard interactive is allowed.
func (cfg *Config) KeyboardInteractiveHandler(ctx ssh.Context, _ gossh.KeyboardInteractiveChallenge) bool {
return (cfg.AnonAccess != "no-access") && cfg.AllowKeyless
}

// PublicKeyHandler returns whether or not the given public key may access the
// repo.
func (cfg *Config) PublicKeyHandler(ctx ssh.Context, pk ssh.PublicKey) bool {
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewServer(cfg *config.Config) *Server {
}
s, err := wish.NewServer(
ssh.PublicKeyAuth(ac.PublicKeyHandler),
ssh.PasswordAuth(ac.PasswordHandler),
ssh.KeyboardInteractiveAuth(ac.KeyboardInteractiveHandler),
wish.WithAddress(fmt.Sprintf("%s:%d", cfg.BindAddr, cfg.Port)),
wish.WithHostKeyPath(cfg.KeyPath),
wish.WithMiddleware(mw...),
Expand Down

0 comments on commit b2c6401

Please sign in to comment.