Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: gax-fallback support for options.sslCreds and "insecure credentials" #1409

Open
MarkDuckworth opened this issue Jan 19, 2023 · 2 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@MarkDuckworth
Copy link

When using gax-fallback we would like support for passing credentials via options.sslCreds. These ssl creds will be used by the fallback instead of initializing the auth client (as done in gax grpc).

Additionally, the gax fallback needs a method similar to grpc.credentials.createInsecure(), which creates a credential that when passed via options.sslCreds, will be detected by the fallback transport and cause it to use the fake auth client. As Alex suggested, a possible solution is to create getInsecureCredentials() in google-gax (both in grpc and fallback) that creates and returns these credentials.

Why? In nodejs-firestore customers are facing an issue where the client is unable to generate credentials when connecting to the emulator using REST transport over http (1811). Several workarounds were investigated, including (1812). But the workarounds faced their own challenges with the initialization of GoogleAuth. Ultimately, we believe it's better to have gax and gax-fallback behavior be consistent with respect to support for options.sslCreds.

@MarkDuckworth MarkDuckworth added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jan 19, 2023
@bcoe
Copy link
Contributor

bcoe commented Jan 31, 2023

@MarkDuckworth if you could share a one pager that describes what the interface would look like in gax-nodejs, and a consuming library like nodejs-firestore, we'd happily take this contribution.

@alexander-fenster
Copy link
Contributor

alexander-fenster commented Jan 31, 2023

Just to give you some details, right now, if we want to initiate an insecure connection (without any authentication, which is useful in tests and/or against an emulator), we need to jump through some hoops:

// Fake auth client for fallback
const authStub = {
  async getClient() {
    return {
      async getRequestHeaders() {
        return {Authorization: 'Bearer SOME_TOKEN'};
      }
    };
  },
};

// initialize HTTP client with no authentication
const client = new Library.SomeClient({auth: authStub, fallback: 'rest'});

The proposed change will make it look something like

const client = new Library.SomeClient({fallback: 'rest', sslCreds: gax.fallback.getInsecureCredentials()});

For comparison, right now, to achieve this with gRPC, one would need to do

const client = new Library.SomeClient({sslCreds: grpc.credentials.createInsecure()});

and the proposed interface (gax.getInsecureCredentials() and gax.fallback.getInsecureCredentials()) would replace the need to import grpc directly, and will make the initialization similar for both gRPC and HTTP.

galz10 pushed a commit to galz10/gax-nodejs that referenced this issue May 15, 2023
googleapis#1409) (googleapis#1220)

This reverts commit e1557e468fd986c952ba718d9ff90e1d87390209.
Source-Link: googleapis/synthtool@8a475dc
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:ba0957cb15a1b8ca7ec2795c7783cd09cb68be2de9f4a7c69aa15b759c622735
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants