{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/13788","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/13788/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/13788/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/13788/events","html_url":"https://github.com/laravel/framework/issues/13788","id":157622353,"number":13788,"title":"Authorize middleware only works for default guard","user":{"login":"dan-iway","id":19486346,"avatar_url":"https://avatars.githubusercontent.com/u/19486346?v=3","gravatar_id":"","url":"https://api.github.com/users/dan-iway","html_url":"https://github.com/dan-iway","followers_url":"https://api.github.com/users/dan-iway/followers","following_url":"https://api.github.com/users/dan-iway/following{/other_user}","gists_url":"https://api.github.com/users/dan-iway/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-iway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-iway/subscriptions","organizations_url":"https://api.github.com/users/dan-iway/orgs","repos_url":"https://api.github.com/users/dan-iway/repos","events_url":"https://api.github.com/users/dan-iway/events{/privacy}","received_events_url":"https://api.github.com/users/dan-iway/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-05-31T09:00:50Z","updated_at":"2016-07-27T02:53:40Z","closed_at":null,"body":"On Laravel 5.2.32:\r\n```\r\nRoute::group(['middleware' => ['auth:api']], function() {\r\n\tRoute::group(['middleware' => 'can:view-internal'], function() {\r\n\t});\r\n});\r\n```\r\n\r\nAll routes within these groups will never be able to run if the default auth guard does not return a user, no matter the conditions for 'can:view-internal'.\r\n\r\nAuthManager registers a userResolver callback which would accept a guard param but Gate::raw() is not supplying a guard. Probably because it does not know which one to use?\r\n\r\nPossible solutions\r\n- Check all available guards in default userResolver for users, though that probably may be unexpected and result in security problems?\r\n- Specify which guard to use as param in middleware definition\r\n- Another config option to specify which guards to check for users\r\n- At least document that behaviour\r\n\r\nCurrent fix for my case in register() of AuthServiceProvider, simply check both guards I care for:\r\n\r\n```\r\nAuth::resolveUsersUsing(function($guard = null) {\r\n\t\treturn Auth::user() ? Auth::user() : Auth::guard('api')->user();\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/235467561","html_url":"https://github.com/laravel/framework/issues/13788#issuecomment-235467561","issue_url":"https://api.github.com/repos/laravel/framework/issues/13788","id":235467561,"user":{"login":"leandromatos","id":969110,"avatar_url":"https://avatars.githubusercontent.com/u/969110?v=3","gravatar_id":"","url":"https://api.github.com/users/leandromatos","html_url":"https://github.com/leandromatos","followers_url":"https://api.github.com/users/leandromatos/followers","following_url":"https://api.github.com/users/leandromatos/following{/other_user}","gists_url":"https://api.github.com/users/leandromatos/gists{/gist_id}","starred_url":"https://api.github.com/users/leandromatos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leandromatos/subscriptions","organizations_url":"https://api.github.com/users/leandromatos/orgs","repos_url":"https://api.github.com/users/leandromatos/repos","events_url":"https://api.github.com/users/leandromatos/events{/privacy}","received_events_url":"https://api.github.com/users/leandromatos/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T02:53:40Z","updated_at":"2016-07-27T02:53:40Z","body":"The same is happening to me. I can login with two different guards, but when trying to get the user through `Auth::user ()`, only the default guard works."}}
{"actor":{"display_login":"leandromatos"}}