Skip to content

Commit 80d8371

Browse files
committed
fixup! Pass public key via auth callback permissions
1 parent 40866c2 commit 80d8371

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

server.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ssh
22

33
import (
44
"context"
5+
"encoding/base64"
56
"errors"
67
"fmt"
78
"net"
@@ -29,6 +30,8 @@ var DefaultChannelHandlers = map[string]ChannelHandler{
2930
"session": DefaultSessionHandler,
3031
}
3132

33+
var permissionsPublicKeyExt = "gliderlabs/ssh.PublicKey"
34+
3235
// Server defines parameters for running an SSH server. The zero value for
3336
// Server is a valid configuration. When both PasswordHandler and
3437
// PublicKeyHandler are nil, no client authentication is performed.
@@ -162,7 +165,10 @@ func (srv *Server) config(ctx Context) *gossh.ServerConfig {
162165
if ok := srv.PublicKeyHandler(ctx, key); !ok {
163166
return ctx.Permissions().Permissions, fmt.Errorf("permission denied")
164167
}
165-
ctx.SetValue(ContextKeyPublicKey, key)
168+
169+
pkStr := base64.StdEncoding.EncodeToString(key.Marshal())
170+
ctx.Permissions().Permissions.Extensions[permissionsPublicKeyExt] = pkStr
171+
166172
return ctx.Permissions().Permissions, nil
167173
}
168174
}

0 commit comments

Comments
 (0)