ฉันตั้งค่าการตรวจสอบสิทธิ์ขั้นพื้นฐานตามที่ระบุไว้ใน เอกสาร Apigility (เอกสารไม่ใช่ ให้ทันสมัยอีกต่อไป แต่ขั้นตอนหลักยังคงเหมือนเดิม) ดังนั้นฉันจึงสร้างไฟล์ users.htpasswd
และเพิ่มอะแดปเตอร์การตรวจสอบความถูกต้อง /config/autoload/local.php
ของฉันได้รับการอัปเดตและได้รับการกำหนดค่าอะแดปเตอร์แล้ว:
return array(
...
'zf-mvc-auth' => array(
'authentication' => array(
'adapters' => array(
'dummy basic auth' => array(
'adapter' => 'ZF\\MvcAuth\\Authentication\\HttpAdapter',
'options' => array(
'accept_schemes' => array(
0 => 'basic',
),
'realm' => 'Dummy Realm',
'htpasswd' => 'data/users.htpasswd',
),
),
),
),
),
);
จนถึงตอนนี้ดีมาก:
Test: I sent a `GET` request got the data just like before the auth setup.
Expected: `200 OK`
Result: `200 OK`
OK
จากนั้น ฉันไปที่ Apigility Admin Backend -> My API -> My Rest Service -> Authorization
และทำเครื่องหมายวิธีการและจุดสิ้นสุด ฉันต้องการขออนุมัติ
Test: I sent a new request without credentials / authentication token.
Expected: `403 Forbidden`
Result: `403 Forbidden`
OK
Test: I sent another request with wrong credentials / authentication token.
Expected: `401 Unauthorized`
Result: `403 Forbidden`
FAIL
Test: I sent a request with correct credentials / authentication token.
Expected: `200 OK`
Result: `403 Forbidden`
FAIL
ผมทำอะไรผิดหรือเปล่า? จะทำให้การตรวจสอบสิทธิ์ HTTP พื้นฐานทำงานได้อย่างไร