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] Support https scheme for auth emulator #2606

Open
jdolieslager opened this issue Jun 20, 2024 · 0 comments
Open

[FR] Support https scheme for auth emulator #2606

jdolieslager opened this issue Jun 20, 2024 · 0 comments

Comments

@jdolieslager
Copy link

Is your feature request related to a problem? Please describe.
We're running our emulator suite over https. The auth-api-requests.ts is forcing the scheme http:// which results we're not able to call our emulator suite.

Describe the solution you'd like
I would like to support https by introducing a new environment variable FIREBASE_AUTH_EMULATOR_SCHEME which will default to http, but when set it would use that scheme. Other solution would be that we can change the format itself.

Describe alternatives you've considered
We now local patched the JS file to change the format.

Additional context

Current

auth-api-request.ts

/** Firebase Auth base URlLformat when using the auth emultor. */
const FIREBASE_AUTH_EMULATOR_BASE_URL_FORMAT =
  'http://{host}/identitytoolkit.googleapis.com/{version}/projects/{projectId}{api}';

Proposed

/** Firebase Auth base URlLformat when using the auth emultor. */
const FIREBASE_AUTH_EMULATOR_BASE_URL_FORMAT =
  '{scheme}://{host}/identitytoolkit.googleapis.com/{version}/projects/{projectId}{api}';

class AuthResourceUrlBuilder {

  protected urlFormat: string;
  private projectId: string;

  /**
   * The resource URL builder constructor.
   *
   * @param projectId - The resource project ID.
   * @param version - The endpoint API version.
   * @constructor
   */
  constructor(protected app: App, protected version: string = 'v1') {
    if (useEmulator()) {
      this.urlFormat = utils.formatString(FIREBASE_AUTH_EMULATOR_BASE_URL_FORMAT, {
        host: emulatorHost(),
        scheme: emulatorScheme() || 'http'
      });
    } else {
      this.urlFormat = FIREBASE_AUTH_BASE_URL_FORMAT;
    }
  }

 // ......
}

function emulatorHost(): string | undefined {
  return process.env.FIREBASE_AUTH_EMULATOR_HOST
}

function emulatorScheme(): string | undefined {
  return process.env.FIREBASE_AUTH_EMULATOR_SCHEME
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant