Skip to content

Manage null in BasicAuthHelper to avoid NPE#50925

Merged
ahus1 merged 1 commit into
keycloak:mainfrom
rmartinc:issue-50791
Jul 16, 2026
Merged

Manage null in BasicAuthHelper to avoid NPE#50925
ahus1 merged 1 commit into
keycloak:mainfrom
rmartinc:issue-50791

Conversation

@rmartinc

Copy link
Copy Markdown
Contributor

Closes #50791

Little PR to send empty username/password in the authentication header if the parameter is null. Currently it throws a NPE in the RFC6749 version and string null in teh common method.

Closes keycloak#50791

Signed-off-by: rmartinc <rmartinc@redhat.com>
Copilot AI review requested due to automatic review settings July 15, 2026 13:24
@rmartinc
rmartinc requested a review from a team as a code owner July 15, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents null credentials from causing an NPE or producing the literal "null" in Basic authentication headers.

Changes:

  • Converts null usernames and passwords to empty strings.
  • Adds coverage for standard and RFC 6749 header handling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/src/main/java/org/keycloak/util/BasicAuthHelper.java Safely handles null credentials.
core/src/test/java/org/keycloak/util/BasicAuthHelperTest.java Tests null username and password behavior.

@gaoyikeshuer gaoyikeshuer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @rmartinc , I have reviewed it. It looks good to me

@ahus1
ahus1 merged commit cfdd75f into keycloak:main Jul 16, 2026
91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE thrown on null secret in AbstractOauth2IdentityProdivder

5 participants