Skip to content

Commit

Permalink
Bug fix jwt lazarus
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Feb 8, 2022
1 parent f162515 commit 7a42c60
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 30 deletions.
29 changes: 15 additions & 14 deletions boss-lock.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{
"hash": "445774d05b3e1b873cfcdb89032b3e1f",
"updated": "2019-10-29T12:23:27.0587203-03:00",
"hash": "d41d8cd98f00b204e9800998ecf8427e",
"updated": "2022-02-08T14:16:13.4097104-03:00",
"installedModules": {
"github.com/hashload/horse": {
"name": "horse",
"version": "2.0.13",
"hash": "32daa5a81f115ecc285cbbbbdbcddcea",
"github.com/andre-djsystem/hashlib4pascal": {
"name": "hashlib4pascal",
"version": "1.0.0",
"hash": "8528036224699ab509c7d8f31d691ffb",
"artifacts": {},
"failed": false,
"changed": false
},
"github.com/paolo-rossi/delphi-jose-jwt": {
"name": "delphi-jose-jwt",
"version": "v3.0.0",
"hash": "e07d23afdc06adef34b7fbbabd97ce83",
"github.com/hashload/horse": {
"name": "horse",
"version": "v2.0.14",
"hash": "38c6bebdc7b9712d6e5856d299289a26",
"artifacts": {},
"failed": false,
"changed": false
},
"github.com/andre-djsystem/HashLib4Pascal": {
"name": "HashLib4Pascal",
"version": "v1.0.0",
"github.com/paolo-rossi/delphi-jose-jwt": {
"name": "delphi-jose-jwt",
"version": "v3.0.3",
"hash": "d8b6ff80aff10e83d87219f45fa43ffb",
"artifacts": {},
"failed": false,
"changed": false
}
}
}
}
10 changes: 5 additions & 5 deletions boss.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "horse-jwt",
"description": "",
"version": "2.0.0",
"version": "1.0.0",
"homepage": "",
"mainsrc": "src/",
"mainsrc": "./src",
"projects": [],
"dependencies": {
"github.com/hashload/horse": "^2.0.8",
"github.com/paolo-rossi/delphi-jose-jwt": "^v3.0.0"
"github.com/andre-djsystem/HashLib4Pascal": "^v1.0.0"
"github.com/andre-djsystem/hashlib4pascal": "^1.0.0",
"github.com/hashload/horse": "^v2.0.14",
"github.com/paolo-rossi/delphi-jose-jwt": "^v3.0.3"
}
}
2 changes: 1 addition & 1 deletion horse_jwt.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<DCC_CBuilderOutput>All</DCC_CBuilderOutput>
<RuntimeOnlyPackage>true</RuntimeOnlyPackage>
<SanitizedProjectName>horse_jwt</SanitizedProjectName>
<DCC_UnitSearchPath>C:\Users\hunsc\projects\hashload\horse-jwt\modules\horse\src\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Samples\Basic\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Samples\Console\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Samples\CustomClaims\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Source\Common\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Source\JOSE\;$(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\delphi-jose-jwt\Samples\Basic;modules\delphi-jose-jwt\Samples\Console;modules\delphi-jose-jwt\Samples\CryptoTest;modules\delphi-jose-jwt\Samples\CustomClaims;modules\delphi-jose-jwt\Source\Common;modules\delphi-jose-jwt\Source\JOSE;modules\delphi-jose-jwt\Tests\Source;modules\horse\src</DCC_UnitSearchPath>
<DCC_UnitSearchPath>C:\Users\hunsc\projects\hashload\horse-jwt\modules\horse\src\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Samples\Basic\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Samples\Console\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Samples\CustomClaims\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Source\Common\;C:\Users\hunsc\projects\hashload\horse-jwt\modules\delphi-jwt\Source\JOSE\;$(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\delphi-jose-jwt\Source\Common;modules\delphi-jose-jwt\Source\JOSE;modules\hashlib4pascal\HashLib\src\Base;modules\hashlib4pascal\HashLib\src\Checksum;modules\hashlib4pascal\HashLib\src\Crypto\Blake2BParams;modules\hashlib4pascal\HashLib\src\Crypto\Blake2SParams;modules\hashlib4pascal\HashLib\src\Crypto;modules\hashlib4pascal\HashLib\src\Hash128;modules\hashlib4pascal\HashLib\src\Hash32;modules\hashlib4pascal\HashLib\src\Hash64;modules\hashlib4pascal\HashLib\src\Include;modules\hashlib4pascal\HashLib\src\Interfaces;modules\hashlib4pascal\HashLib\src\Interfaces\IBlake2BParams;modules\hashlib4pascal\HashLib\src\Interfaces\IBlake2SParams;modules\hashlib4pascal\HashLib\src\KDF;modules\hashlib4pascal\HashLib\src\NullDigest;modules\hashlib4pascal\HashLib\src\Nullable;modules\hashlib4pascal\HashLib\src\Packages\FPC;modules\hashlib4pascal\HashLib\src\Utils;modules\hashlib4pascal\HashLib.Benchmark\src\Core;modules\hashlib4pascal\HashLib.Benchmark\src\Forms\FMX;modules\hashlib4pascal\HashLib.Tests\src;modules\horse\src</DCC_UnitSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
Expand Down
2 changes: 1 addition & 1 deletion samples/delphi/auth/samples.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ begin
end;
end);

THorse.Listen(9000);
THorse.Listen(3000);
end.
2 changes: 1 addition & 1 deletion samples/delphi/auth/samples.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<UsingDelphiRTL>true</UsingDelphiRTL>
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
<DCC_UnitSearchPath>$(Horse);$(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\delphi-jose-jwt\Source\Common;modules\delphi-jose-jwt\Source\JOSE;modules\horse\src;modules\jhonson\src</DCC_UnitSearchPath>
<DCC_UnitSearchPath>$(Horse);modules\.dcp;modules\.dcu;modules;modules\delphi-jose-jwt\Source\Common;modules\delphi-jose-jwt\Source\JOSE;modules\horse\src;modules\jhonson\src;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<DCC_Framework>VCL;$(DCC_Framework)</DCC_Framework>
<SanitizedProjectName>samples</SanitizedProjectName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/delphi/client/samples.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<UsingDelphiRTL>true</UsingDelphiRTL>
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
<DCC_UnitSearchPath>$(Horse);modules\.dcp;modules\.dcu;modules;modules\delphi-jose-jwt\Source\Common;modules\delphi-jose-jwt\Source\JOSE;modules\horse\src;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<DCC_UnitSearchPath>$(Horse);$(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\delphi-jose-jwt\Source\Common;modules\delphi-jose-jwt\Source\JOSE;modules\horse\src</DCC_UnitSearchPath>
<DCC_Framework>VCL;$(DCC_Framework)</DCC_Framework>
<SanitizedProjectName>samples</SanitizedProjectName>
</PropertyGroup>
Expand Down
17 changes: 12 additions & 5 deletions samples/lazarus/client/Console.lpi
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<MainUnitHasScaledStatement Value="False"/>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Console"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
Expand All @@ -24,7 +24,6 @@
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<Units Count="1">
<Unit0>
Expand All @@ -41,15 +40,20 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\..\src;modules\.dcp;modules\.dcu;modules;modules\horse\src;modules\hashlib4pascal\HashLib\src\Base;modules\hashlib4pascal\HashLib\src\Crypto\Blake2BParams;modules\hashlib4pascal\HashLib\src\Crypto\Blake2SParams;modules\hashlib4pascal\HashLib\src\Interfaces\IBlake2BParams;modules\hashlib4pascal\HashLib\src\Interfaces\IBlake2SParams;modules\hashlib4pascal\HashLib\src\Checksum;modules\hashlib4pascal\HashLib\src\Crypto;modules\hashlib4pascal\HashLib\src\Hash32;modules\hashlib4pascal\HashLib\src\Hash64;modules\hashlib4pascal\HashLib\src\Hash128;modules\hashlib4pascal\HashLib\src\Include;modules\hashlib4pascal\HashLib\src\Interfaces;modules\hashlib4pascal\HashLib\src\KDF;modules\hashlib4pascal\HashLib\src\Nullable;modules\hashlib4pascal\HashLib\src\NullDigest;modules\hashlib4pascal\HashLib\src\Utils"/>
<OtherUnitFiles Value="..\..\..\src;modules\.dcp;modules\.dcu;modules;modules\hashlib4pascal\HashLib\src\Base;modules\hashlib4pascal\HashLib\src\Checksum;modules\hashlib4pascal\HashLib\src\Crypto\Blake2BParams;modules\hashlib4pascal\HashLib\src\Crypto\Blake2SParams;modules\hashlib4pascal\HashLib\src\Crypto;modules\hashlib4pascal\HashLib\src\Hash128;modules\hashlib4pascal\HashLib\src\Hash32;modules\hashlib4pascal\HashLib\src\Hash64;modules\hashlib4pascal\HashLib\src\Include;modules\hashlib4pascal\HashLib\src\Interfaces;modules\hashlib4pascal\HashLib\src\Interfaces\IBlake2BParams;modules\hashlib4pascal\HashLib\src\Interfaces\IBlake2SParams;modules\hashlib4pascal\HashLib\src\KDF;modules\hashlib4pascal\HashLib\src\NullDigest;modules\hashlib4pascal\HashLib\src\Nullable;modules\hashlib4pascal\HashLib\src\Packages\FPC;modules\hashlib4pascal\HashLib\src\Utils;modules\hashlib4pascal\HashLib.Benchmark\src\Core;modules\hashlib4pascal\HashLib.Benchmark\src\Forms\FMX;modules\hashlib4pascal\HashLib.Tests\src;modules\horse\src"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
<Other>
<CustomOptions Value="-dUseCThreads"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Exceptions Count="4">
<Item1>
<Name Value="EAbort"/>
</Item1>
Expand All @@ -59,6 +63,9 @@
<Item3>
<Name Value="EFOpenError"/>
</Item3>
<Item4>
<Name Value="EResNotFound"/>
</Item4>
</Exceptions>
</Debugging>
</CONFIG>
4 changes: 2 additions & 2 deletions src/Horse.JWT.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface

uses
{$IF DEFINED(FPC)}
Generics.Collections, Classes, fpjson, SysUtils, HTTPDefs, fpjwt, Base64, DateUtils,
Generics.Collections, Classes, fpjson, SysUtils, HTTPDefs, fpjwt, Base64, DateUtils, jsonparser,
HlpIHashInfo, HlpConverters, HlpHashFactory,
{$ELSE}
System.Generics.Collections, System.Classes, System.JSON, System.SysUtils, Web.HTTPApp, REST.JSON, JOSE.Core.JWT,
Expand Down Expand Up @@ -211,7 +211,7 @@ procedure Middleware(AHorseRequest: THorseRequest;
if (Trim(LJWT.Signature) = EmptyStr) or (not ValidateSignature) then
raise Exception.Create('Invalid signature');

if (LJWT.Claims.exp <> 0) and (LJWT.Claims.exp > DateTimeToUnix(Now)) then
if (LJWT.Claims.exp <> 0) and (LJWT.Claims.exp < DateTimeToUnix(Now)) then
raise Exception.Create(Format(
'The JWT is no longer valid - the evaluation time [%s] is on or after the Expiration Time [exp=%s]',
[DateToISO8601(Now, False), DateToISO8601(LJWT.Claims.exp, False)]));
Expand Down

0 comments on commit 7a42c60

Please sign in to comment.