Skip to content

Commit f9ecee4

Browse files
authored
Fixes a bug that disallowed setting customClaims and/or sessionClaims in blocking functions (#1199)
* adding customClaims and sessionClaims to updateMask & fix tests * add changelog
1 parent f751f5c commit f9ecee4

File tree

5 files changed

+4
-19
lines changed

5 files changed

+4
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixes a bug that disallowed setting customClaims and/or sessionClaims in blocking functions (#1199).

integration_test/functions/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { PubSub } from '@google-cloud/pubsub';
2-
import { GoogleAuth } from 'google-auth-library';
32
import { Request, Response } from 'express';
43
import * as admin from 'firebase-admin';
54
import * as functions from 'firebase-functions';
65
import * as fs from 'fs';
6+
import { GoogleAuth } from 'google-auth-library';
77
import fetch from 'node-fetch';
88

99
import * as v1 from './v1';

spec/common/providers/identity.spec.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -765,19 +765,6 @@ describe('identity', () => {
765765
expect(identity.getUpdateMask()).to.eq('');
766766
});
767767

768-
it('should return empty on only customClaims and sessionClaims', () => {
769-
const response = {
770-
customClaims: {
771-
claim1: 'abc',
772-
},
773-
sessionClaims: {
774-
claim2: 'def',
775-
},
776-
};
777-
778-
expect(identity.getUpdateMask(response)).to.eq('');
779-
});
780-
781768
it('should return the right claims on a response', () => {
782769
const response = {
783770
displayName: 'john',
@@ -793,7 +780,7 @@ describe('identity', () => {
793780
};
794781

795782
expect(identity.getUpdateMask(response)).to.eq(
796-
'displayName,disabled,emailVerified,photoURL'
783+
'displayName,disabled,emailVerified,photoURL,customClaims,sessionClaims'
797784
);
798785
});
799786
});

src/common/providers/identity.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,6 @@ export function getUpdateMask(
799799
}
800800
const updateMask: string[] = [];
801801
for (const key in authResponse) {
802-
if (key === 'customClaims' || key === 'sessionClaims') {
803-
continue;
804-
}
805802
if (
806803
authResponse.hasOwnProperty(key) &&
807804
typeof authResponse[key] !== 'undefined'

src/v2/providers/identity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import { BlockingFunction } from '../../cloud-functions';
2929
import {
3030
AuthBlockingEvent,
31-
AuthUserRecord,
3231
AuthBlockingEventType,
32+
AuthUserRecord,
3333
BeforeCreateResponse,
3434
BeforeSignInResponse,
3535
HttpsError,

0 commit comments

Comments
 (0)