Skip to content

Support kerberos authentication between Presto nodes#8859

Closed
arhimondr wants to merge 4 commits intoprestodb:masterfrom
Teradata:kerberos_support_between_nodes
Closed

Support kerberos authentication between Presto nodes#8859
arhimondr wants to merge 4 commits intoprestodb:masterfrom
Teradata:kerberos_support_between_nodes

Conversation

@arhimondr
Copy link
Member

No description provided.

Copy link
Contributor

@electrum electrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments. I did a quick pass and it seems good, will let someone more familiar with this double check and approve.

File kerberosKeytab = internalCommunicationConfig.getKerberosKeytab();
String kerberosPrincipal = internalCommunicationConfig.getKerberosPrincipal();
String kerberosServiceName = internalCommunicationConfig.getKerberosServiceName();
checkArgument(kerberosConfig != null, "kerberos config must be set");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these as @NotNull validation constraints to the config class. This will provide appropriate error messages when the values are not set. Then you can remove the checks here since we know the config system will only return a validated bean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see that this validation needs to be conditional. You can put these new config properties (except for the enabled flag) in a separate class (KerberosInternalCommunicationConfig or KerberosCommunicationConfig?) that only gets created if Kerberos is enabled.

We do a similar trick in HiveAuthenticationModule where the various modules with their configs get bound conditionally if they are enabled.


import static org.testng.Assert.assertEquals;

public class TestKerberosPrincipal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add some tests for invalid principals to make sure the error handling works and we don't get an IndexOutOfBoundsException or similar.

assertEquals(KerberosPrincipal.valueOf("user/_HOST@REALM.COM"), new KerberosPrincipal("user", Optional.of("_HOST"), Optional.of("REALM.COM")));
assertEquals(KerberosPrincipal.valueOf("user/part1/part2/_HOST@REALM.COM"), new KerberosPrincipal("user/part1/part2", Optional.of("_HOST"), Optional.of("REALM.COM")));
assertEquals(KerberosPrincipal.valueOf("user\\/part1\\/part2\\/_HOST@REALM.COM"), new KerberosPrincipal("user\\/part1\\/part2\\/_HOST", Optional.empty(), Optional.of("REALM.COM")));
assertEquals(KerberosPrincipal.valueOf("user\\/part1\\/part2\\/_HOST\\@REALM.COM"), new KerberosPrincipal("user\\/part1\\/part2\\/_HOST\\@REALM.COM", Optional.empty(), Optional.empty()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These longer ones would be easier to read if wrapped like in the method below.

Internal SSL/TLS communication with Kerberos
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the :doc:`Kerberos</security/server>` authentication is enabled, specify valid Kerberos
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "the" so it reads as "If Kerberos authentication is enabled..."

@electrum
Copy link
Contributor

Not sure why GitHub shows the comments on ServerMainModule.java as outdated. Please make sure to unhide those.

});
configBinder(binder).bindConfigGlobalDefaults(HttpClientConfig.class, config -> {
config.setAuthenticationEnabled(true);
config.setKerberosPrincipal(principal.substituteHostnamePlaceholder().toString());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the reason to do this _HOST transformation, is it related with how the keytab/principle generated. Shall we make an optional logic against directly using "internalCommunicationConfig.getKerberosPrincipal()" ?

@KevinLu233
Copy link

when i use presto 0.187 with kerberos in coordinator and internal-communication,but I get error :
HTTP protocol violation: Authentication challenge without WWW-Authenticate header

Can you help me ?Thks

@anusudarsan
Copy link
Contributor

addressed comments and rebased here - #9683. Closing this.

@anusudarsan anusudarsan closed this Jan 5, 2018
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.

6 participants