-
Notifications
You must be signed in to change notification settings - Fork 688
Support SPNEGO Authentication in HttpClient #3813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I tested Kerberos authentication using the krb5 available at https://formulae.brew.sh/formula/krb5. |
19ccf13 to
090e1c2
Compare
a6efd89 to
96aa2ba
Compare
reactor-netty-http/src/main/java/reactor/netty/http/client/JaasAuthenticator.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/SpnegoAuthProvider.java
Outdated
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/SpnegoAuthProvider.java
Show resolved
Hide resolved
8fcac3f to
a77c0a5
Compare
reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java
Show resolved
Hide resolved
|
@violetagg |
|
This is so great! Looking forward to get this in :) |
|
I can provide some guidance around APIs and configuration. Not every kerberos-enabled client uses JAAS, therefore the direct Subject/SPNEGO token support should be provided |
|
@wendigo I was thinking of allowing users to implement the If I understood you correctly, you're suggesting that we should provide a way for users to directly supply a Subject, as in the example below: public class DirectSubjectAuthenticator implements SpnegoAuthenticator {
// ...
private Subject subject;
@Override
public Subject login() throws LoginException {
return subject;
}
// ...
}Would you be able to share a more concrete example or use case? |
|
Sure @raccoonback. I'd like to use reactor-netty in the trino CLI/JDBC/client libraries. We support delegated/constrained/unconstrained kerberos authentication. Relevant code is here: This is how we add it to the okhttp: https://github.com/trinodb/trino/blob/master/client/trino-client/src/main/java/io/trino/client/auth/kerberos/SpnegoHandler.java Configurability is important as we expose configuration that allows the user to pass remote service name, service principal name, whether to canonicalize hostname: https://github.com/trinodb/trino/blob/master/client/trino-client/src/main/java/io/trino/client/auth/kerberos/SpnegoHandler.java#L50C5-L54C48 |
|
@violetagg cc. @wendigo |
|
I'm currently on vacation. When I return I'll check it.
На нд, 27.07.2025 г. в 18:21 KOSEUNGBIN ***@***.***> написа:
… *raccoonback* left a comment (reactor/reactor-netty#3813)
<#3813 (comment)>
@violetagg <https://github.com/violetagg>
I think supporting not only JAAS-based authentication but also allowing
the user to provide a GSSCredential directly could improve configurability
and flexibility.
This would be especially useful in environments where JAAS is not
preferred or where credentials need to be managed programmatically.
What do you think about this direction?
cc. @wendigo <https://github.com/wendigo>
—
Reply to this email directly, view it on GitHub
<#3813 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFKCVJR2CIDYFH4XV65ZID3KTU6LAVCNFSM6AAAAAB75EX2K6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCMRUGQ4DSNBVGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@wendigo |
685924c to
b082661
Compare
reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/JaasAuthenticator.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/SpnegoAuthProvider.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/SpnegoAuthProvider.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/client/SpnegoAuthProvider.java
Show resolved
Hide resolved
|
@violetagg |
I'm just returning fro vacation, will check it in the next days or so |
|
@violetagg |
|
I will check this one ... just need to finalise some other tasks. |
|
@raccoonback We discussed to introduce this feature for 1.3.0 version but it is based on 1.2.x branch. Which version are we targeting? |
|
@violetagg |
|
@violetagg |
yes |
Signed-off-by: raccoonback <kosb15@naver.com>
Signed-off-by: raccoonback <kosb15@naver.com>
Signed-off-by: raccoonback <kosb15@naver.com>
… authentication Signed-off-by: raccoonback <kosb15@naver.com>
Signed-off-by: raccoonback <kosb15@naver.com>
Signed-off-by: raccoonback <kosb15@naver.com>
b082661 to
5eaf4f0
Compare
|
@violetagg |
|
After following the discussion here and having in mind the Reactor Netty API, I think that the solution should be a bit more generic. Also IMO, Reactor Netty is responsible to provide the infrastructure while the user - to provide the concrete implementation (for example how the token will be generated, cached etc). And the usage will be |
|
The API is a bit rough, if we have a delayed token generation we may need the authenticationConsumer to return Mono that we can execute before sending the request. What do you think? |
|
@violetagg
|
|
@violetagg |
I would like the user to be responsible for the token generation (thus our API will work not only for SPNEGO) and also the decision how the token will be used/reused, what kind of cache that will be used, what will be the expiration time etc., it is not Reactor Netty decision but user's. |
yes, I understand We can show case in the examples various http authentications |
|
@violetagg |
Motivation
This PR adds support for SPNEGO (Kerberos) authentication to HttpClient, addressing #3079.
SPNEGO is widely used for HTTP authentication in enterprise environments, particularly those based on Kerberos.
Changes
SpnegoAuthProvider
Provides SPNEGO authentication by generating a Kerberos-based token and attaching it to the
Authorizationheader of outgoing HTTP requests.JaasAuthenticator
Provides a pluggable way to perform JAAS-based Kerberos login, making it easy to integrate with various authentication backends.
HttpClient.spnego(...) API
Adds a new API to configure SPNEGO authentication for HttpClient instances.
jaas.conf
A JAAS(Java Authentication and Authorization Service) configuration file in Java for integrating with authentication backends such as Kerberos.
krb5.conf
krb5.conf is a Kerberos client configuration file used to define how the client locates and communicates with the Kerberos Key Distribution Center (KDC) for authentication.
How It Works
401 Unauthorizedand aWWW-Authenticate: Negotiateheader,the client automatically generates a SPNEGO token using the Kerberos ticket and resends the request with the appropriate
Authorizationheader.Environment Configuration
Requires proper JAAS (jaas.conf) and Kerberos (krb5.conf) configuration.
See the updated documentation for example configuration files and JVM options.
Additional Notes
SpnegoAuthProviderallows for easy extension and testing by supporting custom authenticators and GSSManager injection.