TMVCJWTAuthenticationMiddleware: Exception will prevent authentication with a json object #337
Labels
accepted
Issue has been accepted and inserted in a future milestone
Milestone
Hello,
in procedure TMVCJWTAuthenticationMiddleware.OnBeforeRouting (unit MVCFramework.Middleware.JWT) , if one tries to pass the jwtusername and jwtpassword as a json object, an exception will be raised because it will attempt first to evaluate the content as ampersand separated name=values.
On line 288 (
LUsername := AContext.Request.ContentFields[FUserNameHeaderName]
) an exception will be raised because FUserNameHeaderName does not exist (obviously) in AContext.Request.ContentFields dictionnary.Now, if you change the code:
to:
You might still get an exception if your json content is written on more that one line, because you will attempt to add two empty names to the ContentFields dictionnary.
One solution would be to write :
I think it would be even better to check if the content-type is application/json and go directly to the json reader.
Regards,
The text was updated successfully, but these errors were encountered: