Skip to content

Commit

Permalink
fix: Go and JS clients should not require v1+v2 auth
Browse files Browse the repository at this point in the history
The Go client required sending v2 auth, but receiving v1 responses -
this change makes it consistently use v1 auth.

The JS client incorrectly closed the stream only after it had received
headers - now it can close right away, and just wait for headers to
arrive normally.

Prerequisite to deephaven#5922
  • Loading branch information
niloc132 committed Aug 15, 2024
1 parent 70368a8 commit 7e63a4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions go/pkg/client/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"fmt"
"github.com/apache/arrow/go/v8/arrow/flight"
configpb2 "github.com/deephaven/deephaven-core/go/internal/proto/config"
sessionpb2 "github.com/deephaven/deephaven-core/go/internal/proto/session"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto"
"log"
"strconv"
"sync"
Expand Down Expand Up @@ -124,13 +126,21 @@ func (tr *tokenManager) Close() error {
func newTokenManager(ctx context.Context, fs *flightStub, cfg configpb2.ConfigServiceClient, authType string, authToken string) (*tokenManager, error) {
authString := makeAuthString(authType, authToken)

handshakeClient, err := fs.handshake(withAuth(ctx, authString))
handshakeClient, err := fs.handshake(ctx)

if err != nil {
return nil, err
}

tkn, err := requestToken(handshakeClient, &flight.HandshakeRequest{Payload: []byte(authString)})
war := sessionpb2.WrappedAuthenticationRequest{
Type: authType,
Payload: []byte(authToken),
}
payload, err := proto.Marshal(&war)
if err != nil {
return nil, err
}
tkn, err := requestToken(handshakeClient, &flight.HandshakeRequest{Payload: []byte(payload)})

if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ private Promise<Void> authUpdate() {
info.fireEvent(EVENT_REFRESH_TOKEN_UPDATED, init);
}
}
handshake.end();
});
handshake.onStatus(status -> {
if (status.isOk()) {
Expand Down Expand Up @@ -526,6 +525,7 @@ private Promise<Void> authUpdate() {
});

handshake.send(new HandshakeRequest());
handshake.end();
});
}

Expand Down

0 comments on commit 7e63a4c

Please sign in to comment.