1
0
Форкнуть 0

Merge pull request #172 from microsoft/niganesh/make-pin-optional-during-validation

don't fail if pin is missing in idtokenhint during validation
This commit is contained in:
nithyaganeshng 2021-07-13 13:05:04 -07:00 коммит произвёл GitHub
Родитель 4c8b638315 3bc8434cea
Коммит 07463922fd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -71,10 +71,13 @@ class OidcPresentationRequestValidator @Inject constructor(private val jwtValida
if (!jwtValidator.verifySignature(jwsToken))
throw InvalidSignatureException("Signature is not valid on id token hint.")
val json = Json.decodeFromString(JsonObject.serializer(), jwsToken.content())
val pinObject = json["pin"] as? JsonObject ?: throw InvalidPinDetailsException("PIN details is missing in request.")
val length = (pinObject["length"] as? JsonPrimitive)?.content?.toInt() ?: throw InvalidPinDetailsException("PIN length is missing in request.")
val type = (pinObject["type"] as? JsonPrimitive)?.content ?: throw InvalidPinDetailsException("PIN type is missing in request.")
if (length < 1) throw InvalidPinDetailsException("PIN length is invalid in request.")
if (!(type == "numeric" || type == "text")) throw InvalidPinDetailsException("PIN type is invalid in request.")
val pinObject = json["pin"] as? JsonObject
if (pinObject != null) {
val length = (pinObject["length"] as? JsonPrimitive)?.content?.toInt()
?: throw InvalidPinDetailsException("PIN length is missing in request.")
val type = (pinObject["type"] as? JsonPrimitive)?.content ?: throw InvalidPinDetailsException("PIN type is missing in request.")
if (length < 1) throw InvalidPinDetailsException("PIN length is invalid in request.")
if (!(type == "numeric" || type == "text")) throw InvalidPinDetailsException("PIN type is invalid in request.")
}
}
}