Skip to content

Commit

Permalink
feat: UUI-2008
Browse files Browse the repository at this point in the history
Add EID for DK
  • Loading branch information
pklawikowski-schibsted committed Oct 1, 2024
1 parent 793d08b commit 8d2d3a5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ enum class MfaType(val value: String) {
EID_NO("eid-no"), //Only used for PRE environment
EID_SE("eid-se"), //Only used for PRE environment
EID_FI("eid-fi"), //Only used for PRE environment
EID_DK("eid-dk"), //Only used for PRE environment
EID("eid"), // For Production
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ internal class IdTokenClaimsVerifier(
// Regardless of country, AMR will only contain EID value
if (needle == MfaType.EID_NO.value ||
needle == MfaType.EID_SE.value ||
needle == MfaType.EID_FI.value
needle == MfaType.EID_FI.value ||
needle == MfaType.EID_DK.value
) {
needle = MfaType.EID.value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,38 @@ class IdTokenValidatorTest {
}
}

@Test
fun testAcceptsEidDKAMRWithoutCountryPrefix() {
val expectedAmrValue = "eid-dk"
val context = IdTokenValidationContext(issuer, clientId, nonce, expectedAmrValue)
val claims = defaultIdTokenClaims()
.claim("amr", listOf("eid", "otherValue"))
.build()
val idToken = createIdToken(claims)
IdTokenValidator.validate(idToken, TestJwks(jwks), context) { result ->
result.assertRight { assertEquals(idTokenClaims(claims), it) }
}
}

@Test
fun testRejectsWrongEidAMRWithoutCountryPrefix() {
val expectedAmrValue = "eid-wrong"
val context = IdTokenValidationContext(issuer, clientId, nonce, expectedAmrValue)
val claims =
defaultIdTokenClaims()
.claim("amr", listOf("eid", "otherValue"))
.build()
val idToken = createIdToken(claims)
IdTokenValidator.validate(idToken, TestJwks(jwks), context) { result ->
result.assertLeft {
assertErrorMessage(
"Missing expected AMR value: $expectedAmrValue",
it.message
)
}
}
}

@Test
fun testRejectMissingExpectedAMRInIdTokenWithoutAMR() {
val context = IdTokenValidationContext(issuer, clientId, nonce, "testValue")
Expand Down

0 comments on commit 8d2d3a5

Please sign in to comment.