-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds kerberos support for kudu connector
Includes handling of kerberos ticket expiration and product tests demonstrating ticket renewal
- Loading branch information
1 parent
ab182c7
commit 5b3d68e
Showing
23 changed files
with
906 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KerberizedKuduClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.kudu; | ||
|
||
import io.trino.plugin.base.authentication.CachingKerberosAuthentication; | ||
import org.apache.kudu.client.KuduClient; | ||
|
||
import javax.security.auth.Subject; | ||
|
||
import java.security.PrivilegedAction; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static org.apache.kudu.client.KuduClient.KuduClientBuilder; | ||
|
||
public class KerberizedKuduClient | ||
extends ForwardingKuduClient | ||
{ | ||
private final KuduClient kuduClient; | ||
private final CachingKerberosAuthentication cachingKerberosAuthentication; | ||
|
||
KerberizedKuduClient(KuduClientBuilder kuduClientBuilder, CachingKerberosAuthentication cachingKerberosAuthentication) | ||
{ | ||
requireNonNull(kuduClientBuilder, "kuduClientBuilder is null"); | ||
this.cachingKerberosAuthentication = requireNonNull(cachingKerberosAuthentication, "cachingKerberosAuthentication is null"); | ||
kuduClient = Subject.doAs(cachingKerberosAuthentication.getSubject(), (PrivilegedAction<KuduClient>) (kuduClientBuilder::build)); | ||
} | ||
|
||
@Override | ||
protected KuduClient delegate() | ||
{ | ||
cachingKerberosAuthentication.reauthenticateIfSoonWillBeExpired(); | ||
return kuduClient; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduAuthenticationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.kudu; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
|
||
public class KuduAuthenticationConfig | ||
{ | ||
private KuduAuthenticationType authenticationType = KuduAuthenticationType.NONE; | ||
|
||
public enum KuduAuthenticationType | ||
{ | ||
NONE, | ||
KERBEROS; | ||
} | ||
|
||
public KuduAuthenticationType getAuthenticationType() | ||
{ | ||
return authenticationType; | ||
} | ||
|
||
@Config("kudu.authentication.type") | ||
@ConfigDescription("Kudu authentication type") | ||
public KuduAuthenticationConfig setAuthenticationType(KuduAuthenticationType authenticationType) | ||
{ | ||
this.authenticationType = authenticationType; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
plugin/trino-kudu/src/main/java/io/trino/plugin/kudu/KuduKerberosConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.kudu; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
import io.airlift.configuration.validation.FileExists; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import java.io.File; | ||
import java.util.Optional; | ||
|
||
public class KuduKerberosConfig | ||
{ | ||
private String clientPrincipal; | ||
private File clientKeytab; | ||
private File config; | ||
// The kudu client defaults to using "kudu" if this is undefined | ||
private Optional<String> kuduPrincipalPrimary = Optional.empty(); | ||
|
||
@NotNull | ||
public String getClientPrincipal() | ||
{ | ||
return clientPrincipal; | ||
} | ||
|
||
@Config("kudu.authentication.client.principal") | ||
@ConfigDescription("Kudu Kerberos client principal") | ||
public KuduKerberosConfig setClientPrincipal(String clientPrincipal) | ||
{ | ||
this.clientPrincipal = clientPrincipal; | ||
return this; | ||
} | ||
|
||
@NotNull | ||
@FileExists | ||
public File getClientKeytab() | ||
{ | ||
return clientKeytab; | ||
} | ||
|
||
@Config("kudu.authentication.client.keytab") | ||
@ConfigDescription("Kudu Kerberos client keytab location") | ||
public KuduKerberosConfig setClientKeytab(File clientKeytab) | ||
{ | ||
this.clientKeytab = clientKeytab; | ||
return this; | ||
} | ||
|
||
@NotNull | ||
@FileExists | ||
public File getConfig() | ||
{ | ||
return config; | ||
} | ||
|
||
@Config("kudu.authentication.config") | ||
@ConfigDescription("Kudu Kerberos service configuration file") | ||
public KuduKerberosConfig setConfig(File config) | ||
{ | ||
this.config = config; | ||
return this; | ||
} | ||
|
||
public Optional<String> getKuduPrincipalPrimary() | ||
{ | ||
return kuduPrincipalPrimary; | ||
} | ||
|
||
@Config("kudu.authentication.server.principal.primary") | ||
@ConfigDescription("The 'primary' portion of the kudu service principal name") | ||
public KuduKerberosConfig setKuduPrincipalPrimary(String kuduPrincipalPrimary) | ||
{ | ||
this.kuduPrincipalPrimary = Optional.ofNullable(kuduPrincipalPrimary); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.