Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions projects/lib/src/oauth-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,20 @@ describe('OAuthService', () => {

await expectAsync(revokePromise).toBeResolved();
});

it('decodes userState from code-flow state (no double encoding)', async () => {
service.configure({
clientId: 'test-client',
loginUrl: 'https://auth.example.com/auth',
responseType: 'code',
});

const original =
'/titles/automation-dashboard?pageSize=25&page=1&title_id_name=finals';
const url = await (service as any).createLoginUrl(original);
const stateParam = new URL(url).searchParams.get('state');
const [, userState] = (service as any).parseState(stateParam);

expect(userState).toBe(original);
});
});
2 changes: 1 addition & 1 deletion projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
userState = state.substr(idx + this.config.nonceStateSeparator.length);
}
}
return [nonce, userState];
return [nonce, decodeURIComponent(userState)];
}

protected validateNonce(nonceInState: string): boolean {
Expand Down