Senseless Default-Parameter in new TMVCJWTAuthenticationMiddleware Constructor
DeddyH opened this issue · comments
DeddyH commented
In the "new" constructor the fourth parameter AConfigClaims of type TJWTClaimsSetup is default nil, but if you leave it blank you will get an exception in OnBeforeRouting. To solve this problem I suggest one of the following solutions:
- Make it mandatory. This would require swapping params for uniqueness, e.g.
constructor Create(
AConfigClaims: TJWTClaimsSetup;
AAuthenticationHandler: IMVCAuthenticationHandler;
ASecret: string = 'D3lph1MVCFram3w0rk';
ALoginURLSegment: string = '/login';
AClaimsToCheck: TJWTCheckableClaims = [];
ALeewaySeconds: Cardinal = 300); overload; virtual;
- Leave the signature as is, but set up a default one if nil, e.g.
constructor TMVCJWTAuthenticationMiddleware.Create(AAuthenticationHandler: IMVCAuthenticationHandler;
ASecret, ALoginURLSegment: string; AConfigClaims: TJWTClaimsSetup; AClaimsToCheck: TJWTCheckableClaims;
ALeewaySeconds: Cardinal);
begin
inherited Create;
FAuthenticationHandler := AAuthenticationHandler;
FSetupJWTClaims := AConfigClaims;
if not Assigned(FSetupJWTClaims) then
FSetupJWTClaims := procedure(const JWT: TJWT)
begin
// setup some reasonable claims here
end;
...
end;