gnodet opened a new pull request, #31279:
URL: https://github.com/apache/camel/pull/31279

   #### What type of PR is this?
   
   /kind bug
   
   #### What this PR does / why we need it:
   
   Fixes two bugs in `camel-cyberark-vault`:
   
   **Bug 1 — Wrong authentication endpoint for password login**
   
   `ConjurClientImpl.authenticate()` was sending the user's plaintext password 
directly to `POST /authn/{account}/{login}/authenticate`, which is the *API 
key* endpoint. The Conjur API requires a two-step flow for password 
authentication:
   
   1. `GET /authn/{account}/login` with `Authorization: Basic 
base64(username:password)` → returns the user's API key
   2. `POST /authn/{account}/{login}/authenticate` with that API key in the 
body → returns a short-lived access token
   
   With the old code, Conjur would reject the request with HTTP 401 (the API 
key endpoint does not accept a password), so password-based authentication was 
completely broken.
   
   **Bug 2 — `camel.vault.cyberark.secrets` option unused**
   
   `CyberArkVaultConfiguration.secrets` was defined (with Javadoc saying "Not 
used") but never read by `CyberArkVaultPropertiesFunction`. The properties 
function maintains an internal `secrets` set that it populates as secrets are 
resolved at runtime, but it never primed this set from the configuration. This 
meant the option had no effect. The fix reads the comma-separated `secrets` 
value at startup and adds the entries to the internal set, making it available 
to callers (such as a future reload-trigger task) before the first `apply()` 
call.
   
   #### Does this PR introduce a user-facing change?
   
   ```
   * `camel-cyberark-vault`: password authentication now correctly uses `GET 
/authn/{account}/login`
     (HTTP Basic) to exchange credentials for an API key before calling the 
authenticate endpoint.
     Previously, password auth always failed with HTTP 401.
   * `camel-cyberark-vault`: the `camel.vault.cyberark.secrets` configuration 
option now pre-populates
     the set of tracked secrets, making it visible before the first property 
resolution.
   ```
   
   #### Additional information
   
   - Conjur REST API reference: 
https://docs.conjur.org/Latest/en/Content/Developer/Conjur_API_Authenticate.htm
   - New test `ConjurClientPasswordAuthTest` verifies that password auth calls 
`GET /authn/{account}/login` with Basic auth and that the password never 
reaches the authenticate endpoint body.
   - New test `CyberArkVaultPropertiesFunctionSecretsTest` verifies that 
secrets listed in `camel.vault.cyberark.secrets` are pre-populated before 
`apply()` is called.
   - Existing `ConjurClientReauthenticationTest` updated: the fake Conjur 
server now correctly distinguishes `GET /login` (returns API key, no token 
counter) from `POST /authenticate` (increments token counter), matching real 
Conjur behaviour.
   
   _Hermès on behalf of gnodet_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to