Skip to content

Commit

Permalink
fix #2072: Prevent JWT validation failure as an API key when the audi…
Browse files Browse the repository at this point in the history
…ence is null
  • Loading branch information
Zwiterrion committed Jan 10, 2025
1 parent e75b82b commit 990d0c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions otoroshi/app/models/apikey.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1930,9 +1930,9 @@ object ApiKeyHelper {
.build
Try(verifier.verify(jwt))
.filter { token =>
val aud = token.getAudience.asScala.headOption.filter(v =>
val aud = Option(token.getAudience).flatMap(_.asScala.headOption.filter(v =>
v.startsWith("http://") || v.startsWith("https://")
)
))
if (aud.isDefined) {
val currentUrl = req.theUrl
val audience = aud.get
Expand Down
5 changes: 5 additions & 0 deletions otoroshi/test/Suites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,8 @@ class GreenScoreTest
extends Suites(
new GreenScoreTestSpec("GreenScore", Configurations.InMemoryConfiguration)
)

//class ApiKeysTest
// extends Suites(
// new ApiKeysSpec("ApiKeysSpec", Configurations.InMemoryConfiguration)
// )

0 comments on commit 990d0c8

Please sign in to comment.