Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emiMobile
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
Mac Stephens
emiMobile
Commits
f0dd0b62
Commit
f0dd0b62
authored
May 06, 2026
by
Michael Brachmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auth token pass with ws
parent
39d668d7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
Ws.Server.Module.dfm
emiMobileServer/Source/Ws.Server.Module.dfm
+1
-0
Module.Websocket.pas
webEMIMobile/Module.Websocket.pas
+17
-4
No files found.
emiMobileServer/Source/Ws.Server.Module.dfm
View file @
f0dd0b62
...
...
@@ -29,6 +29,7 @@ object WsServerModule: TWsServerModule
end
object XDataServer1JWT: TSparkleJwtMiddleware
OnGetSecret = XDataServer1JWTGetSecret
TokenParam = 'token'
end
end
end
webEMIMobile/Module.Websocket.pas
View file @
f0dd0b62
...
...
@@ -3,7 +3,8 @@ unit Module.Websocket;
interface
uses
System
.
SysUtils
,
System
.
Classes
,
WEBLib
.
WebSocketClient
,
Web
,
WEBLib
.
Controls
,
WEBLib
.
Modules
;
System
.
SysUtils
,
System
.
Classes
,
WEBLib
.
WebSocketClient
,
Web
,
WEBLib
.
Controls
,
WEBLib
.
Modules
,
Auth
.
Service
;
type
TdmWebsocket
=
class
(
TWebDataModule
)
...
...
@@ -41,7 +42,7 @@ end;
procedure
TdmWebsocket
.
Connect
(
const
AWsUrl
:
string
);
var
Rest
,
HostPort
,
Scheme
:
string
;
Rest
,
HostPort
,
Scheme
,
Path
,
Token
:
string
;
ColonSlashSlash
,
SlashPos
,
ColonPos
:
Integer
;
begin
if
AWsUrl
=
''
then
...
...
@@ -59,14 +60,26 @@ begin
if
SlashPos
>
0
then
begin
HostPort
:=
Copy
(
Rest
,
1
,
SlashPos
-
1
);
EMiMobileWebSocketClient
.
PathName
:=
Copy
(
Rest
,
SlashPos
,
MaxInt
);
Path
:=
Copy
(
Rest
,
SlashPos
,
MaxInt
);
end
else
begin
HostPort
:=
Rest
;
EMiMobileWebSocketClient
.
PathName
:=
'/'
;
Path
:=
'/'
;
end
;
// Append JWT token as query param — browsers can't set Authorization headers on WebSocket.
Token
:=
AuthService
.
GetToken
;
if
Token
<>
''
then
begin
if
Pos
(
'?'
,
Path
)
>
0
then
Path
:=
Path
+
'&token='
+
Token
else
Path
:=
Path
+
'?token='
+
Token
;
end
;
EMiMobileWebSocketClient
.
PathName
:=
Path
;
ColonPos
:=
Pos
(
':'
,
HostPort
);
if
ColonPos
>
0
then
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