Skip to content

Commit 009331c

Browse files
authored
fix: Fix serialization issues during impersonation (#4)
1 parent 4042b26 commit 009331c

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>tech.stackable</groupId>
66
<artifactId>hdfs-utils</artifactId>
7-
<version>0.1.0</version>
7+
<version>0.1.1</version>
88

99
<name>Apache Hadoop HDFS utils</name>
1010
<url>https://github.com/stackabletech/hdfs-utils/</url>

src/main/java/tech/stackable/hadoop/OpaAllowQuery.java

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tech.stackable.hadoop;
22

33
import org.apache.hadoop.hdfs.server.namenode.INodeAttributeProvider;
4+
import org.apache.hadoop.security.UserGroupInformation;
45

56
public class OpaAllowQuery {
67
public final OpaAllowQueryInput input;
@@ -9,9 +10,14 @@ public OpaAllowQuery(OpaAllowQueryInput input) {
910
this.input = input;
1011
}
1112

13+
/**
14+
* Wrapper around {@link INodeAttributeProvider.AuthorizationContext}, which uses our custom wrapper around
15+
* {@link UserGroupInformation}, {@link OpaQueryUgi}.
16+
*/
1217
public static class OpaAllowQueryInput {
1318
public java.lang.String fsOwner;
1419
public java.lang.String supergroup;
20+
// Wrapping this
1521
public OpaQueryUgi callerUgi;
1622
public org.apache.hadoop.hdfs.server.namenode.INodeAttributes[] inodeAttrs;
1723
public org.apache.hadoop.hdfs.server.namenode.INode[] inodes;

src/main/java/tech/stackable/hadoop/OpaQueryUgi.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import java.util.List;
77

88
public class OpaQueryUgi {
9-
public UserGroupInformation realUser;
9+
// Wrapping this
10+
public OpaQueryUgi realUser;
1011
public String userName;
1112
public String shortUserName;
1213

@@ -16,8 +17,18 @@ public class OpaQueryUgi {
1617
public UserGroupInformation.AuthenticationMethod authenticationMethod;
1718
public UserGroupInformation.AuthenticationMethod realAuthenticationMethod;
1819

20+
/**
21+
* Wrapper around {@link UserGroupInformation}, which does not throw random errors during serialization when no primary
22+
* group is known for the user.
23+
* "Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unexpected IOException (of type java.io.IOException): There is no primary group for UGI hive/hive-iceberg.default.svc.cluster.local@KNAB.COM (auth:KERBEROS)"
24+
*/
1925
public OpaQueryUgi(UserGroupInformation ugi) {
20-
this.realUser = ugi.getRealUser();
26+
UserGroupInformation realUser = ugi.getRealUser();
27+
if (realUser != null) {
28+
this.realUser = new OpaQueryUgi(ugi.getRealUser());
29+
} else {
30+
this.realUser = null;
31+
}
2132
this.userName = ugi.getUserName();
2233
this.shortUserName = ugi.getShortUserName();
2334
try {

0 commit comments

Comments
 (0)