Commit Graph
40 Commits
Author SHA1 Message Date
Hamza-Ayed 915d517ba7 Port all fixes from IntaleqApp (Wallet, CLIQ, OTP, Docker) 2026-08-01 03:58:37 +03:00
Hamza-AyedandClaude Opus 5 39b5a7fc7f Keep OTP phone numbers recoverable for customer-service follow-up
Storing the verification phone as a keyed HMAC made OTP lookups independent
of the encryption mode, but the hash is one-way — and customer service reads
those same rows to chase people who requested a code and never finished
registering. That workflow would have lost the number entirely.

The verification tables now carry both forms: phone_number holds the lookup
key, and a new phone_enc column holds the encrypted number, which is
decryptable when a human needs to call.

The two follow-up queries also compared the verification row against the
driver/passengers tables and the notes tables by matching ciphertext, which
only ever worked because encryption was deterministic. Under GCM every number
would have looked unregistered and every note would have disappeared. Both now
read the number from phone_enc and match on normalised plaintext, so they are
correct under either mode.

Rows written before phone_enc existed are skipped rather than shown without a
number.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-25 16:27:29 +03:00
Hamza-AyedandClaude Opus 5 a1c19b052d Make OTP verification independent of the encryption mode
The verification tables (token_verification*, phone_verification*) use the
phone number as a lookup key: written when the code is sent, read when it is
checked. Storing it encrypted worked only because encryptData() is
deterministic — under AES-GCM the two sides would produce different
ciphertexts and no code would ever verify, locking every user out of
registration and OTP sign-in.

otpPhoneKey() stores a keyed HMAC of the normalised number instead. No schema
change is needed since the column is textual, local and international formats
now resolve to the same key, and the value cannot be reversed without the
pepper. It falls back to the previous behaviour when no pepper is configured.

Applied to both sides of every affected flow — request/verify, and the driver
and passenger send/verify pairs — including the OTP value itself where it is
compared by equality rather than decrypted. auth/otp/verify.php already
decrypts the token before comparing, so it needed no change there.

Also adds ENCRYPTION_MODE to EncryptionHelper: encryptData() writes GCM when
set to 'gcm', CBC otherwise. Verified in both directions — rows written under
CBC stay readable after switching, and rows written under GCM stay readable
after rolling back — so the switch is reversible by an environment variable.

The admin console's own OTP is unaffected: it keys the table by the stored
ciphertext read from adminUser, identical on both sides.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-25 16:18:16 +03:00
Hamza-Ayed 699b380f2b Update: 2026-07-21 20:58:30 2026-07-21 20:58:30 +03:00
Hamza-Ayed 3d0c266b7a Update: 2026-07-21 20:55:19 2026-07-21 20:55:20 +03:00
Hamza-Ayed 23f697b1c6 Update: 2026-07-21 19:43:50 2026-07-21 19:43:51 +03:00
Hamza-Ayed 1bec13634a Update: 2026-07-21 19:34:29 2026-07-21 19:34:29 +03:00
Hamza-Ayed 0ee3655c05 Update: 2026-07-21 19:31:02 2026-07-21 19:31:02 +03:00
Hamza-Ayed 4f47c0ad1d Update: 2026-07-21 19:28:08 2026-07-21 19:28:08 +03:00
Hamza-Ayed f3905bcb2c Update: 2026-07-21 19:24:57 2026-07-21 19:24:57 +03:00
Hamza-Ayed 1103f6ffcf Update: 2026-07-21 19:22:23 2026-07-21 19:22:23 +03:00
Hamza-Ayed 0351bffafc Update: 2026-07-21 19:19:15 2026-07-21 19:19:15 +03:00
Hamza-Ayed 096f6a13a0 Update: 2026-07-21 19:15:57 2026-07-21 19:15:57 +03:00
Hamza-Ayed ebd6f3734a Update: 2026-07-21 19:09:42 2026-07-21 19:09:42 +03:00
Hamza-Ayed 085b180bdb feat: implement secure OTP-based payout workflow with dynamic fee calculation and improved authentication checks 2026-07-19 01:51:39 +03:00
Hamza-Ayed 5fb2c25504 Update: 2026-07-10 13:41:34 2026-07-10 13:41:34 +03:00
Hamza-Ayed f5a5ffc10c Update: 2026-06-25 03:58:15 2026-06-25 04:00:27 +03:00
Hamza-Ayed 5b5033b110 Update: 2026-06-25 03:56:11 2026-06-25 03:58:30 +03:00
Hamza-Ayed 0671388e15 Update: 2026-06-25 00:05:45 2026-06-25 00:05:45 +03:00
Hamza-Ayed cca16053da Fix OTP verification success response payload and restore deterministic encryptData 2026-06-24 23:24:41 +03:00
Hamza-Ayed 2ee3a14c6d Fix OTP verification success response payload and restore deterministic encryptData 2026-06-24 23:11:24 +03:00
Hamza-Ayed 7b0283473e Fix timezone bug in request.php using MySQL DATE_ADD and clean up EncryptionHelper 2026-06-24 23:03:45 +03:00
Hamza-Ayed 12dfb25629 Update: 2026-06-24 22:56:39 2026-06-24 22:56:39 +03:00
Hamza-Ayed f75e456aac Update: 2026-06-24 16:27:39 2026-06-24 16:27:41 +03:00
Hamza-Ayed 2e4bf784ec Update: 2026-06-24 16:18:03 2026-06-24 16:18:03 +03:00
Hamza-Ayed dfeea2d95a Update: 2026-06-24 16:15:00 2026-06-24 16:15:01 +03:00
Hamza-Ayed 4894d566a0 Update: 2026-06-24 16:04:53 2026-06-24 16:04:53 +03:00
Hamza-Ayed 3b2c2a86c6 Update: 2026-06-23 18:44:45 2026-06-23 18:44:45 +03:00
Hamza-Ayed ed6e34cc4b Update: 2026-06-23 18:36:09 2026-06-23 18:36:09 +03:00
Hamza-Ayed bb13eb74e8 Update: 2026-06-23 18:32:23 2026-06-23 18:32:23 +03:00
Hamza-Ayed 4043d939f2 Update: 2026-06-23 18:21:54 2026-06-23 18:21:54 +03:00
Hamza-Ayed f25066140f Update: 2026-06-23 18:19:33 2026-06-23 18:19:33 +03:00
Hamza-Ayed c859b8006b Update: 2026-06-23 18:18:30 2026-06-23 18:18:30 +03:00
Hamza-Ayed 342611a158 Update: 2026-06-23 18:12:45 2026-06-23 18:12:45 +03:00
Hamza-Ayed b110e03039 Update: 2026-06-23 17:58:46 2026-06-23 17:58:46 +03:00
Hamza-Ayed 52c4f96976 Update: 2026-06-23 17:42:09 2026-06-23 17:42:09 +03:00
Hamza-Ayed 148ca3af1d Update: 2026-06-23 17:25:29 2026-06-23 17:25:29 +03:00
Hamza-Ayed 1a9619f9f8 fix(security): fix login AND logic to OR, add signup input validation, separate OTP rate limit keys 2026-06-17 07:05:58 +03:00
Hamza-Ayed 3dad979eb5 fix(security): remove JWT role extraction without signature, add OTP replay protection, fix user enumeration 2026-06-17 06:45:53 +03:00
Hamza-Ayed f907212c57 Update: 2026-06-12 20:40:40 2026-06-12 20:40:40 +03:00