Skip to content
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

Fixes a bug that disallowed setting customClaims and/or sessionClaims in blocking functions #1199

Merged
merged 2 commits into from Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -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
@@ -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
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
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
Expand Up @@ -28,8 +28,8 @@
import { BlockingFunction } from '../../cloud-functions';
import {
AuthBlockingEvent,
AuthUserRecord,
AuthBlockingEventType,
AuthUserRecord,
BeforeCreateResponse,
BeforeSignInResponse,
HttpsError,
Expand Down