-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19958. Support IPv6 delegation token service addresses #8669
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: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -480,7 +480,7 @@ public static void setTokenService(Token<?> token, InetSocketAddress addr) { | |
| * hadoop.security.token.service.use_ip | ||
| */ | ||
| public static Text buildTokenService(InetSocketAddress addr) { | ||
| String host = null; | ||
| String host; | ||
| if (useIpForTokenService) { | ||
| if (addr.isUnresolved()) { // host has no ip address | ||
| throw new IllegalArgumentException( | ||
|
|
@@ -491,7 +491,7 @@ public static Text buildTokenService(InetSocketAddress addr) { | |
| } else { | ||
| host = StringUtils.toLowerCase(addr.getHostName()); | ||
| } | ||
| return new Text(host + ":" + addr.getPort()); | ||
| return new Text(NetUtils.getHostPortString(host, addr.getPort())); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -297,7 +297,7 @@ void runBadPortPermutes(String arg, boolean validIfPosPort) { | |
| String serviceHost = useIp ? ip : StringUtils.toLowerCase(host); | ||
|
|
||
| Token<?> token = new Token<TokenIdentifier>(); | ||
| Text service = new Text(serviceHost+":"+port); | ||
| Text service = new Text(NetUtils.getHostPortString(serviceHost, port)); | ||
|
|
||
| assertEquals(service, SecurityUtil.buildTokenService(addr)); | ||
| SecurityUtil.setTokenService(token, addr); | ||
|
|
@@ -366,6 +366,14 @@ public void testSocketAddrWithIP() { | |
| verifyServiceAddr(staticHost, "127.0.0.1"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSocketAddrWithIPv6() throws Exception { | ||
| SecurityUtil.setTokenServiceUseIp(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: |
||
| String host = "::1"; | ||
| InetSocketAddress addr = NetUtils.createSocketAddr("[::1]:123"); | ||
| verifyAddress(addr, host, InetAddress.getByName(host).getHostAddress(), 123); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The PR description says both Consider deriving the expected hostname from |
||
| } | ||
|
|
||
| @Test | ||
| public void testSocketAddrWithNameToStaticName() { | ||
| String staticHost = "host1"; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new helper emits bracketed IPv6 authorities (e.g.
"[::1]:123"), but the existinggetPortFromHostPortString()(unchanged in this PR) still splits on":"and requires exactly one colon — it cannot parse bracketed IPv6 strings.Token round-trip via
SecurityUtil.getTokenServiceAddr()→createSocketAddr()is fine, but the two helpers are now inconsistent. Any caller that formats withgetHostPortStringand parses withgetPortFromHostPortStringwill break on IPv6.Worth updating
getPortFromHostPortString()to accept"[<ipv6>]:<port>"(and reject ambiguous unbracketed IPv6), with tests, either here or as an immediate follow-up on the same JIRA.