Skip to content

Using signed routes with InitializeTenancyByRequestData results in invalid signature #1370

Description

@secrethash

Bug description

When creating a signed route (in my case absolute is false) for central domain and using signed:relative & InitializeTenancyByRequestData::class middleware together it returns 403 Invalid signature error.

Steps to reproduce

  • Create a signed route URL
    use Illuminate\Support\Uri;
    
    ...
    
    $portal = Uri::temporarySignedRoute(
      'test.home',
      now()->addSeconds(30),
      absolute: false
    )->withQuery([
      'tenant' => $tenant->id,
      'access_token' => Auth::getTokenForRequest(),
    ])->withHost(config('test.domain'))
      ->withScheme(config('app.force_secure') ? 'https' : 'http');
  • Make sure the central domain is present in config/tenancy.php
  • Add middleware to route, here test.home
    Route::prefix('portal')
      ->name('test.')
      ->middleware([
        'signed:relative',
        InitializeTenancyByRequestData::class,
        'auth:api'
      ])->group(function () {
        Route::get('/', [TestController::class, 'index'])->name('home');
      });

Expected behavior

The signature should be valid

Laravel version

12.19.3

stancl/tenancy version

dev-master:e1fc0e107d236a113ab5e67fc1fa0044925100e4

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions