Skip to content

Commit 7a42c60

Browse files
Bug fix jwt lazarus
1 parent f162515 commit 7a42c60

File tree

8 files changed

+38
-30
lines changed

8 files changed

+38
-30
lines changed

boss-lock.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
{
2-
"hash": "445774d05b3e1b873cfcdb89032b3e1f",
3-
"updated": "2019-10-29T12:23:27.0587203-03:00",
2+
"hash": "d41d8cd98f00b204e9800998ecf8427e",
3+
"updated": "2022-02-08T14:16:13.4097104-03:00",
44
"installedModules": {
5-
"github.com/hashload/horse": {
6-
"name": "horse",
7-
"version": "2.0.13",
8-
"hash": "32daa5a81f115ecc285cbbbbdbcddcea",
5+
"github.com/andre-djsystem/hashlib4pascal": {
6+
"name": "hashlib4pascal",
7+
"version": "1.0.0",
8+
"hash": "8528036224699ab509c7d8f31d691ffb",
99
"artifacts": {},
1010
"failed": false,
1111
"changed": false
1212
},
13-
"github.com/paolo-rossi/delphi-jose-jwt": {
14-
"name": "delphi-jose-jwt",
15-
"version": "v3.0.0",
16-
"hash": "e07d23afdc06adef34b7fbbabd97ce83",
13+
"github.com/hashload/horse": {
14+
"name": "horse",
15+
"version": "v2.0.14",
16+
"hash": "38c6bebdc7b9712d6e5856d299289a26",
1717
"artifacts": {},
1818
"failed": false,
1919
"changed": false
2020
},
21-
"github.com/andre-djsystem/HashLib4Pascal": {
22-
"name": "HashLib4Pascal",
23-
"version": "v1.0.0",
21+
"github.com/paolo-rossi/delphi-jose-jwt": {
22+
"name": "delphi-jose-jwt",
23+
"version": "v3.0.3",
24+
"hash": "d8b6ff80aff10e83d87219f45fa43ffb",
2425
"artifacts": {},
2526
"failed": false,
2627
"changed": false
27-
}
28+
}
2829
}
2930
}

boss.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "horse-jwt",
33
"description": "",
4-
"version": "2.0.0",
4+
"version": "1.0.0",
55
"homepage": "",
6-
"mainsrc": "src/",
6+
"mainsrc": "./src",
77
"projects": [],
88
"dependencies": {
9-
"github.com/hashload/horse": "^2.0.8",
10-
"github.com/paolo-rossi/delphi-jose-jwt": "^v3.0.0"
11-
"github.com/andre-djsystem/HashLib4Pascal": "^v1.0.0"
9+
"github.com/andre-djsystem/hashlib4pascal": "^1.0.0",
10+
"github.com/hashload/horse": "^v2.0.14",
11+
"github.com/paolo-rossi/delphi-jose-jwt": "^v3.0.3"
1212
}
1313
}

horse_jwt.dproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<DCC_CBuilderOutput>All</DCC_CBuilderOutput>
5959
<RuntimeOnlyPackage>true</RuntimeOnlyPackage>
6060
<SanitizedProjectName>horse_jwt</SanitizedProjectName>
61-
<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>
61+
<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>
6262
</PropertyGroup>
6363
<PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
6464
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>

samples/delphi/auth/samples.dpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ begin
3131
end;
3232
end);
3333

34-
THorse.Listen(9000);
34+
THorse.Listen(3000);
3535
end.

samples/delphi/auth/samples.dproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<UsingDelphiRTL>true</UsingDelphiRTL>
7777
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
7878
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
79-
<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>
79+
<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>
8080
<DCC_Framework>VCL;$(DCC_Framework)</DCC_Framework>
8181
<SanitizedProjectName>samples</SanitizedProjectName>
8282
</PropertyGroup>

samples/delphi/client/samples.dproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<UsingDelphiRTL>true</UsingDelphiRTL>
7272
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
7373
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
74-
<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>
74+
<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>
7575
<DCC_Framework>VCL;$(DCC_Framework)</DCC_Framework>
7676
<SanitizedProjectName>samples</SanitizedProjectName>
7777
</PropertyGroup>

samples/lazarus/client/Console.lpi

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<CONFIG>
33
<ProjectOptions>
4-
<Version Value="11"/>
4+
<Version Value="12"/>
55
<PathDelim Value="\"/>
66
<General>
77
<Flags>
88
<MainUnitHasCreateFormStatements Value="False"/>
99
<MainUnitHasTitleStatement Value="False"/>
1010
<MainUnitHasScaledStatement Value="False"/>
11+
<CompatibilityMode Value="True"/>
1112
</Flags>
1213
<SessionStorage Value="InProjectDir"/>
13-
<MainUnit Value="0"/>
1414
<Title Value="Console"/>
1515
<UseAppBundle Value="False"/>
1616
<ResourceType Value="res"/>
@@ -24,7 +24,6 @@
2424
</PublishOptions>
2525
<RunParams>
2626
<FormatVersion Value="2"/>
27-
<Modes Count="0"/>
2827
</RunParams>
2928
<Units Count="1">
3029
<Unit0>
@@ -41,15 +40,20 @@
4140
</Target>
4241
<SearchPaths>
4342
<IncludeFiles Value="$(ProjOutDir)"/>
44-
<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"/>
43+
<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"/>
4544
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
4645
</SearchPaths>
46+
<Linking>
47+
<Debugging>
48+
<DebugInfoType Value="dsDwarf2Set"/>
49+
</Debugging>
50+
</Linking>
4751
<Other>
4852
<CustomOptions Value="-dUseCThreads"/>
4953
</Other>
5054
</CompilerOptions>
5155
<Debugging>
52-
<Exceptions Count="3">
56+
<Exceptions Count="4">
5357
<Item1>
5458
<Name Value="EAbort"/>
5559
</Item1>
@@ -59,6 +63,9 @@
5963
<Item3>
6064
<Name Value="EFOpenError"/>
6165
</Item3>
66+
<Item4>
67+
<Name Value="EResNotFound"/>
68+
</Item4>
6269
</Exceptions>
6370
</Debugging>
6471
</CONFIG>

src/Horse.JWT.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface
88

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

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

0 commit comments

Comments
 (0)