mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
add exception logging for JWT validation failure
This commit is contained in:
parent
9f14cd0a5e
commit
d4f06b96ff
@ -146,6 +146,7 @@ namespace CarCareTracker.Controllers
|
|||||||
var userAccessToken = decodedToken?.access_token ?? string.Empty;
|
var userAccessToken = decodedToken?.access_token ?? string.Empty;
|
||||||
var tokenParser = new JsonWebTokenHandler();
|
var tokenParser = new JsonWebTokenHandler();
|
||||||
bool passedSignatureCheck = true;
|
bool passedSignatureCheck = true;
|
||||||
|
string signatureValidationError = "check jwks endpoint";
|
||||||
if (!string.IsNullOrWhiteSpace(openIdConfig.JwksURL))
|
if (!string.IsNullOrWhiteSpace(openIdConfig.JwksURL))
|
||||||
{
|
{
|
||||||
//validate token signature if jwks endpoint is provided
|
//validate token signature if jwks endpoint is provided
|
||||||
@ -165,6 +166,10 @@ namespace CarCareTracker.Controllers
|
|||||||
if (!validatedIdToken.IsValid)
|
if (!validatedIdToken.IsValid)
|
||||||
{
|
{
|
||||||
passedSignatureCheck = false;
|
passedSignatureCheck = false;
|
||||||
|
if (validatedIdToken.Exception != null && !string.IsNullOrWhiteSpace(validatedIdToken.Exception.Message))
|
||||||
|
{
|
||||||
|
signatureValidationError = validatedIdToken.Exception.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,7 +243,7 @@ namespace CarCareTracker.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.LogError($"OpenID Provider did not provide a valid id_token: check jwks endpoint");
|
_logger.LogError($"OpenID Provider did not provide a valid id_token: {signatureValidationError}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -329,6 +334,10 @@ namespace CarCareTracker.Controllers
|
|||||||
if (!validatedIdToken.IsValid)
|
if (!validatedIdToken.IsValid)
|
||||||
{
|
{
|
||||||
passedSignatureCheck = false;
|
passedSignatureCheck = false;
|
||||||
|
if (validatedIdToken.Exception != null && !string.IsNullOrWhiteSpace(validatedIdToken.Exception.Message))
|
||||||
|
{
|
||||||
|
results.Add(OperationResponse.Failed($"Failed JWT Validation: {validatedIdToken.Exception.Message}"));
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
results.Add(OperationResponse.Succeed($"Passed JWT Validation - Valid To: {validatedIdToken.SecurityToken.ValidTo}"));
|
results.Add(OperationResponse.Succeed($"Passed JWT Validation - Valid To: {validatedIdToken.SecurityToken.ValidTo}"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user