feat: implement sessions request from grpc server

This commit is contained in:
2026-01-03 20:06:14 +07:00
parent 4644420eee
commit 449f546e04
5 changed files with 155 additions and 81 deletions
+5 -9
View File
@@ -83,17 +83,13 @@ func (s *Server) handleConnection(conn net.Conn) {
ctx := context.Background()
log.Println("SSH connection established:", sshConn.User())
//Fallback: kalau auth gagal userID di set UNAUTHORIZED
authorized, _ := s.grpcClient.AuthorizeConn(ctx, sshConn.User())
var userID string
if authorized {
userID = sshConn.User()
} else {
userID = "UNAUTHORIZED"
user := "UNAUTHORIZED"
if s.grpcClient != nil {
_, u, _ := s.grpcClient.AuthorizeConn(ctx, sshConn.User())
user = u
}
sshSession := session.New(sshConn, forwardingReqs, chans, s.sessionRegistry, userID)
sshSession := session.New(sshConn, forwardingReqs, chans, s.sessionRegistry, user)
err = sshSession.Start()
if err != nil {
log.Printf("SSH session ended with error: %v", err)