feat: implement sessions request from grpc server
Some checks failed
Docker Build and Push / build-and-push-branches (push) Has been skipped
Docker Build and Push / build-and-push-tags (push) Has been cancelled

This commit is contained in:
2026-01-03 20:06:14 +07:00
parent 30e84ac3b7
commit 8fd9f8b567
5 changed files with 155 additions and 81 deletions

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)