fix(frontend,backend): Remove hardcoded legalconsenthub keycloak client ID
Some checks failed
CI/CD Pipeline / backend (push) Has been cancelled
CI/CD Pipeline / deploy (push) Has been cancelled
CI/CD Pipeline / frontend (push) Has been cancelled

This commit is contained in:
2026-03-16 08:29:54 +01:00
parent d4c6def398
commit 37a907e087
4 changed files with 12 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
package com.betriebsratkanzlei.legalconsenthub.security
import org.springframework.beans.factory.annotation.Value
import org.springframework.core.convert.converter.Converter
import org.springframework.security.authentication.AbstractAuthenticationToken
import org.springframework.security.core.GrantedAuthority
@@ -8,14 +9,16 @@ import org.springframework.security.oauth2.jwt.Jwt
import org.springframework.stereotype.Component
@Component
class CustomJwtAuthenticationConverter : Converter<Jwt, AbstractAuthenticationToken> {
class CustomJwtAuthenticationConverter(
@Value("\${legalconsenthub.keycloak.client-id}") private val keycloakClientId: String,
) : Converter<Jwt, AbstractAuthenticationToken> {
override fun convert(jwt: Jwt): AbstractAuthenticationToken {
val userId = jwt.subject
val username = jwt.getClaimAsString("name")
val resourceAccess = jwt.getClaimAsMap("resource_access") as? Map<*, *>
val legalconsenthubResource = resourceAccess?.get("legalconsenthub") as? Map<*, *>
val roles = (legalconsenthubResource?.get("roles") as? List<*>)?.mapNotNull { it as? String } ?: emptyList()
val clientResource = resourceAccess?.get(keycloakClientId) as? Map<*, *>
val roles = (clientResource?.get("roles") as? List<*>)?.mapNotNull { it as? String } ?: emptyList()
val organizationIds = extractOrganizationIds(jwt)

View File

@@ -63,6 +63,8 @@ spring:
max-request-size: 50MB
legalconsenthub:
keycloak:
client-id: ${KEYCLOAK_CLIENT_ID:gremiumhub}
file:
storage:
filesystem: