Skip to content

Commit 4683e65

Browse files
committed
Increased minimum expiry for custom token to 5 mins (as per #1016 (comment))
1 parent 879bda8 commit 4683e65

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/auth/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ export namespace auth {
951951
developerClaims?: { [key: string]: any };
952952

953953
/**
954-
* The JWT expiration in milliseconds. The minimum allowed is X and the maximum allowed is 1 hour.
954+
* The JWT expiration in milliseconds. The minimum allowed is 5 minutes and the maximum allowed is 1 hour.
955955
* Defaults to 1 hour.
956956
*/
957957
expiresIn?: number;

src/auth/token-generator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { HttpError } from '../utils/api-request';
2727

2828
const ALGORITHM_NONE: Algorithm = 'none' as const;
2929

30-
const MIN_JWT_EXPIRES_IN_MS = 1000;
30+
const MIN_JWT_EXPIRES_IN_MS = 5 * 60 * 1000;
3131
const ONE_HOUR_IN_MS = 60 * 60 * 1000;
3232

3333
// List of blacklisted claims which cannot be provided when creating a custom token

test/unit/auth/token-generator.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe('FirebaseTokenGenerator', () => {
212212
});
213213

214214
it('should throw given an invalid expiresIn', () => {
215-
const invalidExpiresIns: any[] = [null, NaN, Infinity, _.noop, 0, 999, 3600001];
215+
const invalidExpiresIns: any[] = [null, NaN, Infinity, _.noop, 0, 299999, 3600001];
216216
invalidExpiresIns.forEach((invalidExpiresIn) => {
217217
expect(() => {
218218
tokenGenerator.createCustomToken(mocks.uid, { expiresIn: invalidExpiresIn });
@@ -233,7 +233,7 @@ describe('FirebaseTokenGenerator', () => {
233233
});
234234

235235
it('should be fulfilled given a valid uid, empty object developer claims and valid expiresIn', () => {
236-
return tokenGenerator.createCustomToken(mocks.uid, { developerClaims: {}, expiresIn: 1000 });
236+
return tokenGenerator.createCustomToken(mocks.uid, { developerClaims: {}, expiresIn: 300000 });
237237
});
238238

239239
it('should be fulfilled given a valid uid, valid developer claims and valid expiresIn', () => {

0 commit comments

Comments
 (0)