Skip to content

Improve SpnegoEngine to allow more login configuration options #1582

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

Merged

Conversation

nddipiazza
Copy link
Contributor

@nddipiazza nddipiazza commented Oct 4, 2018

SpnegoEngine improvements

Summary

The current spnego implementation locks you into using a single kerberos login configuration, and the SpnegoEngine has no unit test coverage.

This fixes those things.

  • Add a SpnegoEngineTest that uses apache kerby to test SpnegoEngine.
  • Allow different JAAS login configurations as parameters to SpnegoEngine.
  • Properly obtain SPN and don't hard code HTTP@ spns.
  • We should not need to specify a username/password in the new Realm.Builder(). It's optional for spnego, so we should not be asserting that it's not null.

New parameters to the SpnegoEngine (parameters added to Realm/DSL where needed)

servicePrincipalName - new param* - to allow user to specify their own SPN.
useCanonicalHostname -new param* - whether or not to obtain the canonical hostname or just use the raw host.
customLoginConfig - new param* - allow to specify your own login configuration as map<string, string>
loginContextName - new param* - allow to choose a specific login configuration from the login conf
realmName - send existing realm name to spnego engine to allow users to customize the @realmName appended to the SPN.
username and password - send existing principal and password to the spnego engine to allow username/password kerberos auth as well.

@nddipiazza nddipiazza changed the title Add the ability to pass in a {principal name, keytab} to SPNego Add the ability to pass in a custom login config to SPNegoEngines Oct 4, 2018
@nddipiazza
Copy link
Contributor Author

@slandelle just wondering if you have a moment to check this out.

@slandelle
Copy link
Contributor

@nddipiazza Do you have any idea how this could be tested?

@nddipiazza
Copy link
Contributor Author

Hi @slandelle. The Apache CXF project has an example of a JUnit Kerberos ticket server that we could pull into the unit testing code. We could pull that in. it'd be a lot of work. otherwise docker can do it.

@nddipiazza
Copy link
Contributor Author

nddipiazza commented Oct 17, 2018

@nddipiazza
Copy link
Contributor Author

Oh even better, I noticed this test module in apache cxf: https://github.com/apache/cxf/tree/master/systests/kerberos

It uses apache directory to create a real KDC and uses it accordingly. that would be very nice because no docker dependency

@slandelle
Copy link
Contributor

Hi @nddipiazza
Sorry for the lag, I'm pretty swamped atm.
Yes, an embedded server would be awesome! Sorry that I can't help much, I'm not very familiar with Spnego... Do you think you could contribute a test suite based on a fork of CXF work?

@nddipiazza
Copy link
Contributor Author

@slandelle ready for review

@nddipiazza nddipiazza changed the title Add the ability to pass in a custom login config to SPNegoEngines Improve SpnegoEngine to allow more login configuration optoins Oct 18, 2018
@nddipiazza nddipiazza changed the title Improve SpnegoEngine to allow more login configuration optoins Improve SpnegoEngine to allow more login configuration options Oct 18, 2018
@slandelle slandelle merged commit 7908701 into AsyncHttpClient:master Oct 19, 2018
@slandelle
Copy link
Contributor

Thanks a lot, looks great!

@nddipiazza
Copy link
Contributor Author

Thanks!

nddipiazza added a commit to nddipiazza/async-http-client that referenced this pull request Oct 20, 2018
…HttpClient#1582)

* add the ability to pass in a {principal name, keytab} combination to async http client.

* fix issue where spnego principal/keytab was no longer optional

* specify the login config as a map to allow all the values custom not just
a couple of them.

* remove the principal/password assertion on not null
add a map of spnego engines so you can support more than one spnego login confg per jvm

* no need to detect null on loginContext

* add a SpnegoEngine unit test.

* Delete kerberos.jaas

* Update pom.xml

* Provide more granularity to be more aligned with other http clients:

* Login context name
* Username/password auth option

* remove useless comment

* add login context name and username into the instance key

* cxf.kerby.version -> kerby.version

# Conflicts:
#	pom.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants