Skip to content

Commit

Permalink
Fixes a bug that disallowed setting customClaims and/or sessionClaims…
Browse files Browse the repository at this point in the history
… in blocking functions (#1199)

* adding customClaims and sessionClaims to updateMask & fix tests

* add changelog
  • Loading branch information
colerogers authored Aug 23, 2022
1 parent f751f5c commit f9ecee4
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixes a bug that disallowed setting customClaims and/or sessionClaims in blocking functions (#1199).
2 changes: 1 addition & 1 deletion integration_test/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
15 changes: 1 addition & 14 deletions spec/common/providers/identity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -793,7 +780,7 @@ describe('identity', () => {
};

expect(identity.getUpdateMask(response)).to.eq(
'displayName,disabled,emailVerified,photoURL'
'displayName,disabled,emailVerified,photoURL,customClaims,sessionClaims'
);
});
});
Expand Down
3 changes: 0 additions & 3 deletions src/common/providers/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/v2/providers/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import { BlockingFunction } from '../../cloud-functions';
import {
AuthBlockingEvent,
AuthUserRecord,
AuthBlockingEventType,
AuthUserRecord,
BeforeCreateResponse,
BeforeSignInResponse,
HttpsError,
Expand Down

0 comments on commit f9ecee4

Please sign in to comment.