Skip to content

Commit 5309a67

Browse files
Falha na validação do JWT #39
1 parent 3ed092c commit 5309a67

File tree

7 files changed

+91
-12
lines changed

7 files changed

+91
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ src/*.~*
3232
*.identcache
3333
*.projdata
3434
*.tvsconfig
35+
*.skincfg
3536
*.dsk
3637
*.dcu
3738
*.exe

boss-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hash": "445774d05b3e1b873cfcdb89032b3e1f",
3-
"updated": "2023-03-09T23:35:20.3502827-03:00",
3+
"updated": "2023-08-07T09:27:43.9207961-03:00",
44
"installedModules": {
55
"github.com/andre-djsystem/hashlib4pascal": {
66
"name": "hashlib4pascal",
@@ -12,8 +12,8 @@
1212
},
1313
"github.com/hashload/horse": {
1414
"name": "horse",
15-
"version": "3.1.0",
16-
"hash": "fc3b8eefb46c1a3b387e86ca46a9faa1",
15+
"version": "3.1.4",
16+
"hash": "54665bed032fc96d1398bf5df6332754",
1717
"artifacts": {},
1818
"failed": false,
1919
"changed": false

boss.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"projects": [],
88
"dependencies": {
99
"github.com/andre-djsystem/hashlib4pascal": "^1.0.0",
10-
"github.com/hashload/horse": "^3.1.0",
10+
"github.com/hashload/horse": "^3.1.4",
1111
"github.com/paolo-rossi/delphi-jose-jwt": "^v3.2.0"
1212
}
1313
}

samples/delphi/client/boss-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"hash": "6ef9161b900632671022358216c7dfe7",
3-
"updated": "2023-03-09T23:37:34.5596218-03:00",
3+
"updated": "2023-08-07T09:25:32.3870207-03:00",
44
"installedModules": {
55
"github.com/hashload/horse": {
66
"name": "horse",
7-
"version": "3.1.0",
8-
"hash": "fc3b8eefb46c1a3b387e86ca46a9faa1",
7+
"version": "3.1.4",
8+
"hash": "54665bed032fc96d1398bf5df6332754",
99
"artifacts": {},
1010
"failed": false,
1111
"changed": false

samples/delphi/client/boss.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"mainsrc": "./",
77
"projects": [],
88
"dependencies": {
9-
"github.com/hashload/horse": "^3.1.0",
9+
"github.com/hashload/horse": "^3.1.4",
1010
"github.com/paolo-rossi/delphi-jose-jwt": "^v3.2.0"
1111
}
1212
}

samples/delphi/client/samples_client.dproj

Lines changed: 68 additions & 2 deletions
Large diffs are not rendered by default.

src/Horse.JWT.pas

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
unit Horse.JWT;
22

33
{$IF DEFINED(FPC)}
4-
{$MODE DELPHI}{$H+}
4+
{$MODE DELPHI}{$H+}
55
{$ENDIF}
66

77
interface
@@ -224,8 +224,20 @@ procedure Middleware(AHorseRequest: THorseRequest; AHorseResponse: THorseRespons
224224
LBuilder.SetRequireSubject;
225225
end;
226226

227-
LJWT := TJOSEContext.Create(LToken, TJWTClaims);
228227
try
228+
LJWT := TJOSEContext.Create(LToken, TJWTClaims);
229+
except
230+
AHorseResponse.Send(UNAUTHORIZED).Status(THTTPStatus.Unauthorized);
231+
raise EHorseCallbackInterrupted.Create(UNAUTHORIZED);
232+
end;
233+
234+
try
235+
if LJWT.GetJOSEObject = nil then
236+
begin
237+
AHorseResponse.Send(UNAUTHORIZED).Status(THTTPStatus.Unauthorized);
238+
raise EHorseCallbackInterrupted.Create(UNAUTHORIZED);
239+
end;
240+
229241
LValidations := LBuilder.Build;
230242
try
231243
LValidations.ProcessContext(LJWT);

0 commit comments

Comments
 (0)