You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-49Lines changed: 29 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,13 @@
1
1
# Face Authentication Validation Example
2
2
3
-
This project demonstrates a secure face authentication flow using Incode's WebSDK with proper validation and session management. The application implements:
3
+
This project demonstrates a secure face authentication flow using Incode's WebSDK with proper backend validation. The application implements:
4
4
5
-
-**User hint input** for authentication (customerId, email, or phone)
5
+
-**User hint input** for authentication (identityId)
6
6
-**Face authentication** using Incode's renderAuthFace SDK
7
-
-**Session management** with IndexedDB to prevent reuse
8
7
-**Backend validation** to verify authentication integrity by:
9
8
- Matching candidate from the SDK with identityId from the score API
10
-
- Validating overall authentication status
11
-
- Preventing token tampering and session replay attacks
12
-
- Marking sessions as used to prevent reuse
9
+
- Validating overall status to be OK
10
+
- Closing sessions to prevent modification
13
11
14
12
This example showcases best practices for implementing face authentication in a web application with proper security measures.
15
13
@@ -20,64 +18,48 @@ sequenceDiagram
20
18
participant Frontend
21
19
participant Backend
22
20
participant IncodeAPI
23
-
participant IndexedDB
24
21
25
-
Note over Frontend: Enter hint:<br>identityId
22
+
Note over Frontend: Enter hint:<br>identityId
26
23
Note over Frontend: WebSDK: create()
27
24
Frontend->>Backend: Start Session in Backend<br>{identityId}
28
25
Backend->>IncodeAPI: Create new session<br>{configurationId, apikey}
Vite requires Node.js version 14.18+, 16+. some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.
62
+
Vite 8 requires **Node.js ^20.19.0 || >=22.12.0**. Run `node -v`to verify before installing.
81
63
82
64
# Install
83
65
@@ -99,24 +81,22 @@ VITE_FAKE_BACKEND_FLOW_ID=
99
81
100
82
Remember the Flow holds the backend counter part of the process, some configurations there might affect the behavior of the WebSDK here.
101
83
102
-
# Fake Backend Server
84
+
# Example Backend
103
85
104
86
Starting and finishing the session must be done in the backend. To simplify development, this
105
-
sample includes a `fake_backend.js` file that handles backend operations in the frontend.
87
+
sample includes an `example_backend.js` file that handles backend operations in the frontend.
106
88
107
89
**Important:** Replace this with a proper backend for production. The API key should NEVER be exposed in the frontend.
108
90
109
91
## Key Backend Functions
110
92
111
-
-`fakeBackendStart()` - Creates a new session and stores it in IndexedDB with `used: false`
112
-
-`fakeBackendFinish()` - Retrieves the finish status from the API
113
-
-`fakeBackendGetScore()` - Gets the authentication score from the API
114
-
-`fakeBackendValidateAuthentication()` - Validates the authentication by:
115
-
- Checking if the session exists and hasn't been used
116
-
- Verifying the token matches the stored token
117
-
- Comparing candidate with identityId from the score
118
-
- Ensuring overall status is "OK"
119
-
- Marking the session as used to prevent reuse
93
+
-`start(identityId)` - Calls Incode's `/0/omni/start` API to create a new session and returns the session `token`
94
+
-`getResults(token, candidate)` - Verifies the authentication by:
95
+
- Finishing the session via `/0/omni/finish-status` to trigger score calculation
96
+
- Closing the session via `/0/omni/session/status/set?action=Closed` to freeze the score
97
+
- Retrieving the score via `/0/omni/get/score`
98
+
- Comparing `candidate` (from the WebSDK) with `identityId` from the score to prevent tampering
0 commit comments