Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Allow legacy stateless tokens that were minted without a password fingerprint.
Francis Cao3888ec6f4fa3
diff --git a/src/lib/auth.test.ts b/src/lib/auth.test.tsindex ff1c0b25c..fed2dad29 100644--- a/src/lib/auth.test.ts+++ b/src/lib/auth.test.ts@@ -66,6 +66,15 @@ describe('checkAuth password fingerprint', () => {expect(result?.user?.id).toBe('user-1');});+ test('authorizes a legacy stateless token that does not include a password fingerprint', async () => {+ parseSecureTokenMock.mockReturnValue({ userId: 'user-1' } as any);+ mockUser();++ const result = await checkAuth(authedRequest());++ expect(result?.user?.id).toBe('user-1');+ });+test('rejects a stateless token whose fingerprint predates a password change', async () => {// Token minted against the old password must stop working once the password changes.parseSecureTokenMock.mockReturnValue({diff --git a/src/lib/auth.ts b/src/lib/auth.tsindex 4450cd92a..559c7f90e 100644--- a/src/lib/auth.ts+++ b/src/lib/auth.ts@@ -32,7 +32,8 @@ export async function checkAuth(request: Request) {user = await getUser(userId, { includePassword: true });// Reject tokens issued before the current password.- if (user && hash(user.password) !== payload.pwd) {+ // Allow legacy stateless tokens that were minted without a password fingerprint.+ if (user && payload.pwd && hash(user.password) !== payload.pwd) {user = null;}} else if (redis.enabled && authKey) {