Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kgOrders
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cam Hayes
kgOrders
Commits
6219d663
Commit
6219d663
authored
Jan 02, 2026
by
Cam Hayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JWT Token working and tested for expiration
parent
3a2f4189
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
Api.Server.Module.dfm
kgOrdersServer/Source/Api.Server.Module.dfm
+2
-0
Api.Server.Module.pas
kgOrdersServer/Source/Api.Server.Module.pas
+23
-0
No files found.
kgOrdersServer/Source/Api.Server.Module.dfm
View file @
6219d663
...
...
@@ -24,7 +24,9 @@ object ApiServerModule: TApiServerModule
object XDataServerCompress: TSparkleCompressMiddleware
end
object XDataServerJWT: TSparkleJwtMiddleware
ForbidAnonymousAccess = True
OnGetSecret = XDataServerJWTGetSecret
OnForbidRequest = XDataServerJWTForbidRequest
end
end
end
kgOrdersServer/Source/Api.Server.Module.pas
View file @
6219d663
...
...
@@ -28,6 +28,8 @@ type
procedure
XDataServerLoggingMiddlewareCreate
(
Sender
:
TObject
;
var
Middleware
:
IHttpServerMiddleware
);
procedure
XDataServerJWTGetSecret
(
Sender
:
TObject
;
var
Secret
:
string
);
procedure
XDataServerJWTForbidRequest
(
Sender
:
TObject
;
Context
:
THttpServerContext
;
var
Forbid
:
Boolean
);
private
{ Private declarations }
public
...
...
@@ -91,6 +93,27 @@ begin
Middleware
:=
TLoggingMiddleware
.
Create
(
Logger
);
end
;
procedure
TApiServerModule
.
XDataServerJWTForbidRequest
(
Sender
:
TObject
;
Context
:
THttpServerContext
;
var
Forbid
:
Boolean
);
var
Path
:
string
;
begin
Path
:=
Context
.
Request
.
Uri
.
Path
;
if
SameText
(
Context
.
Request
.
Method
,
'OPTIONS'
)
then
Forbid
:=
False
;
if
Path
.
Contains
(
'/swaggerui'
)
then
Forbid
:=
False
;
if
Path
.
Contains
(
'/openapi/swagger.json'
)
then
Forbid
:=
False
;
if
Forbid
then
Logger
.
Log
(
1
,
'[JWT] ForbidRequest fired (token missing/invalid/expired?)'
);
end
;
procedure
TApiServerModule
.
XDataServerJWTGetSecret
(
Sender
:
TObject
;
var
Secret
:
string
);
begin
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment