diff --git a/ktor-http/common/src/io/ktor/http/auth/HttpAuthHeader.kt b/ktor-http/common/src/io/ktor/http/auth/HttpAuthHeader.kt index 47cbf25b625..0fa08090d5a 100644 --- a/ktor-http/common/src/io/ktor/http/auth/HttpAuthHeader.kt +++ b/ktor-http/common/src/io/ktor/http/auth/HttpAuthHeader.kt @@ -61,6 +61,7 @@ public fun parseAuthorizationHeader(headerValue: String): HttpAuthHeader? { * @return a list of [HttpAuthHeader] * @throws [ParseException] on invalid header */ +@InternalAPI public fun parseAuthorizationHeaders(headerValue: String): List { var index = 0 val headers = mutableListOf() @@ -107,6 +108,12 @@ private fun parseAuthorizationHeader( return nextIndexChallenge } +/** + * Check for the ending of the current challenge in a header + * @return -1 if at the end of the header + * @return null if the challenge is not ended + * @return a positive number - the index of the beginning of the next challenge + */ private fun nextChallengeIndex( headers: MutableList, header: HttpAuthHeader, diff --git a/ktor-server/ktor-server-plugins/ktor-server-auth/jvmAndNix/test/io/ktor/tests/auth/AuthorizeHeaderParserTest.kt b/ktor-server/ktor-server-plugins/ktor-server-auth/jvmAndNix/test/io/ktor/tests/auth/AuthorizeHeaderParserTest.kt index 0519f3dd0fc..2179514e38b 100644 --- a/ktor-server/ktor-server-plugins/ktor-server-auth/jvmAndNix/test/io/ktor/tests/auth/AuthorizeHeaderParserTest.kt +++ b/ktor-server/ktor-server-plugins/ktor-server-auth/jvmAndNix/test/io/ktor/tests/auth/AuthorizeHeaderParserTest.kt @@ -5,6 +5,7 @@ package io.ktor.tests.auth import io.ktor.http.auth.* +import io.ktor.util.* import kotlin.random.* import kotlin.test.* @@ -114,6 +115,7 @@ class AuthorizeHeaderParserTest { } } + @OptIn(InternalAPI::class) private fun testParserMultipleChallenges(expected: List, headerValue: String) { val actual = parseAuthorizationHeaders(headerValue)