• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / auth / 25552752016

08 May 2026 11:20AM UTC coverage: 71.592% (+13.0%) from 58.608%
25552752016

push

github

web-flow
Merge pull request #48 from daycry/development

Add Laravel-parity authentication features: Gates, Password Confirmation, Basic Auth

198 of 252 new or added lines in 18 files covered. (78.57%)

1 existing line in 1 file now uncovered.

4453 of 6220 relevant lines covered (71.59%)

62.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/src/Filters/GateFilter.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Auth.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Auth\Filters;
15

16
use CodeIgniter\HTTP\RedirectResponse;
17
use CodeIgniter\HTTP\RequestInterface;
18
use CodeIgniter\HTTP\ResponseInterface;
19
use Daycry\Auth\Authorization\Gate;
20

21
/**
22
 * Authorization filter for closure-based abilities and class-based
23
 * policies registered with {@see Gate}.
24
 *
25
 * Apply on routes that map cleanly to a single ability **without** a
26
 * resource argument — for example, abilities that depend solely on the
27
 * authenticated user's groups / claims (`gate:dashboard.view`,
28
 * `gate:billing.access`).
29
 *
30
 * For abilities that need a resource instance (a Post, an Order, etc.)
31
 * use the Gate API directly inside the controller method:
32
 *
33
 *     Gate::authorize('post.update', $post);
34
 *
35
 * Filter usage:
36
 *
37
 *     $routes->get('admin', 'Admin::index', ['filter' => 'gate:admin.access']);
38
 */
39
class GateFilter extends AbstractAuthFilter
40
{
41
    protected function isAuthorized(array $arguments): bool
3✔
42
    {
43
        if ($arguments === []) {
3✔
NEW
44
            return false;
×
45
        }
46

47
        /** @var Gate $gate */
48
        $gate = service('gate');
3✔
49

50
        foreach ($arguments as $ability) {
3✔
51
            $ability = trim((string) $ability);
3✔
52

53
            if ($ability === '') {
3✔
NEW
54
                continue;
×
55
            }
56

57
            if ($gate->denies($ability)) {
3✔
58
                return false;
2✔
59
            }
60
        }
61

62
        return true;
1✔
63
    }
64

65
    protected function redirectToDeniedUrl(RequestInterface $request): RedirectResponse|ResponseInterface
2✔
66
    {
67
        return $this->buildDeniedResponse($request, config('Auth')->permissionDeniedRedirect());
2✔
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc