Skip to content

Commit

Permalink
Ikke få nullpointer på getClaims
Browse files Browse the repository at this point in the history
  • Loading branch information
hestad committed Sep 25, 2024
1 parent b6a4039 commit 4bcfcb8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.nav.su.se.bakover.common.infrastructure.web

import arrow.core.Either
import arrow.core.getOrElse
import com.auth0.jwt.interfaces.Payload
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode
Expand Down Expand Up @@ -63,7 +64,9 @@ private fun getGroupsFromJWT(applicationConfig: ApplicationConfig, payload: Payl
return if (applicationConfig.runtimeEnvironment == ApplicationConfig.RuntimeEnvironment.Local) {
applicationConfig.azure.groups.asList()
} else {
payload.getClaim("groups").asList(String::class.java)
Either.catch {
payload.getClaim("groups")?.asList(String::class.java) ?: emptyList<String>()
}.getOrElse { emptyList<String>() }
}
}

Expand Down

0 comments on commit 4bcfcb8

Please sign in to comment.