-
Notifications
You must be signed in to change notification settings - Fork 46
Apigility - Authentication - Per Api authentication adapter - Authorization problem #92
Comments
I'll do a PR in few minutes for the referenced bug. Changes made will be done in the ZF\MvcAuth\Authentication\HttpAdapter. Here I'll simply mimic the OAuth adapter behavior. E.g: When no credential were present at all, we just return a guest identity. Then, this solves the issue. The ZF\Apigility\MvcAuth\UnauthenticatedListener will simply return due to the absence of the authentication result and thus, the authorization process for guest identity will be performed as it should. BTW: To be able to reproduce the issue referenced here, only one Basic auth adapter must be configured. |
Close #94 Fixes #92 Fixes zfcampus/zf-apigility-skeleton#104
I fail to see how it solve the issue. IMHO, you have to know whether the request is for a private or public API in order to either return a 401 or a successful response. How can you differentiate between those two cases before routing (and thus authentication configuration) ? |
My fix was wrong after all... It prevent challenge of client when needed... ...
'zf-mvc-auth' => [
'authentication' =>
'adapters' => [
'http' => [
// HTTP auth adapter configuration
],
'whatever' => [
// Whatever auth adapter configuration
],
],
'map' => [
'API/VERSION1' => 'basic',
'API/VERSION2 => 'whatevertype'
]
]
]
... Now, let imagine the following scenario: A client request the following URI /host.tld/API/VERSION1 (here, the matching authentication type is Then, the following will occurs in the default authentication listener:
At this point, if the mvc http adapter don't find the The problem here, is that the authentication layer don't known if a resource is private or public. That layer only known which authentitcation type is available for a specific API. Thus, current design (assuming that the fix referenced by #92 is reverted) involve challenging client, whatever the resource is private or not. This means here that an API is just either public or private. There is no concept of public and private resources at this level. This is bad because if someone want provide both public and private resources through the same API, it cannot because client (even for public resources) will be challenged. That was the point of my #92 fix that is wrong because it delegate challenge phase to the authorization layer, which is only able to send 403 status code. This is normal because the authorization layer must not be concerned about authentication. A way to resolve that problem would be to allow the developer to mark specific resource as public (no authentication required). Now here, we have to think how. |
Don't know if this is more related to this module so ;)
See zfcampus/zf-apigility-skeleton#104:
The text was updated successfully, but these errors were encountered: