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

daycry / auth / 22520725744

27 Feb 2026 09:30PM UTC coverage: 65.761% (-1.1%) from 66.864%
22520725744

push

github

daycry
Add StatelessAuthenticator and refactor token handling

Introduce StatelessAuthenticator as a shared base for JWT/AccessToken and centralize token extraction (getTokenFromRequest). Refactor JWT and AccessToken to extend it and simplify header/query parsing. Add Utils::generateNumericCode and use it in Email2FA/EmailActivator to replace duplicated generators. Centralize model() calls in traits (HasAccessTokens, HasDeviceSessions, HasTotp) via small private getters. Improve filters and error handling: add buildDeniedResponse in AbstractAuthFilter, adjust Group/Permission filters to return ResponseInterface and reuse the builder. Replace static authorization flags with instance properties in AuthenticationException/AuthorizationException and update ExceptionHandler to read them safely. Misc: small controller/type fixes, email helper guard, DeviceSessionModel null handling, active-group/permission query fixes, phpstan baseline updates, and adjust tests to expect 403 for denied JSON responses.

56 of 68 new or added lines in 19 files covered. (82.35%)

115 existing lines in 7 files now uncovered.

2614 of 3975 relevant lines covered (65.76%)

42.9 hits per line

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

0.0
/src/Entities/Cast/SerializeCast.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\Entities\Cast;
15

16
use CodeIgniter\Entity\Cast\BaseCast;
17

18
/**
19
 * Serialize Cast
20
 *
21
 * Stores values as JSON. Provides backward-compatible reading of
22
 * legacy PHP-serialized data (read-only fallback, never writes serialized).
23
 */
24
final class SerializeCast extends BaseCast
25
{
26
    /**
27
     * @param string $value
28
     */
29
    public static function get($value, array $params = []): ?array
30
    {
UNCOV
31
        if (! $value) {
×
32
            return null;
×
33
        }
34

35
        // Primary: try JSON (new format)
UNCOV
36
        $decoded = json_decode($value, true);
×
37

UNCOV
38
        if (json_last_error() === JSON_ERROR_NONE) {
×
UNCOV
39
            return $decoded;
×
40
        }
41

42
        // Fallback: legacy PHP-serialized data — allowed_classes=false prevents object injection
UNCOV
43
        $unserialized = unserialize($value, ['allowed_classes' => false]);
×
44

UNCOV
45
        return is_array($unserialized) ? $unserialized : null;
×
46
    }
47

48
    /**
49
     * @param bool|int|list<mixed>|string $value
50
     */
51
    public static function set($value, array $params = []): ?string
52
    {
UNCOV
53
        if (! $value) {
×
UNCOV
54
            return null;
×
55
        }
56

UNCOV
57
        return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
×
58
    }
59
}
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