Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BasicAuthenticationHandler(basicAuthType: AuthType)
val authorization = getAuthorization(request)
val inputToken = Option(authorization).map(a => Base64.getDecoder.decode(a.getBytes()))
.getOrElse(Array.empty[Byte])
val creds = new String(inputToken, Charset.forName("UTF-8")).split(":")
val creds = new String(inputToken, Charset.forName("UTF-8")).split(":", 2)

if (allowAnonymous) {
authUser = creds.take(1).headOption.filterNot(_.isEmpty).getOrElse("anonymous")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class KyuubiInternalAuthenticationHandler extends AuthenticationHandler with Log
val authorization = getAuthorization(request)
val inputToken = Option(authorization).map(a => Base64.getDecoder.decode(a.getBytes()))
.getOrElse(Array.empty[Byte])
val creds = new String(inputToken, StandardCharsets.UTF_8).split(":")
val creds = new String(inputToken, StandardCharsets.UTF_8).split(":", 2)

if (creds.size < 2 || creds(0).trim.isEmpty || creds(1).trim.isEmpty) {
response.setHeader(WWW_AUTHENTICATE_HEADER, authScheme.toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ class KyuubiRestCustomAuthenticationTest extends KyuubiRestAuthenticationSuite {
assert(HttpServletResponse.SC_OK == response.getStatus)
}

test("test with invalid CUSTOM http basic authorization that contains colon") {
val response = webTarget.path("api/v1/sessions/count")
.request()
.header(AUTHORIZATION_HEADER, basicAuthorizationHeader("user", "password:with:colons"))
.get()

assert(HttpServletResponse.SC_FORBIDDEN == response.getStatus)
}

test("test with invalid CUSTOM http basic authorization") {
val response = webTarget.path("api/v1/sessions/count")
.request()
Expand Down
Loading