Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
feature to toggle off pkce (authts#897)
Browse files Browse the repository at this point in the history
* feature to disable pkce
  • Loading branch information
satanshiro authored Feb 17, 2023
1 parent da8c80d commit 23bf295
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 125 deletions.
9 changes: 7 additions & 2 deletions docs/oidc-client-ts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export interface OidcClientSettings {
client_secret?: string;
// @deprecated (undocumented)
clockSkewInSeconds?: number;
disablePKCE?: boolean;
display?: string;
extraQueryParams?: Record<string, string | number | boolean>;
// (undocumented)
Expand Down Expand Up @@ -373,7 +374,7 @@ export interface OidcClientSettings {

// @public
export class OidcClientSettingsStore {
constructor({ authority, metadataUrl, metadata, signingKeys, metadataSeed, client_id, client_secret, response_type, scope, redirect_uri, post_logout_redirect_uri, client_authentication, prompt, display, max_age, ui_locales, acr_values, resource, response_mode, filterProtocolClaims, loadUserInfo, staleStateAgeInSeconds, clockSkewInSeconds, userInfoJwtIssuer, mergeClaims, stateStore, refreshTokenCredentials, revokeTokenAdditionalContentTypes, fetchRequestCredentials, refreshTokenAllowedScope, extraQueryParams, extraTokenParams, }: OidcClientSettings);
constructor({ authority, metadataUrl, metadata, signingKeys, metadataSeed, client_id, client_secret, response_type, scope, redirect_uri, post_logout_redirect_uri, client_authentication, prompt, display, max_age, ui_locales, acr_values, resource, response_mode, filterProtocolClaims, loadUserInfo, staleStateAgeInSeconds, clockSkewInSeconds, userInfoJwtIssuer, mergeClaims, disablePKCE, stateStore, refreshTokenCredentials, revokeTokenAdditionalContentTypes, fetchRequestCredentials, refreshTokenAllowedScope, extraQueryParams, extraTokenParams, }: OidcClientSettings);
// (undocumented)
readonly acr_values: string | undefined;
// (undocumented)
Expand All @@ -387,6 +388,8 @@ export class OidcClientSettingsStore {
// (undocumented)
readonly clockSkewInSeconds: number;
// (undocumented)
readonly disablePKCE: boolean;
// (undocumented)
readonly display: string | undefined;
// (undocumented)
readonly extraQueryParams: Record<string, string | number | boolean>;
Expand Down Expand Up @@ -619,7 +622,7 @@ export type SigninRedirectArgs = RedirectParams & ExtraSigninRequestArgs;

// @public (undocumented)
export class SigninRequest {
constructor({ url, authority, client_id, redirect_uri, response_type, scope, state_data, response_mode, request_type, client_secret, nonce, resource, skipUserInfo, extraQueryParams, extraTokenParams, ...optionalParams }: SigninRequestArgs);
constructor({ url, authority, client_id, redirect_uri, response_type, scope, state_data, response_mode, request_type, client_secret, nonce, resource, skipUserInfo, extraQueryParams, extraTokenParams, disablePKCE, ...optionalParams }: SigninRequestArgs);
// (undocumented)
readonly state: SigninState;
// (undocumented)
Expand All @@ -637,6 +640,8 @@ export interface SigninRequestArgs {
// (undocumented)
client_secret?: string;
// (undocumented)
disablePKCE?: boolean;
// (undocumented)
display?: string;
// (undocumented)
extraQueryParams?: Record<string, string | number | boolean>;
Expand Down
1 change: 1 addition & 0 deletions src/OidcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class OidcClient {
client_secret: this.settings.client_secret,
skipUserInfo,
nonce,
disablePKCE: this.settings.disablePKCE,
});

// house cleaning
Expand Down
11 changes: 8 additions & 3 deletions src/OidcClientSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export interface OidcClientSettings {
* Will check the content type header of the response of the revocation endpoint to match these passed values (default: [])
*/
revokeTokenAdditionalContentTypes?: string[];

/**
* Will disable pkce validation, changing to true will not append to sign in request code_challenge and code_challenge_method. (default: false)
*/
disablePKCE?: boolean;
/**
* Sets the credentials for fetch requests. (default: "same-origin")
* Use this if you need to send cookies to the OIDC/OAuth2 provider or if you are using a proxy that requires cookies
Expand Down Expand Up @@ -178,7 +181,8 @@ export class OidcClientSettingsStore {
public readonly revokeTokenAdditionalContentTypes?: string[];
public readonly fetchRequestCredentials: RequestCredentials;
public readonly refreshTokenAllowedScope: string | undefined;

public readonly disablePKCE: boolean;

public constructor({
// metadata related
authority, metadataUrl, metadata, signingKeys, metadataSeed,
Expand All @@ -195,6 +199,7 @@ export class OidcClientSettingsStore {
clockSkewInSeconds = DefaultClockSkewInSeconds,
userInfoJwtIssuer = "OP",
mergeClaims = false,
disablePKCE = false,
// other behavior
stateStore,
refreshTokenCredentials,
Expand Down Expand Up @@ -246,7 +251,7 @@ export class OidcClientSettingsStore {
this.clockSkewInSeconds = clockSkewInSeconds;
this.userInfoJwtIssuer = userInfoJwtIssuer;
this.mergeClaims = !!mergeClaims;

this.disablePKCE = !!disablePKCE;
this.revokeTokenAdditionalContentTypes = revokeTokenAdditionalContentTypes;

if (fetchRequestCredentials && refreshTokenCredentials) {
Expand Down
Loading

0 comments on commit 23bf295

Please sign in to comment.