Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow empty string for client_secret in TokenClient #1738

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

ntamotsu
Copy link
Contributor

@ntamotsu ntamotsu commented Nov 19, 2024

Closes/fixes #1068 and #1438

Checklist

  • This PR makes changes to the public API
  • I have included links for closing relevant issue numbers

This pull request includes changes to the TokenClient class in the src/TokenClient.ts file to improve the handling of the client_secret parameter. The changes ensure that the client_secret is explicitly checked for undefined or null values, rather than using a falsy check. This modification allows empty strings as valid client_secret values when using client_secret_basic authentication method, which was previously rejected by the falsy check.

@@ -112,7 +112,7 @@ export class TokenClient {
let basicAuth: string | undefined;
switch (this._settings.client_authentication) {
case "client_secret_basic":
if (!client_secret) {
if (client_secret === undefined || client_secret === null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!client_secret is the same as client_secret === undefined || client_secret === null, both evaluate to true when client_secret is null or undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pamapa
Thanks for the feedback. You’re correct that !client_secret and client_secret === undefined || client_secret === null behave similarly when checking for null or undefined. However, the reason for the change is that I want to allow an empty string as a valid value.

Using !client_secret would exclude an empty string because it’s considered “falsy,” but by explicitly checking for undefined and null, I can ensure that empty strings are still permitted.

This is intentional, so I appreciate you pointing it out.

@pamapa pamapa changed the title fix: improve client_secret validation in TokenClient fix: allow empty string for client_secret in TokenClient Dec 18, 2024
@pamapa pamapa added this to the 3.1.1 milestone Dec 18, 2024
@pamapa pamapa changed the title fix: allow empty string for client_secret in TokenClient allow empty string for client_secret in TokenClient Dec 18, 2024
@pamapa pamapa merged commit 743783e into authts:main Dec 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Basic Auth Client Authentication with client_id Only
2 participants