Skip to content

Add Support for Kerberos auth for proxies in Netty - #7276

Merged
dagnir merged 15 commits into
masterfrom
feature/master/netty-kerberos-proxy-auth
Aug 21, 2026
Merged

Add Support for Kerberos auth for proxies in Netty#7276
dagnir merged 15 commits into
masterfrom
feature/master/netty-kerberos-proxy-auth

Conversation

@dagnir

@dagnir dagnir commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Add support for Kerberos (SPNEGO) proxy authentication via the new proxyAuthScheme option on the Netty client's ProxyConfiguration. Setting ProxyAuthScheme.NEGOTIATE authenticates proxy CONNECT tunnels using the Kerberos ticket cache in the environment; a valid ticket-granting ticket must already exist (for example via kinit), and no password or keytab is read. ProxyAuthScheme.BASIC may also be set to select Basic authentication explicitly. See #7033.

This branch is a collection of smaller PRs that were previously reviewed:

Modifications

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

dagnir added 5 commits August 3, 2026 12:54
* Initial support for Kerberos auth

This commit adds
 - A new enum `ProxyAuthScheme` that enumerates the proxy auth
   mechanisms supported by Netty
 - `ProxyAuthGenerator` (internal) that knows how to generate the auth
   params for its respective auth scheme
 - `NegotiateProxyAuthGenerator` for Kerberos

* wip

* Document OID
This reverts commit b20454f.
* Add basic auth impl

* Checkstyle and dependency issues
* Switch to AuthGenerator in tunnel pool

Use the new AuthGenerator mechanism in the `Http1TunnelConnectionPool`
and `AwaitCloseChannelPoolMap` classes. For now, supports only using
BASIC auth; Kerberos will be added in a subsequent PR.

* Allow empty username, pass

Original impl allowed empty (e.g. whitespace) in username and pass for
BASIC auth so preserve that behavior.
* Support ProxyAuthScheme

This commit Adds a `ProxyAuthScheme` configuration option in
`ProxyConfiguration` and adds support for `NEGOTIATE` auth scheme.

For backwards compatibility, if username and password are set on the
config and the proxy auth scheme is *not* set, the client assumes
`BASIC` auth scheme. If `NEGOTIATE` is configured, `username` and
`password` are ignored.

* Fix test
@dagnir
dagnir requested a review from a team as a code owner August 14, 2026 16:15
dagnir added 6 commits August 14, 2026 09:16
requestMutualAuth(true) asked for mutual authentication that was never
established: the proxy's response token is never consumed, so there is
nothing to verify it against. Preemptive single-leg Negotiate cannot
verify it either, so the call is dropped rather than wired up.

The com.sun.security.auth.module.Krb5LoginModule import existed only to
satisfy a javadoc {@link}. Referring to the class by name in {@code}
instead keeps the documentation while dropping a compile-time reference
to a JDK-implementation-specific class.
* Document the Negotiate proxy auth prerequisites

NEGOTIATE depends on ambient, expiring, host-level state rather than on
anything the customer passes to the builder, and none of that was
documented. Spell out on the enum constant that credentials come from
the ticket cache and never from a prompt or keytab, that a missing or
expired ticket is not detected at build time and instead fails when a
proxy connection is established, that the service principal is derived
from the configured proxy host so an IP literal will not work, and that
the JDK's GSS and JAAS modules must be present in the runtime image.

Also note on the builder setter that username and password are ignored
for NEGOTIATE, so credentials left in place while switching schemes are
not silently assumed to be in use.

* Warn when proxy credentials are ignored by NEGOTIATE

NEGOTIATE authenticates from the Kerberos ticket cache, so a username
and password configured alongside it are dead configuration. Switching
an existing Basic proxy configuration over to NEGOTIATE and leaving the
credentials in place therefore looks like it still uses them, with no
signal either way.

Warn at build() rather than reject, and only when the credentials were
set directly on the builder: values resolved from system properties or
environment variables may not be under the caller's control, so warning
about those would be noise they cannot act on.
Generating a SPNEGO token performs a JAAS login and may make a blocking
TGS request to the KDC. That ran on the Netty event loop during proxy
tunnel setup, so a slow or unreachable KDC stalled every other channel
assigned to that loop, and SDK timeouts could not unpark the thread.

ProxyAuthGenerator now returns a CompletableFuture, so the contract
states that generating params may be slow and must not complete on the
caller's thread. Basic auth completes inline and stays on the existing
synchronous path; the handler only hops threads when the future is not
already done.

AwaitCloseChannelPoolMap creates the executor the Negotiate generator
runs on, and shuts it down when it closes, so the resource is created
and released in the same place. It is a single daemon thread, created
only when NEGOTIATE is configured: the goal is to keep blocking work off
the event loops, not to parallelize it. The generator itself is resolved
once per client rather than once per remote host.
@dagnir dagnir changed the title [WIP] Feature/master/netty kerberos proxy auth Add Support for Kerberos auth for proxies in Netty Aug 18, 2026
@dagnir dagnir added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Aug 19, 2026
@dagnir
dagnir requested a review from RanVaknin August 19, 2026 22:49
@dagnir
dagnir added this pull request to the merge queue Aug 21, 2026
Merged via the queue into master with commit b2bb928 Aug 21, 2026
16 of 18 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 21, 2026
@dagnir
dagnir deleted the feature/master/netty-kerberos-proxy-auth branch August 21, 2026 17:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants