Signiere Bestätigung und Ausgaben über den Pfad, damit der Port die Links nicht ungültig macht.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2113378e81
commit
63f2be565f
8 files changed
+69
-10
No files matched your search
@@ -9,9 +9,9 @@
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
@@ -56,7 +56,7 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
'allowed' => $decision->allowed,
|
||||
'reason' => $decision->reason,
|
||||
'url' => $decision->allowed
|
||||
? URL::temporarySignedRoute('member.media', now()->addMinutes(10), [
|
||||
? SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class SignedLink
|
||||
{
|
||||
/**
|
||||
* Die Signatur gilt für den Pfad. Die Adresse davor darf der Port oder ein
|
||||
* Platzhalter sein, ohne dass der Link ungültig wird.
|
||||
*
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
public static function temporary(string $name, DateTimeInterface $expiration, array $parameters): string
|
||||
{
|
||||
return url(URL::temporarySignedRoute($name, $expiration, $parameters, false));
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Domain\Identity\StaffRoleAssignment;
|
||||
use App\Notifications\VerifyEmailAddress;
|
||||
use Database\Factories\UserFactory;
|
||||
use Filament\Auth\MultiFactor\App\Concerns\InteractsWithAppAuthentication;
|
||||
use Filament\Auth\MultiFactor\App\Concerns\InteractsWithAppAuthenticationRecovery;
|
||||
@@ -42,6 +43,11 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function sendEmailVerificationNotification(): void
|
||||
{
|
||||
$this->notify(new VerifyEmailAddress);
|
||||
}
|
||||
|
||||
public function party(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Party::class);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class VerifyEmailAddress extends VerifyEmail
|
||||
{
|
||||
protected function verificationUrl($notifiable): string
|
||||
{
|
||||
return SignedLink::temporary(
|
||||
'verification.verify',
|
||||
Carbon::now()->addMinutes((int) Config::get('auth.verification.expire', 60)),
|
||||
[
|
||||
'id' => $notifiable->getKey(),
|
||||
'hash' => sha1($notifiable->getEmailForVerification()),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,11 @@ server {
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
|
||||
set $forwarded_proto $http_x_forwarded_proto;
|
||||
if ($forwarded_proto = "") {
|
||||
set $forwarded_proto $scheme;
|
||||
}
|
||||
fastcgi_param HTTP_X_FORWARDED_PROTO $forwarded_proto;
|
||||
fastcgi_param HTTP_X_FORWARDED_HOST $http_x_forwarded_host;
|
||||
fastcgi_param HTTP_X_FORWARDED_PORT $http_x_forwarded_port;
|
||||
fastcgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/email/bestaetigen', [EmailVerificationController::class, 'notice'])->name('verification.notice');
|
||||
Route::get('/email/bestaetigen/{id}/{hash}', [EmailVerificationController::class, 'verify'])
|
||||
->middleware('signed')
|
||||
->middleware('signed:relative')
|
||||
->name('verification.verify');
|
||||
Route::post('/email/erneut', [EmailVerificationController::class, 'send'])
|
||||
->middleware('throttle:6,1')
|
||||
@@ -44,7 +44,7 @@
|
||||
Route::get('/bibliothek', [LibraryController::class, 'index'])->name('library');
|
||||
Route::get('/bibliothek/{article}', [LibraryController::class, 'show'])->name('article');
|
||||
Route::get('/ausgabe/{article}/{release}/{version}/{action}', [LibraryController::class, 'media'])
|
||||
->middleware('signed')
|
||||
->middleware('signed:relative')
|
||||
->name('media');
|
||||
Route::get('/materialien', [LibraryController::class, 'materials'])->name('materials');
|
||||
Route::get('/berechtigungen', [LibraryController::class, 'grants'])->name('grants');
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Http\SignedLink;
|
||||
use App\Mail\OrderConfirmed;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\DemoCatalogSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MembershipAccessTest extends TestCase
|
||||
@@ -103,7 +103,7 @@ public function test_a_member_can_read_an_entitled_text_and_a_stranger_cannot():
|
||||
$version = $release->contents->first()->elementVersion;
|
||||
|
||||
$this->actingAs($member)->get(route('member.article', $article))->assertOk()->assertSee($article->code);
|
||||
$url = URL::temporarySignedRoute('member.media', now()->addMinutes(5), [
|
||||
$url = SignedLink::temporary('member.media', now()->addMinutes(5), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Notifications\VerifyEmailAddress;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\TestCase;
|
||||
@@ -47,7 +47,7 @@ public function test_registration_creates_a_person_and_sends_verification(): voi
|
||||
$this->assertSame('person', $user->party->type->value);
|
||||
$this->assertSame('private', $user->party->profile->visibility['display_name']);
|
||||
$this->assertAuthenticatedAs($user);
|
||||
Notification::assertSentTo($user, VerifyEmail::class);
|
||||
Notification::assertSentTo($user, VerifyEmailAddress::class);
|
||||
}
|
||||
|
||||
public function test_placeholder_app_url_uses_the_address_opened_in_the_browser(): void
|
||||
@@ -66,8 +66,14 @@ public function test_placeholder_app_url_uses_the_address_opened_in_the_browser(
|
||||
$response->assertRedirect(url('/email/bestaetigen'));
|
||||
|
||||
$user = User::query()->where('email', 'probe@example.test')->firstOrFail();
|
||||
Notification::assertSentTo($user, VerifyEmail::class, function (VerifyEmail $notification) use ($user): bool {
|
||||
Notification::assertSentTo($user, VerifyEmailAddress::class, function (VerifyEmailAddress $notification) use ($user): bool {
|
||||
$link = $notification->toMail($user)->actionUrl;
|
||||
$path = parse_url($link, PHP_URL_PATH);
|
||||
$query = parse_url($link, PHP_URL_QUERY);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get($path.'?'.$query)
|
||||
->assertRedirect(route('member.dashboard'));
|
||||
|
||||
return str_starts_with($link, url('/email/bestaetigen/'))
|
||||
&& ! str_contains($link, 'CHANGE-ME.example');
|
||||
|
||||
Reference in new issue
Block a user