You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2026/08/18 03:48:08 UTC
[PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
pan3793 opened a new pull request, #58064:
URL: https://github.com/apache/spark/pull/58064
# [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user
### What changes were proposed in this pull request?
Support obtaining Kafka delegation tokens when the current user is a proxy user, based on
KAFKA-6945 (Kafka 3.3.0):
- `KafkaTokenUtil.obtainToken` requests the token with
`CreateDelegationTokenOptions.owner(<proxy user>)` when the current UGI is a proxy user, so the
token is requested with the real user's credentials but owned by the proxy user. The
`checkProxyUser()` guard that rejected proxy users is removed.
- The two failure modes of the owner-set path are translated into actionable `SparkException`s:
`UnsupportedVersionException` (broker older than 3.3.0) and
`DelegationTokenAuthorizationException` (real user lacks the `CreateTokens` operation on the
`User:<proxy user>` resource).
- `printToken` logs the token's REQUESTER alongside OWNER, which differ for proxy-user tokens.
- The SS Kafka integration guide's caveat is updated: broker version requirement, the
`kafka-acls.sh` grant example, and the constraint that the real user's credentials come from the
ticket cache (`--proxy-user` cannot be combined with `--principal`/`--keytab`) with the token
obtained once and not renewed.
### Why are the changes needed?
Applications submitted with `--proxy-user` cannot use Kafka delegation tokens: token acquisition
is skipped with a warning, and connectors fall back to other authentication. KAFKA-6945 added the
ability to create tokens owned by another principal, which makes impersonation work end to end.
### Does this PR introduce _any_ user-facing change?
Yes. Proxy-user applications now obtain Kafka delegation tokens owned by the proxy user
(previously acquisition was skipped with a warning). Requires Kafka 3.3.0+ brokers and the real
user granted `CreateTokens` on the `User:<proxy user>` resource; misconfigurations of either now
fail with a descriptive error.
### How was this patch tested?
UT/IT:
- `KafkaTokenUtilSuite`: `createDelegationTokenOptions` sets the owner for a proxy user and
leaves it unset otherwise.
- `KafkaDelegationTokenSuite` (embedded secure Kafka + MiniKdc): asserts the broker-recorded
owner/requester for both the plain and the proxy-user roundtrip; the proxy roundtrip runs with
DENY read/write ACLs for the real user on the test topic so it passes only if connectors
authenticate as the proxy user; a negative test asserts the descriptive error when
`CreateTokens` is not granted.
Real cluster tests:
- Plain token via `KafkaTokenUtil.obtainToken` — → success (token owner `User:spark`, requester `User:spark`).
- Proxy-user token - `alice` with CreateTokens ACL → success (token owner `User:alice`).
- Proxy-user token - `bob` without ACL → failure, clean `SparkException: The real user must be granted the CreateTokens operation on the User:bob resource.`; broker recorded 0 tokens for `bob`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-fable-5)
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR closed pull request #58064: [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user
URL: https://github.com/apache/spark/pull/58064
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5352787383
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/52eb078867cf809a92fd6ebdc96c9d72bce63417
- merged into branch-4.x https://github.com/apache/spark/commit/0c534822ba1fab2964ca3f6b96dcfc7adf3b29f6
*Posted by `merge_spark_pr.py`*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5352765582
Thanks! Merging to master/4.x.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5352588875
Maybe beyond the scope of the PR, but KafkaDelegationTokenProvider.obtainDelegationTokens seems to log the warning message and swallow when KafkaTokenUtil.obtainToken raises exception. The code is there as it is so maybe it's fine, but I wonder whether fail-fast is somehow better; I'm away from delegation token for 5+ years so just a grain of salt.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5352763464
Yeah OK there may be a reason to do it, or it's probably too late to change the behavior.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5352676709
@HeartSaVioR, thanks for the review and for raising your thoughts.
> KafkaDelegationTokenProvider.obtainDelegationTokens seems to log the warning message and swallow when KafkaTokenUtil.obtainToken raises exception. ... I wonder whether fail-fast is somehow better
I think it's by design, the `obtainDelegationTokens` API signature says:
> ```
> @return If the returned tokens are renewable and can be renewed, return the time of the next
> renewal, otherwise None should be returned.`
> ```
And I checked all existing built-in `HadoopDelegationTokenProvider`s (Hive, HDFS, HBase), all of them log the exception and return None instead of failing fast when an error occurs.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5324680143
LGTM, nice extension to obtain the Kafka delegation token for the proxy user, thank you @pan3793!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-28173][SS] Support obtaining Kafka delegation token for proxy user [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #58064:
URL: https://github.com/apache/spark/pull/58064#issuecomment-5336815898
thanks @uros-b. cc @HeartSaVioR @sarutak, could you please take a look?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org