Skip to content

Commit

Permalink
Fix for DPoP authorization failure when tomcat base url and actual ba…
Browse files Browse the repository at this point in the history
…se url differ. (#781)

Signed-off-by: Peter Sorotokin <[email protected]>
  • Loading branch information
sorotokin authored Nov 18, 2024
1 parent 9a31b97 commit 1e46506
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ abstract class BaseServlet: BaseHttpServlet() {
if (json["nonce"]?.jsonPrimitive?.content != dpopNonce) {
throw InvalidRequestException("Stale or invalid DPoP nonce")
}
if (json["htu"]?.jsonPrimitive?.content != req.requestURL.toString()) {
throw InvalidRequestException("Incorrect request URI: ${req.requestURL}")
val serverUrl = environment.getInterface(Configuration::class)!!.getValue("base_url")
// NB: cannot use req.requestURL, as it does not take into account potential frontends.
val expectedUrl = "$serverUrl${req.servletPath}"
val actualUrl = json["htu"]?.jsonPrimitive?.content
if (actualUrl != expectedUrl) {
throw InvalidRequestException("Incorrect request URI: $expectedUrl vs $actualUrl")
}
}
}

0 comments on commit 1e46506

Please sign in to comment.