Skip to content

Commit

Permalink
Fix more issues related to admin auth and appcheck. (#5146)
Browse files Browse the repository at this point in the history
* Pass auth token to the connection, and use Bearer in the header value

* Add changeset.

* Don't use lastSessionId as transportSessionId.
  • Loading branch information
jsdt committed Jul 14, 2021
1 parent cca8d4b commit fb3e359
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-pets-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/database': patch
---

Fix sending of auth tokens on node.
2 changes: 2 additions & 0 deletions packages/database/src/realtime/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export class Connection {
this.repoInfo_,
this.applicationId_,
this.appCheckToken_,
this.authToken_,
null,
this.lastSessionId
);

Expand Down
4 changes: 2 additions & 2 deletions packages/database/src/realtime/WebSocketConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class WebSocketConnection implements Transport {
// Note that this header is just used to bypass appcheck, and the token should still be sent
// through the websocket connection once it is established.
if (this.authToken) {
options.headers['Authorization'] = this.authToken;
options.headers['Authorization'] = `Bearer ${this.authToken}`;
}
if (this.appCheckToken) {
options.headers['X-Firebase-AppCheck'] = this.appCheckToken;
Expand Down Expand Up @@ -238,7 +238,7 @@ export class WebSocketConnection implements Transport {
/**
* No-op for websockets, we don't need to do anything once the connection is confirmed as open
*/
start() { }
start() {}

static forceDisallow_: boolean;

Expand Down

0 comments on commit fb3e359

Please sign in to comment.