Repository navigation
KNOX-3603: Refuse delegated tokens at the KnoxIDF client token endpoints - #1533
Merged
Merged
Conversation
KNOX-3600 refuses a delegated token (act claim) at client registration. RegistrationResource now also refuses it, with access_denied, at the inherited getUserTokens, revoke, revokeTokens, enable, enableTokens, disable and disableTokens endpoints, which authorize the user the token acts for. knoxidf.client.registration.delegated.callers.denied (default true) controls both checks.
Test Results 5 files 5 suites 1m 17s ⏱️ Results for commit 7630ce6. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KNOX-3603 - KnoxIDF: Refuse delegated tokens at client revocation and enable/disable
What changes were proposed in this pull request?
KNOX-3600 refuses a delegated token (RFC 8693
actclaim, anActorChainPrincipalon the subject) at/knoxidf/api/v1/client/register. The other/clientendpointsRegistrationResourceinherits fromTokenResourcehad no such check. They authorize the caller's effective principal, which for a delegated token is the user it acts for, and accept a bare token id. So whoever holds a user's delegated token could list that user's tokens and revoke, disable or re-enable any of them whose id it knows.RegistrationResourceoverridesgetUserTokens,revoke,revokeTokens,enable,enableTokens,disableanddisableTokens. A delegated caller gets403access_denied("A delegated token cannot list/revoke/enable/disable tokens.") before the parent runs, audited asauthorization|…|failure|event=client_<token_listing|revocation|enablement|disablement> reason=delegated_caller_denied. Other callers reach the inherited implementation unchanged.knoxidf.client.registration.delegated.callers.denied(defaulttrue) now controls these endpoints too, so one switch decides whether delegated tokens may manage clients.falserestores the previous behaviour.configuration.mdandsecurity.md.How was this patch tested?
Unit tests: new
RegistrationResourceDelegatedTokenAccessGuardTest(13 tests). A delegated caller is refused withaccess_deniedat all 7 endpoints, and a strictTokenStateServicemock verifies the token state is untouched. With the param set tofalse, and for a non-delegated caller,revoke,disableandgetUserTokensreach the parent and return200. All 299gateway-service-knoxidftests pass, andmvn verify(checkstyle, PMD) is clean.Manual test on a local gateway, on two delegated-token paths. In both, the test first registers two clients C1 and C2 owned by the user, then calls
getUserTokens,disable/enableC1,disableTokens/enableTokensC2,revokeC1 andrevokeTokensC2, first with the delegated token, then with a non-delegated token of the same user. Theknoxidf-auth-clientregistrationtopology (JWTProvider,lowercaseprincipal mapping,thirdPartyApp=true,knoxidf.client.registration.delegated.callers.denied=true) serves/client. A test-only PathAcls rule opens/knoxidf/api/v1/client/*there, so the requests reachRegistrationResourceinstead of being stopped by the existingregister-only ACL.RFC 8693 on-behalf-of token.
knoxidf-tokenexchange(delegation.server.enabled=true,knoxidf.knox.token.enable.delegated.auth=true,passthroughaudience validator) exchanges admin's KNOXSSO token with guest's as the actor, under a delegation policy (guest may act for admin at audienceknoxidf) set atknoxidf-admin. The registration topology trusts that issuer. The same-subject exchange of admin's token is the non-delegated control.Impersonation token with
act. The test-onlydelegationtopology from KNOX-3600 (doAsimpersonation for guest,KNOXTOKENwithknox.token.enable.delegated.auth=true) mints a KNOXSSO token for admin withact.sub=guest. Steps 1–5 are the KNOX-3600 registration checks; admin's KNOXSSO token registers C1 and C2 and is the control.Each refusal is in the audit log, e.g.:
The KNOX-3600 client-caller check is unaffected: with
knoxidf.client.registration.client.callers.deniedunset, a registered client's own token still gets403"A registered client cannot register another client.".Integration Tests
Two new tests in
test_delegation.py, which already sets up delegation policies and RFC 8693 exchanges. Both use a token delegated to recursiveUser acting for tom (sub=tom,act.sub=recursiveUser) fromknoxidf-token-delegation-policy.test_delegated_token_refused_at_client_endpoints, onknoxidf-token-delegation-policy(default, delegated callers refused): tom's own token registers two clients. The delegated token gets403access_deniedatregisterand at all 7 token endpoints, each with its verb in the message. Each refusal leaves oneauthorizationfailure audit record with the righteventandreason=delegated_caller_denied, matched by anaudit_markerquery parameter as in the KNOX-3568 tests. tom's own token then gets200at all 7, so the 403s come from the delegated check.test_delegated_token_reaches_client_endpoints_when_allowed, on the newknoxidf-client-delegated-allowedtopology (JWTProvider, server-managed,KNOXIDFwithknoxidf.client.registration.delegated.callers.denied=false): the same delegated token registers two clients and gets200at all 7 endpoints.