From bd49d30b217f102ef29d7ebef7176fb9380b43fb Mon Sep 17 00:00:00 2001 From: douxxtech Date: Thu, 30 Apr 2026 17:47:39 +0200 Subject: [PATCH 1/3] made PARSE_AUTH_HEADER look for "auth" instead of "Auth" --- macros/httputils.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macros/httputils.asm b/macros/httputils.asm index a0ef289..6f047ee 100644 --- a/macros/httputils.asm +++ b/macros/httputils.asm @@ -366,7 +366,7 @@ section .bss xor r8, r8 ; offset %%auth_scan: - ; need at least 22 bytes left: "Authorization: Basic " (21) + 1 byte of token + ; need at least 22 bytes left: "authorization: Basic " (21) + 1 byte of token mov rax, r8 add rax, 22 cmp rax, %2 @@ -375,14 +375,14 @@ section .bss cmp byte [rsi + r8], 'A' jne %%auth_next - ; "Authorization: Basic " split into dwords: - ; [+0] "Auth" = 0x68747541 + ; "authorization: Basic " split into dwords: + ; [+0] "auth" = 0x68747541 ; [+4] "oriz" = 0x7a69726f ; [+8] "atio" = 0x6f697461 ; [+12] "n: B" = 0x42203a6e ; [+16] "asic" = 0x63697361 - ; [+20] " " = 0x20 - cmp dword [rsi + r8 + 0], 0x68747541 + ; [+20] " " = 0x20 + cmp dword [rsi + r8 + 0], 0x68747561 jne %%auth_next cmp dword [rsi + r8 + 4], 0x7a69726f From 6a6aa9026e04ce00d81bd115211836f4a8273048 Mon Sep 17 00:00:00 2001 From: douxxtech Date: Thu, 30 Apr 2026 17:52:12 +0200 Subject: [PATCH 2/3] Re-fixed PARSE_AUTH_HEADER --- macros/httputils.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/httputils.asm b/macros/httputils.asm index 6f047ee..a97aa52 100644 --- a/macros/httputils.asm +++ b/macros/httputils.asm @@ -372,11 +372,11 @@ section .bss cmp rax, %2 jg %%not_found - cmp byte [rsi + r8], 'A' + cmp byte [rsi + r8], 'a' jne %%auth_next ; "authorization: Basic " split into dwords: - ; [+0] "auth" = 0x68747541 + ; [+0] "auth" = 0x68747561 ; [+4] "oriz" = 0x7a69726f ; [+8] "atio" = 0x6f697461 ; [+12] "n: B" = 0x42203a6e From f070478f6bc95cabc4137d8784faef368b7c3210 Mon Sep 17 00:00:00 2001 From: douxxtech Date: Thu, 30 Apr 2026 17:58:38 +0200 Subject: [PATCH 3/3] updated the test program to check for auth --- .github/scripts/test-program.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/scripts/test-program.sh b/.github/scripts/test-program.sh index 2073211..7a275d8 100644 --- a/.github/scripts/test-program.sh +++ b/.github/scripts/test-program.sh @@ -70,6 +70,37 @@ else fail "curl response did not contain expected content (got: $RESPONSE)" fi +# Setup Auth in config +echo "AUTH_USER=admin" >> test-env.cfg +echo "AUTH_PASSWORD=password123" >> test-env.cfg +echo "AUTH_REALM=TestRealm" >> test-env.cfg + +kill "$SERVER_PID" 2>/dev/null +./program -e test-env.cfg > /dev/null 2>&1 & +SERVER_PID=$! +sleep 1 + +# test 5 +echo ">> Testing unauthorized access (expecting 401)..." +HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" localhost:8080) + +if [ "$HTTP_STATUS" -eq 401 ]; then + pass "Correctly returned 401 Unauthorized" +else + fail "Expected 401, but got $HTTP_STATUS" +fi + +# test 6 +echo ">> Testing authorized access (expecting 200)..." +# Using -u for Basic Auth +HTTP_STATUS=$(curl -s -u admin:password123 -o /dev/null -w "%{http_code}" localhost:8080) + +if [ "$HTTP_STATUS" -eq 200 ]; then + pass "Correctly returned 200 OK with valid credentials" +else + fail "Expected 200, but got $HTTP_STATUS" +fi + # summary echo "" echo "================================"