{"action":"created","issue":{"url":"https://api.github.com/repos/JosephSilber/bouncer/issues/56","repository_url":"https://api.github.com/repos/JosephSilber/bouncer","labels_url":"https://api.github.com/repos/JosephSilber/bouncer/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/JosephSilber/bouncer/issues/56/comments","events_url":"https://api.github.com/repos/JosephSilber/bouncer/issues/56/events","html_url":"https://github.com/JosephSilber/bouncer/issues/56","id":135157748,"number":56,"title":"How should wildcards work?","user":{"login":"JosephSilber","id":1403741,"avatar_url":"https://avatars.githubusercontent.com/u/1403741?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephSilber","html_url":"https://github.com/JosephSilber","followers_url":"https://api.github.com/users/JosephSilber/followers","following_url":"https://api.github.com/users/JosephSilber/following{/other_user}","gists_url":"https://api.github.com/users/JosephSilber/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephSilber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephSilber/subscriptions","organizations_url":"https://api.github.com/users/JosephSilber/orgs","repos_url":"https://api.github.com/users/JosephSilber/repos","events_url":"https://api.github.com/users/JosephSilber/events{/privacy}","received_events_url":"https://api.github.com/users/JosephSilber/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JosephSilber/bouncer/labels/discussion","name":"discussion","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-21T04:20:42Z","updated_at":"2016-02-21T06:41:26Z","closed_at":null,"body":"I'm currently working on allowing wildcard abilities. Here's how it works:\r\n\r\n```php\r\nBouncer::allow($user)->to('*');\r\n\r\nBouncer::allows('*'); // true\r\nBouncer::allows('ban-users'); // true\r\n```\r\n\r\nYou can also allow all actions on a model:\r\n\r\n```php\r\nBouncer::allow($user)->to('*', $post);\r\n\r\nBouncer::allows('delete', $post); // true\r\nBouncer::allows('*', $post); // true\r\n\r\nBouncer::allows('ban-users'); // false\r\nBouncer::allows('*'); // false\r\n```\r\n\r\nYou can also allow a specific action on all models:\r\n\r\n```php\r\nBouncer::allow($user)->to('create', '*');\r\n\r\nBouncer::allows('create', User::class); // true\r\nBouncer::allows('create', Post::class); // true\r\n\r\nBouncer::allows('edit', Post::class); // false\r\nBouncer::allows('create'); // false\r\n```\r\n\r\n---\r\n\r\nSo far so good. What I'm not sure about is the following:\r\n\r\n```php\r\nBouncer::allow($user)->to('*');\r\n\r\nBouncer::allows('view-dashboard'); // true\r\n\r\nBouncer::allows('delete', $user); // false\r\n```\r\n\r\nAs you can see, a wildcard ability *does not* allow model abilities. To also allow model abilities you need two wildcards:\r\n\r\n```php\r\nBouncer::allow($user)->to('*', '*');\r\n\r\nBouncer::allows('view-dashboard'); // true\r\nBouncer::allows('delete', $user); // true\r\n```\r\n\r\nAll of this is already implemented. Now onto the question:\r\n\r\nWhich one of these two makes more sense?\r\n\r\n1. A single wildcard only allows simple abilities. Model abilities requires double wildcards.\r\n2. There's no point in ever only allowing a user all simple abilities. Make a single wildcard allow everything.\r\n\r\nOption 1 is the way it works now.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/JosephSilber/bouncer/issues/comments/186760930","html_url":"https://github.com/JosephSilber/bouncer/issues/56#issuecomment-186760930","issue_url":"https://api.github.com/repos/JosephSilber/bouncer/issues/56","id":186760930,"user":{"login":"a-komarev","id":1849174,"avatar_url":"https://avatars.githubusercontent.com/u/1849174?v=3","gravatar_id":"","url":"https://api.github.com/users/a-komarev","html_url":"https://github.com/a-komarev","followers_url":"https://api.github.com/users/a-komarev/followers","following_url":"https://api.github.com/users/a-komarev/following{/other_user}","gists_url":"https://api.github.com/users/a-komarev/gists{/gist_id}","starred_url":"https://api.github.com/users/a-komarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-komarev/subscriptions","organizations_url":"https://api.github.com/users/a-komarev/orgs","repos_url":"https://api.github.com/users/a-komarev/repos","events_url":"https://api.github.com/users/a-komarev/events{/privacy}","received_events_url":"https://api.github.com/users/a-komarev/received_events","type":"User","site_admin":false},"created_at":"2016-02-21T06:41:26Z","updated_at":"2016-02-21T06:41:26Z","body":"1st option is giving more flexibility, but it's wouldn't be so obvious behaviour. Maybe there should be alias methods which should do the trick and will be more verbose?"}}