Skip to content

feat(config): HTTP Basic Authentication credentials (builds on #89)#152

Merged
epugh merged 4 commits into
apache:mainfrom
adityamparikh:feat/basic-auth-support
Jun 15, 2026
Merged

feat(config): HTTP Basic Authentication credentials (builds on #89)#152
epugh merged 4 commits into
apache:mainfrom
adityamparikh:feat/basic-auth-support

Conversation

@adityamparikh

Copy link
Copy Markdown
Contributor

Summary

Adds optional HTTP Basic Authentication for the SolrJ client. This builds directly on #89 by @dolphinium — it carries their original feature commit unchanged and adds a small review-cleanup commit on top.

Credit for the feature belongs to @dolphinium (original PR: #89). This PR exists to fold in the feedback from a code review + simplification pass so the change can land clean.

What's included

dolphinium's feature commit (unchanged): optional solr.username / solr.password properties (bound from SOLR_USERNAME / SOLR_PASSWORD), applied via HttpJdkSolrClient.Builder#withBasicAuthCredentials only when both are present. Fully backwards-compatible — existing unauthenticated deployments are unaffected.

Review cleanup commit (no behavioural change):

  • SolrConfig: replace the inline username != null && !username.isEmpty() guard with Spring's StringUtils.hasText(username), matching the convention already used in HttpSecurityConfiguration and SearchService.
  • SolrConfigAuthTest: drop the hand-rolled superclass-walking findField helper for ReflectionUtils.findField / makeAccessible / getField, and tighten the over-defensive equals(x) || equals("Basic " + x) assertion to an exact assertEquals (verified against solr-solrj:10.0.0: the client stores "Basic " + Base64(user:pass) in UTF-8).

Tests

  • SolrConfigAuthTest: parameterized coverage of none / username-only / password-only / blank-username / both.
  • SolrConfigUrlNormalizationTest: updated to the new record constructor.
  • ./gradlew build passes locally (Spotless + NullAway + full unit/integration suite incl. Testcontainers).

Notes

🤖 Generated with Claude Code

dolphinium and others added 2 commits June 2, 2026 18:43
Add optional `solr.username` / `solr.password` configuration properties
(also bound from the `SOLR_USERNAME` / `SOLR_PASSWORD` environment
variables) that, when both are set, are applied to every SolrJ request
via `HttpJdkSolrClient.Builder#withBasicAuthCredentials`. When either
value is missing or the username is blank, the client is built without
credentials so existing unauthenticated deployments are unaffected.

Documents the new variables in the Development and Architecture guides
and adds `SolrConfigAuthTest` covering:

- no credentials attached when both values are missing,
- no credentials attached when only one value is provided (or the
  username is blank), and
- credentials applied when both values are provided.

The existing `SolrConfigUrlNormalizationTest` is updated to the new
record constructor.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Yunus Emre Korkmaz <yunus.emre.korkmaz@turboard.com>
…uth wiring

Review cleanup on top of the HTTP Basic Auth support from #89 (by
@dolphinium). No behavioural change to the feature.

- SolrConfig: replace the inline `username != null && !username.isEmpty()`
  guard with Spring's `StringUtils.hasText`, matching the convention already
  used in HttpSecurityConfiguration and SearchService.
- SolrConfigAuthTest: drop the hand-rolled superclass-walking `findField`
  helper in favour of `ReflectionUtils.findField`/`makeAccessible`/`getField`,
  and tighten the over-defensive `equals(x) || equals("Basic " + x)` assertion
  to an exact `assertEquals` now that the stored format is known (SolrJ stores
  `"Basic " + Base64(user:pass)` in UTF-8).

./gradlew build passes (Spotless + NullAway + full test suite incl. Testcontainers).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
@epugh epugh merged commit ab42b64 into apache:main Jun 15, 2026
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.

3 participants