【发布时间】:2015-05-12 12:31:08
【问题描述】:
我按照Apigility docu 所述设置基本身份验证(文档不再是最新的,但主要步骤保持不变)。因此,我创建了一个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 身份验证正常工作?
【问题讨论】:
标签: php authentication zend-framework2 basic-authentication laminas-api-tools