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

refactor!: Revamp apiEndpoint #821

Open
danielbankhead opened this issue Jun 14, 2024 · 0 comments
Open

refactor!: Revamp apiEndpoint #821

danielbankhead opened this issue Jun 14, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@danielbankhead
Copy link
Member

With the advent of TPC and PSC, there’s a lot of complexity with apiEndpoints. To improve, we should:

  • expose an async Storage#getEndpoint() method
  • make the apiEndpoint property private
  • remove the useAuthWithCustomEndpoint parameter/property
  • remove the internal customEndpoint parameter/property

Additionally, if STORAGE_EMULATOR_HOST is detected and used the PassThrough AuthClient should be used by default (which can be overwritten via the existing authClient parameter) - removing the need for the useAuthWithCustomEndpoint parameter.

This will greatly clean-up the code base as:

  • Customers will not be required to manually provide the universeDomain - as we can determine it asynchronously via GoogleAuth#getUniverseDomain. This is a major convenience for TPC customers.
  • We can offer a predictable, secure experience by not disabling auth by default when an apiEndpoint has been provided
  • Classes will no longer have to distinguish between auth and non-auth contexts - we can simply use auth everywhere uniformly

Related:

We this change we can remove the following:

nodejs-common/src/util.ts

Lines 140 to 148 in 0b4380a

/**
* If true, just return the provided request options. Default: false.
*/
customEndpoint?: boolean;
/**
* If true, will authenticate when using a custom endpoint. Default: false.
*/
useAuthWithCustomEndpoint?: boolean;

nodejs-common/src/util.ts

Lines 766 to 777 in 0b4380a

const authorizeRequest = async () => {
if (
reqConfig.customEndpoint &&
!reqConfig.useAuthWithCustomEndpoint
) {
// Using a custom API override. Do not use `google-auth-library` for
// authentication. (ex: connecting to a local Datastore server)
return reqOpts;
} else {
return authClient.authorizeRequest(reqOpts);
}
};

@danielbankhead danielbankhead added priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. 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

1 participant