{"action":"closed","issue":{"url":"https://api.github.com/repos/zfcampus/zf-mvc-auth/issues/82","labels_url":"https://api.github.com/repos/zfcampus/zf-mvc-auth/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/zfcampus/zf-mvc-auth/issues/82/comments","events_url":"https://api.github.com/repos/zfcampus/zf-mvc-auth/issues/82/events","html_url":"https://github.com/zfcampus/zf-mvc-auth/issues/82","id":93183348,"number":82,"title":"[proposal] Modularize OAuth2 Adapters","user":{"login":"TomHAnderson","id":493920,"avatar_url":"https://avatars.githubusercontent.com/u/493920?v=3","gravatar_id":"","url":"https://api.github.com/users/TomHAnderson","html_url":"https://github.com/TomHAnderson","followers_url":"https://api.github.com/users/TomHAnderson/followers","following_url":"https://api.github.com/users/TomHAnderson/following{/other_user}","gists_url":"https://api.github.com/users/TomHAnderson/gists{/gist_id}","starred_url":"https://api.github.com/users/TomHAnderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomHAnderson/subscriptions","organizations_url":"https://api.github.com/users/TomHAnderson/orgs","repos_url":"https://api.github.com/users/TomHAnderson/repos","events_url":"https://api.github.com/users/TomHAnderson/events{/privacy}","received_events_url":"https://api.github.com/users/TomHAnderson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/zfcampus/zf-mvc-auth/labels/awaiting%20maintaner%20response","name":"awaiting maintaner response","color":"eb6420"},{"url":"https://api.github.com/repos/zfcampus/zf-mvc-auth/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-06T04:17:21Z","updated_at":"2015-11-19T05:11:52Z","closed_at":"2015-11-19T05:11:52Z","body":"zf-mvc-auth and zf-oauth2 each have specific code for specific adapters for OAuth2 and they do not allow code which is not for those adapters to hook in properly to support multiple OAuth2 connections of the same adapter.  A symptom is config::zf-oauth2 configuring in a global space.\r\n\r\nI propose zf-oauth2 be reduced to a controller and user id provider and all adapter code be moved into individual adapters named zf-oauth2-[adapter].  These adapter repos will support the combined logic of zf-mvc-auth and zf-oauth2 adapters and factories.  zf-oauth2 will no longer have local configuration.\r\n\r\nConfiguration of zf-oauth2-[adapter]s will be handled through zf-mvc-auth like this:\r\n```\r\n    'zf-mvc-auth' => array(\r\n        'authentication' => array(\r\n            'adapters' => array(\r\n                'named_adapter' => array(\r\n                    'adapter' => 'ZF\\\\MvcAuth\\\\Authentication\\\\OAuth2Adapter',\r\n                    'storage' => array(\r\n                        'adapter' => 'ZF\\OAuth2\\Pdo\\Adapter',\r\n                        'dsn' => 'mysql:dbname=database;host=localhost',\r\n                        'route' => '/oauth',\r\n                        'username' => 'db',\r\n                        'password' => '',\r\n                    ),\r\n                ),\r\n            ),\r\n        ),\r\n    ),\r\n```\r\n\r\nThis would be handled in `src/Factory/OAuth2ServerFactory.php` at `createStorageFromAdapter`\r\n```\r\nprivate static function createStorageFromAdapter($adapter, array $config, ServiceLocatorInterface $services)\r\n{\r\n    $callback = $services->get($adapter);\r\n    return $callback($config, $services);\r\n}\r\n```\r\n\r\nThis pattern is central to allowing multiple adapters.  Without this pattern, such as using services, separate factories must be configured for each connection.  Using this pattern the factory can use the zf-mvc-auth configuration to configure each adapter."}}