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
f4e97894
Commit
f4e97894
authored
Aug 27, 2026
by
Michael Brachmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a2573e3e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
Auth.ServiceImpl.pas
emiMobileServer/Source/Auth.ServiceImpl.pas
+8
-10
No files found.
emiMobileServer/Source/Auth.ServiceImpl.pas
View file @
f4e97894
...
@@ -188,7 +188,7 @@ var
...
@@ -188,7 +188,7 @@ var
cdJsonBytes
,
attObjBytes
,
credIdBytes
:
TBytes
;
cdJsonBytes
,
attObjBytes
,
credIdBytes
:
TBytes
;
cdJsonText
:
string
;
cdJsonText
:
string
;
cdJson
:
TJSONObject
;
cdJson
:
TJSONObject
;
typeVal
,
challengeVal
:
string
;
typeVal
,
challengeVal
,
originVal
,
effectiveRpId
:
string
;
authData
:
TBytes
;
authData
:
TBytes
;
rpIdHash
,
credId
,
pubKeyX
,
pubKeyY
:
TBytes
;
rpIdHash
,
credId
,
pubKeyX
,
pubKeyY
:
TBytes
;
flags
:
Byte
;
flags
:
Byte
;
...
@@ -229,7 +229,6 @@ begin
...
@@ -229,7 +229,6 @@ begin
Exit
;
Exit
;
end
;
end
;
var
originVal
:
string
;
try
try
typeVal
:=
cdJson
.
GetValue
<
string
>(
'type'
,
''
);
typeVal
:=
cdJson
.
GetValue
<
string
>(
'type'
,
''
);
challengeVal
:=
cdJson
.
GetValue
<
string
>(
'challenge'
,
''
);
challengeVal
:=
cdJson
.
GetValue
<
string
>(
'challenge'
,
''
);
...
@@ -255,10 +254,10 @@ begin
...
@@ -255,10 +254,10 @@ begin
// Derive effectiveRpId from the origin the browser reported.
// Derive effectiveRpId from the origin the browser reported.
// Falls back to ServerConfig.rpId only if origin is absent.
// Falls back to ServerConfig.rpId only if origin is absent.
var
effectiveRpId
:=
ExtractOriginHostname
(
originVal
);
effectiveRpId
:=
ExtractOriginHostname
(
originVal
);
if
effectiveRpId
=
''
then
if
effectiveRpId
=
''
then
effectiveRpId
:=
ServerConfig
.
rpId
;
effectiveRpId
:=
ServerConfig
.
rpId
;
Logger
.
Log
(
3
,
'CompleteRegistration - effectiveRpId: "'
+
effectiveRpId
+
'" (origin: "'
+
originVal
+
'")
'
);
Logger
.
Log
(
2
,
'CompleteRegistration - effectiveRpId: "'
+
effectiveRpId
+
'" origin: "'
+
originVal
+
'"
'
);
// 3. Decode attestationObject and extract authData
// 3. Decode attestationObject and extract authData
...
@@ -443,7 +442,7 @@ var
...
@@ -443,7 +442,7 @@ var
cdJsonBytes
,
authDataBytes
,
sigBytes
:
TBytes
;
cdJsonBytes
,
authDataBytes
,
sigBytes
:
TBytes
;
cdJsonText
:
string
;
cdJsonText
:
string
;
cdJson
:
TJSONObject
;
cdJson
:
TJSONObject
;
typeVal
,
challengeVal
:
string
;
typeVal
,
challengeVal
,
loginOriginVal
,
loginEffectiveRpId
:
string
;
rpIdHash
,
expectedRpIdHash
:
TBytes
;
rpIdHash
,
expectedRpIdHash
:
TBytes
;
flags
:
Byte
;
flags
:
Byte
;
signCount
:
Cardinal
;
signCount
:
Cardinal
;
...
@@ -494,7 +493,6 @@ begin
...
@@ -494,7 +493,6 @@ begin
if
not
Assigned
(
cdJson
)
then
if
not
Assigned
(
cdJson
)
then
raise
EXDataHttpUnauthorized
.
Create
(
'clientDataJSON is not valid JSON.'
);
raise
EXDataHttpUnauthorized
.
Create
(
'clientDataJSON is not valid JSON.'
);
var
loginOriginVal
:
string
;
try
try
typeVal
:=
cdJson
.
GetValue
<
string
>(
'type'
,
''
);
typeVal
:=
cdJson
.
GetValue
<
string
>(
'type'
,
''
);
challengeVal
:=
cdJson
.
GetValue
<
string
>(
'challenge'
,
''
);
challengeVal
:=
cdJson
.
GetValue
<
string
>(
'challenge'
,
''
);
...
@@ -509,10 +507,10 @@ begin
...
@@ -509,10 +507,10 @@ begin
if
challengeVal
<>
challengeB64
then
if
challengeVal
<>
challengeB64
then
raise
EXDataHttpUnauthorized
.
Create
(
'Challenge mismatch.'
);
raise
EXDataHttpUnauthorized
.
Create
(
'Challenge mismatch.'
);
var
loginEffectiveRpId
:=
ExtractOriginHostname
(
loginOriginVal
);
loginEffectiveRpId
:=
ExtractOriginHostname
(
loginOriginVal
);
if
loginEffectiveRpId
=
''
then
if
loginEffectiveRpId
=
''
then
loginEffectiveRpId
:=
ServerConfig
.
rpId
;
loginEffectiveRpId
:=
ServerConfig
.
rpId
;
Logger
.
Log
(
3
,
Format
(
'AuthService.Login - effectiveRpId: "%s"'
,
[
loginEffectiveRpId
]));
Logger
.
Log
(
2
,
Format
(
'AuthService.Login - effectiveRpId: "%s" origin: "%s"'
,
[
loginEffectiveRpId
,
loginOriginVal
]));
// 4. Load credential from DB
// 4. Load credential from DB
q
:=
TUniQuery
.
Create
(
nil
);
q
:=
TUniQuery
.
Create
(
nil
);
...
@@ -550,13 +548,13 @@ begin
...
@@ -550,13 +548,13 @@ begin
if
Length
(
authDataBytes
)
<
37
then
if
Length
(
authDataBytes
)
<
37
then
raise
EXDataHttpUnauthorized
.
Create
(
'authenticatorData too short.'
);
raise
EXDataHttpUnauthorized
.
Create
(
'authenticatorData too short.'
);
// Verify rpIdHash (first 32 bytes of authData) against effective rpId from origin
// Verify rpIdHash (first 32 bytes of authData) against effective rpId from
clientDataJSON
origin
SetLength
(
rpIdHash
,
32
);
SetLength
(
rpIdHash
,
32
);
Move
(
authDataBytes
[
0
],
rpIdHash
[
0
],
32
);
Move
(
authDataBytes
[
0
],
rpIdHash
[
0
],
32
);
expectedRpIdHash
:=
SHA256Bytes
(
TEncoding
.
UTF8
.
GetBytes
(
loginEffectiveRpId
));
expectedRpIdHash
:=
SHA256Bytes
(
TEncoding
.
UTF8
.
GetBytes
(
loginEffectiveRpId
));
if
not
CompareMem
(@
rpIdHash
[
0
],
@
expectedRpIdHash
[
0
],
32
)
then
if
not
CompareMem
(@
rpIdHash
[
0
],
@
expectedRpIdHash
[
0
],
32
)
then
raise
EXDataHttpUnauthorized
.
Create
(
raise
EXDataHttpUnauthorized
.
Create
(
Format
(
'rpId mismatch
(server derived "%s" from origin "%s").
'
,
[
loginEffectiveRpId
,
loginOriginVal
]));
Format
(
'rpId mismatch
— server used "%s" (from origin "%s")
'
,
[
loginEffectiveRpId
,
loginOriginVal
]));
// Check user-present flag
// Check user-present flag
flags
:=
authDataBytes
[
32
];
flags
:=
authDataBytes
[
32
];
...
...
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