Skip to content

Commit 1bd8e19

Browse files
committed
Password with colon bug fixes
1 parent db2c291 commit 1bd8e19

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/authentication/BasicAuthenticationHandler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BasicAuthenticationHandler(basicAuthType: AuthType)
6969
val authorization = getAuthorization(request)
7070
val inputToken = Option(authorization).map(a => Base64.getDecoder.decode(a.getBytes()))
7171
.getOrElse(Array.empty[Byte])
72-
val creds = new String(inputToken, Charset.forName("UTF-8")).split(":")
72+
val creds = new String(inputToken, Charset.forName("UTF-8")).split(":", 2)
7373

7474
if (allowAnonymous) {
7575
authUser = creds.take(1).headOption.filterNot(_.isEmpty).getOrElse("anonymous")

kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/authentication/KyuubiInternalAuthenticationHandler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class KyuubiInternalAuthenticationHandler extends AuthenticationHandler with Log
4848
val authorization = getAuthorization(request)
4949
val inputToken = Option(authorization).map(a => Base64.getDecoder.decode(a.getBytes()))
5050
.getOrElse(Array.empty[Byte])
51-
val creds = new String(inputToken, StandardCharsets.UTF_8).split(":")
51+
val creds = new String(inputToken, StandardCharsets.UTF_8).split(":", 2)
5252

5353
if (creds.size < 2 || creds(0).trim.isEmpty || creds(1).trim.isEmpty) {
5454
response.setHeader(WWW_AUTHENTICATE_HEADER, authScheme.toString)

kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ class KyuubiRestCustomAuthenticationTest extends KyuubiRestAuthenticationSuite {
240240
assert(HttpServletResponse.SC_OK == response.getStatus)
241241
}
242242

243+
test("test with invalid CUSTOM http basic authorization that contains colon") {
244+
val response = webTarget.path("api/v1/sessions/count")
245+
.request()
246+
.header(AUTHORIZATION_HEADER, basicAuthorizationHeader("user", "password:with:colons"))
247+
.get()
248+
249+
assert(HttpServletResponse.SC_FORBIDDEN == response.getStatus)
250+
}
251+
243252
test("test with invalid CUSTOM http basic authorization") {
244253
val response = webTarget.path("api/v1/sessions/count")
245254
.request()

0 commit comments

Comments
 (0)