1 Commits
Author SHA1 Message Date
Romulus21 116129a098 fix tests 2026-05-27 14:12:47 +02:00
4 changed files with 32 additions and 26 deletions
+12 -12
View File
@@ -9,26 +9,26 @@ class DelegateAuthServiceProvider extends ServiceProvider
public function register(): void
{
$this->mergeConfigFrom(
__DIR__.'/../config/delegate-auth.php', 'delegate-auth'
__DIR__ . "/../config/delegate-auth.php",
"delegate-auth",
);
}
public function boot(): void
{
$this->publishes([
__DIR__.'/../config/delegate-auth.php' => config_path('delegate-auth.php'),
], 'delegate-auth-config');
$this->publishes(
[
__DIR__ . "/../config/delegate-auth.php" => config_path(
"delegate-auth.php",
),
],
"delegate-auth-config",
);
$this->publishes([
__DIR__.'/../resources/views/errors/401.blade.php' => resource_path('views/errors/401.blade.php'),
], 'delegate-auth-views');
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
$this->loadRoutesFrom(__DIR__ . "/../routes/web.php");
if ($this->app->runningInConsole()) {
$this->commands([
Console\InstallCommand::class,
]);
$this->commands([Console\InstallCommand::class]);
}
}
}
+16 -10
View File
@@ -49,16 +49,22 @@ class DelegateAuthController extends Controller
private function decryptToken(string $token): ?array
{
$data = base64_decode(urldecode($token));
$payload = openssl_decrypt(
substr($data, 16),
"AES-256-CBC",
config("delegate.encrypt_key"),
0,
substr($data, 0, 16),
);
$data = json_decode($payload, associative: true);
$data = base64_decode($token, strict: true);
return is_array($data) ? $data : null;
if ($data === false || strlen($data) <= 16) {
return null;
}
$key = substr(hash('sha256', config('delegate-auth.encrypt_key'), binary: true), 0, 32);
$payload = openssl_decrypt(substr($data, 16), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, substr($data, 0, 16));
if ($payload === false) {
return null;
}
$decoded = json_decode($payload, associative: true);
return is_array($decoded) ? $decoded : null;
}
}
+2 -2
View File
@@ -37,8 +37,8 @@ class LoginTest extends TestCase
{
$wrongKey = substr(hash('sha256', 'wrong-key', binary: true), 0, 32);
$iv = random_bytes(16);
$encrypted = openssl_encrypt(json_encode(['email' => 'user@example.com']), 'AES-256-CBC', $wrongKey, 0, $iv);
$token = base64_encode($iv).'.'.$encrypted;
$encrypted = openssl_encrypt(json_encode(['email' => 'user@example.com']), 'AES-256-CBC', $wrongKey, OPENSSL_RAW_DATA, $iv);
$token = base64_encode($iv.$encrypted);
User::create(['email' => 'user@example.com']);
+2 -2
View File
@@ -39,8 +39,8 @@ abstract class TestCase extends OrchestraTestCase
{
$key = substr(hash('sha256', config('delegate-auth.encrypt_key'), binary: true), 0, 32);
$iv = random_bytes(16);
$encrypted = openssl_encrypt(json_encode($payload), 'AES-256-CBC', $key, 0, $iv);
$encrypted = openssl_encrypt(json_encode($payload), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
return base64_encode($iv).'.'.$encrypted;
return base64_encode($iv.$encrypted);
}
}