Skip to content

Update Console domains for RTDB SDK #4154

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

Merged
merged 5 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/database/src/realtime/BrowserPollConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { StatsManager } from '../core/stats/StatsManager';
import { PacketReceiver } from './polling/PacketReceiver';
import {
APPLICATION_ID_PARAM,
FORGE_DOMAIN,
FORGE_DOMAIN_RE,
FORGE_REF,
LAST_SESSION_PARAM,
LONG_POLLING,
Expand Down Expand Up @@ -222,8 +222,8 @@ export class BrowserPollConnection implements Transport {
}
if (
typeof location !== 'undefined' &&
location.href &&
location.href.indexOf(FORGE_DOMAIN) !== -1
location.hostname &&
FORGE_DOMAIN_RE.test(location.hostname)
) {
urlParams[REFERER_PARAM] = FORGE_REF;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/database/src/realtime/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const REFERER_PARAM = 'r';

export const FORGE_REF = 'f';

export const FORGE_DOMAIN = 'firebaseio.com';
// Matches console.firebase.google.com and *.corp.google.com.
export const FORGE_DOMAIN_RE = /(console\.firebase|.*\.corp)\.google\.com/;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the regexp stricter to match firebase console under corp domain only? I'm worried it may brake some internal apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use firebase-console-\w*.corp as per Laura's suggestion.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it doesn't match the prod firebase corp URL: "firebase.corp.google.com" :-).

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a regular expression, so of course it is going to be buggy:) Fixed (and manually tested)

export const LAST_SESSION_PARAM = 'ls';

Expand Down
13 changes: 4 additions & 9 deletions packages/database/src/realtime/WebSocketConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@
*/

import { RepoInfo } from '../core/RepoInfo';
import {
assert,
jsonEval,
stringify,
isNodeSdk
} from '@firebase/util';
import { assert, jsonEval, stringify, isNodeSdk } from '@firebase/util';
import { logWrapper, splitStringBySize } from '../core/util/util';
import { StatsManager } from '../core/stats/StatsManager';
import {
FORGE_DOMAIN,
FORGE_DOMAIN_RE,
FORGE_REF,
LAST_SESSION_PARAM,
PROTOCOL_VERSION,
Expand Down Expand Up @@ -121,8 +116,8 @@ export class WebSocketConnection implements Transport {
if (
!isNodeSdk() &&
typeof location !== 'undefined' &&
location.href &&
location.href.indexOf(FORGE_DOMAIN) !== -1
location.hostname &&
FORGE_DOMAIN_RE.test(location.hostname)
) {
urlParams[REFERER_PARAM] = FORGE_REF;
}
Expand Down