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

daycry / auth / 25545552027

08 May 2026 08:28AM UTC coverage: 59.045% (+0.4%) from 58.608%
25545552027

push

github

daycry
Add Laravel-parity auth features: Gates, Password Confirmation, Basic auth

Three independent additions that close the gaps identified when
comparing daycry/auth against Laravel Fortify + Sanctum + core. All
three are aditive — no existing API changes, no migrations needed.

F1. Gates & Policies (src/Authorization/)
- New `Gate` service (registered as `service('gate')`) with closure-
  and class-based authorization rules.
  - `define('post.update', fn($user, $post) => …)` for inline rules.
  - `policy(Post::class, PostPolicy::class)` for class-based policies.
  - `allows() / denies() / authorize() / forUser() / has()`.
  - Auto-discovery: `App\Models\Post` → `App\Policies\PostPolicy`,
    namespace configurable via `Auth::$policyNamespace` (default
    `App\Policies\`); toggle via `Auth::$gateAutoDiscover`.
  - Ability names like `post.update` resolve to method `update()` on
    the policy; bare names work too.
- Abstract `Policy` base with optional `before()` hook for global
  short-circuits (e.g. admins bypass everything on a resource).
- `PolicyResponse::allow($msg)` / `::deny($msg)` to carry deny-reason
  text; `->authorize()` throws `AuthorizationException` on deny.
- Brand-new `Daycry\Auth\Authorization\AuthorizationException`
  (distinct from the pre-existing `Exceptions\AuthorizationException`
  used by RBAC errors); carries the PolicyResponse.
- New `gate:ability,…` filter alias for ability-only route guards.
  Use the Gate API directly inside controllers when the check needs a
  resource argument.
- `Authorizable` trait gains `canDo()` / `cantDo()` — sister methods
  to the existing `can()` / `cant()`. The originals still take
  permission strings only ("posts.update"), the new ones route
  through the Gate and accept resource arguments. Signature of
  `can()` is unchanged.

F2. Password Confirmation workflow ("sudo mode")
- New `password-confirm` filter alias backed by `PasswordConfirmFilter`.
  Reads `password_confirmed_at` from the sessio... (continued)

128 of 182 new or added lines in 10 files covered. (70.33%)

3672 of 6219 relevant lines covered (59.04%)

48.17 hits per line

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

50.0
/src/Authorization/AuthorizationException.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\Authorization;
15

16
use CodeIgniter\Exceptions\RuntimeException;
17

18
/**
19
 * Thrown by {@see Gate::authorize()} when an authorization check fails.
20
 *
21
 * Carries an optional explanation message (from a {@see PolicyResponse})
22
 * so callers can decide whether to surface it to the user.
23
 */
24
class AuthorizationException extends RuntimeException
25
{
26
    public function __construct(
3✔
27
        string $message = 'This action is unauthorized.',
28
        private readonly ?PolicyResponse $response = null,
29
    ) {
30
        parent::__construct($message);
3✔
31
    }
32

NEW
33
    public function response(): ?PolicyResponse
×
34
    {
NEW
35
        return $this->response;
×
36
    }
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc