Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Support auth over non-TLS connections
Browse files Browse the repository at this point in the history
Signed-off-by: Haytham Abuelfutuh <[email protected]>
  • Loading branch information
EngHabu committed Apr 21, 2021
1 parent da45b9d commit 87fa28b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions clients/go/admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ func NewAdminConnection(ctx context.Context, cfg Config) (*grpc.ClientConn, erro
// TODO: as of Go 1.11.4, this is not supported on Windows. https://github.com/golang/go/issues/16736
creds := credentials.NewClientTLSFromCert(nil, "")
opts = append(opts, grpc.WithTransportCredentials(creds))
if cfg.UseAuth {
logger.Infof(ctx, "Instantiating a token source to authenticate against Admin, ID: %s", cfg.ClientID)
jwtDialOption, err := getAuthenticationDialOption(ctx, cfg, opts)
if err != nil {
return nil, err
}
opts = append(opts, jwtDialOption)
}

if cfg.UseAuth {
logger.Infof(ctx, "Instantiating a token source to authenticate against Admin, ID: %s", cfg.ClientID)
jwtDialOption, err := getAuthenticationDialOption(ctx, cfg, opts)
if err != nil {
return nil, err
}
opts = append(opts, jwtDialOption)
}

return grpc.Dial(cfg.Endpoint.String(), opts...)
Expand Down

0 comments on commit 87fa28b

Please sign in to comment.