-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple authentication adapters per API #16
Comments
https://github.com/zfcampus/zf-mvc-auth#sub-key-adapters This part of the README.md for this module shows HTTP and OAuth2. Originally posted by @TomHAnderson at zfcampus/zf-mvc-auth#93 (comment) |
Yes, but
For but, this look like we can map only one named adapter to one API at time. Originally posted by @nuxwin at zfcampus/zf-mvc-auth#93 (comment) |
My understanding is the map can map to an array of adapters. Consider this hear-say but I suggest you try it.
Originally posted by @TomHAnderson at zfcampus/zf-mvc-auth#93 (comment) |
Same idea here. I'm not sure about the list possibility ;) At least, in apigility UI we cannot map multiple adapters atm. The only way is to use the fallback feature with andy adapters. Eg; When no adapter is specified for a given API, attempt is made by the DefaultAuthenticationListener event listener to retrieve the adapter type to use from the request and thus, the first andy adapter which match this type is used (at least, this is what I understand from the code). My personal through was something like The adapter type should be first retrieved from the request in any case, and once done checked against the map (API modules to allowed authentication adapters.). In such case, we should be allowed to do something like 'zf-mvc-auth' => array(
'authentication' => array(
'map' => array(
'Status\\V1' => array(
'named_adapter_1',
'named_adapter_2',
)
),
),
), as you said ;) Originally posted by @nuxwin at zfcampus/zf-mvc-auth#93 (comment) |
For me it look like we cannot specify list of adapters in the map currently. ...
/**
* Match the controller to an authentication type, based on the API to
* which the controller belongs.
*
* @param null|RouteMatch $routeMatch
* @return string|false
*/
private function getTypeFromMap(RouteMatch $routeMatch = null)
{
if (! $routeMatch) {
return false;
}
$controller = $routeMatch->getParam('controller', false);
if (false === $controller) {
return false;
}
foreach ($this->authMap as $api => $type) {
$api = rtrim($api, '\\') . '\\';
if (strlen($api) > strlen($controller)) {
continue;
}
if (0 === strpos($controller, $api)) {
return $type;
}
}
return false;
}
... Originally posted by @nuxwin at zfcampus/zf-mvc-auth#93 (comment) |
Hi, Because we needed this feature for our project, we implemented it (see qapa/zf-mvc-auth@b30d83e) Basically, if an array of types is defined for an API, we try to find the type extracted from request in this array. Originally posted by @ronan-gloo at zfcampus/zf-mvc-auth#93 (comment) |
It could be great to add support for multiple authentication adapter per API at it is possible in Github API.
See https://developer.github.com/v3/auth/
Originally posted by @nuxwin at zfcampus/zf-mvc-auth#93
The text was updated successfully, but these errors were encountered: