mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-22 18:34:08 +01:00
🔧 feat: Add support for PKCE in OpenID strategy configuration
This commit is contained in:
parent
f74b9a3018
commit
ec5c9fef48
3 changed files with 50 additions and 18 deletions
|
|
@ -98,6 +98,7 @@ describe('setupOpenId', () => {
|
|||
delete process.env.OPENID_USERNAME_CLAIM;
|
||||
delete process.env.OPENID_NAME_CLAIM;
|
||||
delete process.env.PROXY;
|
||||
delete process.env.OPENID_USE_PKCE;
|
||||
|
||||
// By default, jwtDecode returns a token that includes the required role.
|
||||
jwtDecode.mockReturnValue({
|
||||
|
|
@ -393,4 +394,29 @@ describe('setupOpenId', () => {
|
|||
);
|
||||
expect(user.avatar).toBe(existingUser.avatar);
|
||||
});
|
||||
|
||||
it('should pass usePKCE true and set code_challenge_method in params when OPENID_USE_PKCE is "true"', async () => {
|
||||
process.env.OPENID_USE_PKCE = 'true';
|
||||
await setupOpenId();
|
||||
// Get the options from the last call of OpenIDStrategy
|
||||
const callOptions = OpenIDStrategy.mock.calls[OpenIDStrategy.mock.calls.length - 1][0];
|
||||
expect(callOptions.usePKCE).toBe(true);
|
||||
expect(callOptions.params.code_challenge_method).toBe('S256');
|
||||
});
|
||||
|
||||
it('should pass usePKCE false and not set code_challenge_method in params when OPENID_USE_PKCE is "false"', async () => {
|
||||
process.env.OPENID_USE_PKCE = 'false';
|
||||
await setupOpenId();
|
||||
const callOptions = OpenIDStrategy.mock.calls[OpenIDStrategy.mock.calls.length - 1][0];
|
||||
expect(callOptions.usePKCE).toBe(false);
|
||||
expect(callOptions.params.code_challenge_method).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should default to usePKCE false when OPENID_USE_PKCE is not defined', async () => {
|
||||
delete process.env.OPENID_USE_PKCE;
|
||||
await setupOpenId();
|
||||
const callOptions = OpenIDStrategy.mock.calls[OpenIDStrategy.mock.calls.length - 1][0];
|
||||
expect(callOptions.usePKCE).toBe(false);
|
||||
expect(callOptions.params.code_challenge_method).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue