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

[Backport 1.26.x] [GWC-1363] Support Environment Parametrization for WMSLayer Credentials #1376

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

geoserver-bot
Copy link
Collaborator

Backport #1364
Authored by: @groldan

This commit enhances security and configurability by enabling dynamic runtime
resolution of HTTP Basic Authentication credentials for WMS layers. Credentials
can now be injected from environment variables, reducing the need to hardcode
sensitive values. This improves code maintainability, supports secure multi-
environment deployments, and simplifies testing through dynamic configuration.

1. **Dynamic Environment Parametrization**:
   - Introduced `GeoWebCacheEnvironment#isAllowEnvParametrization()` to replace
     the static `ALLOW_ENV_PARAMETRIZATION` field, allowing runtime toggling.

2. **Environment Variable Resolution Refactor**:
   - Replaced direct static field checks with method calls.
   - Updated `resolveValue()` and related methods to use environment variables
     dynamically.

3. **WMS Credentials Management Update**:
   - Added `getResolvedHttpUsername()` and `getResolvedHttpPassword()` in
     `WMSHttpHelper`.
   - Created `setGeoWebCacheEnvironment()` for dependency injection.

4. **Testing Enhancements**:
   - Integrated the `system-rules` library for environment variable manipulation.
   - Added tests to cover default, custom, and parameterized credentials.

5. **Code Improvements**:
   - Replaced unsafe casts in `resolveValue()`.
   - Improved exception handling by switching from `Throwable` to
     `RuntimeException`.
   - Added better logging and documentation for credential handling.
@groldan groldan merged commit 4984457 into 1.26.x Feb 24, 2025
10 checks passed
@groldan groldan deleted the backport-1364-to-1.26.x branch February 24, 2025 16:39
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.

2 participants