[ 
https://issues.apache.org/jira/browse/KNOX-3621?focusedWorklogId=1057230&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1057230
 ]

ASF GitHub Bot logged work on KNOX-3621:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Nov/26 10:53
            Start Date: 26/Nov/26 10:53
    Worklog Time Spent: 10m 
      Work Description: smolnar82 opened a new pull request, #1551:
URL: https://github.com/apache/knox/pull/1551

   [KNOX-3621](https://issues.apache.org/jira/browse/KNOX-3621) - Make the 
KnoxIDF token endpoint's user params lookup non-fatal and configurable
   
   ## What changes were proposed in this pull request?
   
   With the LDAP user params provider (`user.params.provider.ldap.*`) 
configured, the `authorization_code` and `refresh_token` grants look up the 
user in LDAP to add optional claims (name, email, roles, ...) to the access 
token. Any failure of that lookup (LDAP unreachable, bind failure, 
misconfiguration) escaped as an unhandled `RuntimeException`, so the grant 
failed with a 500. The auth code / refresh token is consumed before the lookup, 
so the client could not even retry with it. `/userinfo` looks the user up again 
anyway, so on the token endpoint the lookup is optional enrichment.
   
   - **Token endpoint: a failed lookup no longer fails the grant.** The token 
is issued without the user params claims, a WARN is logged (stack trace at 
DEBUG), and the grant's audit entry records `user_params=unavailable`.
   - **New KnoxIDF service param `knoxidf.token.user.params.enabled`** (default 
`true`, i.e. unchanged behavior). When `false`, the token endpoint uses the 
empty provider and never contacts LDAP; `/userinfo` still uses the configured 
provider. `UserParamsProviderFactory.getUserParamsProvider(ServletContext)` 
honors the switch (token endpoint), `getUserParamsProvider(ServletContext, 
true)` ignores it (`/userinfo`).
   - **`/userinfo`: a failed lookup answers `503` `temporarily_unavailable`** 
with a WARN and audit `reason=user_params_unavailable`, instead of a 500. 
Returning an empty profile would wrongly tell the client the user has no such 
claims.
   - **`LdapUserParamsProvider` logs static misconfiguration once at startup** 
as ERROR (missing/unresolvable `systemPasswordAlias`, search filter without 
`{0}`). The per-lookup fail-closed checks are unchanged and use the same 
messages.
   - New `KnoxIDFMessages` i18n interface for the above log messages.
   - Docs: `knox-site/docs/knoxidf/configuration.md` documents the new param 
and the failure behavior.
   
   Note: services that authorize on a user params claim in the access token 
(e.g. `roles`) will see a token without it if LDAP was down when the token was 
issued, until the token expires or is refreshed.
   
   ## How was this patch tested?
   
   - New unit tests:
     - `TokenResourceUserParamsTest`: auth code and refresh grants with a 
failing provider return 200 and audit `user_params=unavailable`; a successful 
lookup records nothing extra.
     - `UserInfoResourceUserParamsTest`: failing provider -> 503 
`temporarily_unavailable` with a FAILURE audit 
`reason=user_params_unavailable`; successful provider -> claims served.
     - `UserParamsProviderFactoryTest`: provider selection with/without LDAP 
URL, switch unset/`true`/`false`/`FALSE`, and the explicit overload ignoring 
the switch.
     - Existing `LdapUserParamsProviderTest` covers constructing the provider 
with a missing/unresolvable alias and bad filters (now logged, still not 
thrown).
   - `mvn -pl gateway-service-knoxidf verify`: 312 tests pass; checkstyle, PMD, 
spotbugs, forbiddenapis, RAT and jacoco pass.
   
   ## Integration Tests
   
   No integration test added: the new behavior only shows when the LDAP lookup 
fails (or with the switch turned off), and the compose setup has no way to take 
LDAP down mid-flow. The default path (switch unset, LDAP reachable) is 
unchanged and remains covered by the existing KnoxIDF suites. No opt-in labels 
needed.
   
   ## Performance implications
   
   - Default (`knoxidf.token.user.params.enabled` unset/`true`): no change, one 
LDAP lookup per `authorization_code` / `refresh_token` grant as before.
   - With `knoxidf.token.user.params.enabled=false`: one LDAP round trip fewer 
per token grant; `/userinfo` is unchanged.
   - Failure path: the grant now completes instead of failing, so no client 
retries with a new authorization flow; no new remote calls, caching or locking.
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1057230)
    Remaining Estimate: 0h
            Time Spent: 10m

> KnoxIDF: LDAP user params lookup failure breaks token issuance; make the 
> mint-time lookup non-fatal and configurable
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: KNOX-3621
>                 URL: https://issues.apache.org/jira/browse/KNOX-3621
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: KnoxIDF
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Major
>             Fix For: 3.1.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to