From 5c8bacc0d30aec5849f66546ea83eea5f35d171a Mon Sep 17 00:00:00 2001 From: Cole Rogers Date: Tue, 23 Aug 2022 11:56:53 -0400 Subject: [PATCH 1/2] adding customClaims and sessionClaims to updateMask & fix tests --- integration_test/functions/src/index.ts | 2 +- spec/common/providers/identity.spec.ts | 15 +-------------- src/common/providers/identity.ts | 3 --- src/v2/providers/identity.ts | 2 +- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/integration_test/functions/src/index.ts b/integration_test/functions/src/index.ts index 3a5fd8474..a880c64ea 100644 --- a/integration_test/functions/src/index.ts +++ b/integration_test/functions/src/index.ts @@ -1,9 +1,9 @@ import { PubSub } from '@google-cloud/pubsub'; -import { GoogleAuth } from 'google-auth-library'; import { Request, Response } from 'express'; import * as admin from 'firebase-admin'; import * as functions from 'firebase-functions'; import * as fs from 'fs'; +import { GoogleAuth } from 'google-auth-library'; import fetch from 'node-fetch'; import * as v1 from './v1'; diff --git a/spec/common/providers/identity.spec.ts b/spec/common/providers/identity.spec.ts index 592d14767..2b2ea71e9 100644 --- a/spec/common/providers/identity.spec.ts +++ b/spec/common/providers/identity.spec.ts @@ -765,19 +765,6 @@ describe('identity', () => { expect(identity.getUpdateMask()).to.eq(''); }); - it('should return empty on only customClaims and sessionClaims', () => { - const response = { - customClaims: { - claim1: 'abc', - }, - sessionClaims: { - claim2: 'def', - }, - }; - - expect(identity.getUpdateMask(response)).to.eq(''); - }); - it('should return the right claims on a response', () => { const response = { displayName: 'john', @@ -793,7 +780,7 @@ describe('identity', () => { }; expect(identity.getUpdateMask(response)).to.eq( - 'displayName,disabled,emailVerified,photoURL' + 'displayName,disabled,emailVerified,photoURL,customClaims,sessionClaims' ); }); }); diff --git a/src/common/providers/identity.ts b/src/common/providers/identity.ts index 2c0ce0a2e..0a376be9e 100644 --- a/src/common/providers/identity.ts +++ b/src/common/providers/identity.ts @@ -799,9 +799,6 @@ export function getUpdateMask( } const updateMask: string[] = []; for (const key in authResponse) { - if (key === 'customClaims' || key === 'sessionClaims') { - continue; - } if ( authResponse.hasOwnProperty(key) && typeof authResponse[key] !== 'undefined' diff --git a/src/v2/providers/identity.ts b/src/v2/providers/identity.ts index 80d1cf0b8..eb03c747b 100644 --- a/src/v2/providers/identity.ts +++ b/src/v2/providers/identity.ts @@ -28,8 +28,8 @@ import { BlockingFunction } from '../../cloud-functions'; import { AuthBlockingEvent, - AuthUserRecord, AuthBlockingEventType, + AuthUserRecord, BeforeCreateResponse, BeforeSignInResponse, HttpsError, From ce1ef0f842f47b538e1c390ad6f0753637f78950 Mon Sep 17 00:00:00 2001 From: Cole Rogers Date: Tue, 23 Aug 2022 12:00:11 -0400 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29bb..d61eb5f0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ +- Fixes a bug that disallowed setting customClaims and/or sessionClaims in blocking functions (#1199).