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

[GWC-1363] Support Environment Parametrization for WMSLayer Credentials #1364

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

groldan
Copy link
Member

@groldan groldan commented Feb 9, 2025

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.

Fixes #1363

@groldan groldan force-pushed the wmslayer_http_credentials_env_variables branch from d28c710 to 8871694 Compare February 9, 2025 20:53
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 force-pushed the wmslayer_http_credentials_env_variables branch from 8871694 to e3c9c90 Compare February 12, 2025 19:57
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 Environment Parametrization for WMSLayer Credentials
2 participants