-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4376e9f
commit 220f46c
Showing
4 changed files
with
125 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/com/faforever/icebreaker/security/CustomTenantResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.faforever.icebreaker.security | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import io.quarkus.oidc.TenantResolver | ||
import io.vertx.core.http.HttpHeaders.AUTHORIZATION | ||
import io.vertx.ext.web.RoutingContext | ||
import jakarta.enterprise.context.ApplicationScoped | ||
|
||
|
||
@ApplicationScoped | ||
class CustomTenantResolver( | ||
private val objectMapper: ObjectMapper | ||
): TenantResolver { | ||
|
||
override fun resolve(context: RoutingContext): String? = | ||
context.request().getHeader(AUTHORIZATION) | ||
?.takeIf { it.startsWith("Bearer ") } | ||
?.let { | ||
val rawToken = it.substring(7) | ||
val body = java.util.Base64.getDecoder().decode(rawToken.split(".")[1]) | ||
val json = objectMapper.readTree(body) | ||
|
||
json["iss"]?.textValue() | ||
} | ||
?.takeIf { it == "https://ice.faforever.com" } | ||
?.let { "self-tenant" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters