Course outline

Laravel / Basic: request and data foundations / Lesson 7

Signed URLs and expiring links

Create and verify signed links while distinguishing URL integrity from identity, authorization and one-time use.

About 25 min read20 worked examples20 practice exercisesContent reviewed
On this page

Lesson goals

  • Explain what a signed URL protects and what it does not.
  • Generate an expiring link and validate it at the receiving route.
  • Design tests for tampering, expiry and access policy.
  • Generate and validate temporary signed links while separating integrity, identity, and authorization.
  • Test tampering, expiry, proxy reconstruction, and one-use state with synthetic data.

Identify the promise

A signed URL lets an application detect whether the protected URL was changed after it was generated. An expiring signed URL also carries a time boundary checked when validation occurs. Neither property proves who currently holds the link, hides the URL, nor automatically makes a link single use. A person who receives a valid bearer link may be able to share it. Decide whether the action is suitable for that exposure before choosing this mechanism.

Generate a bounded link

A named route gives generation and validation a shared destination. The following fragment assumes an existing named route and a configured application key; it is illustrative and does not boot an application. Use a synthetic identifier in a local fixture, set a short lifetime appropriate to the operation, and deliver the URL through a channel suitable for its sensitivity. Changing the key can invalidate links signed with the earlier key, so consider outstanding links during rotation.

php Create an expiring URL for an existing named route
use Illuminate\Support\Facades\URL;

$url = URL::temporarySignedRoute(
    'reports.show', now()->addMinutes(30), ['report' => 42]
);

The application must define reports.show and configure its signing key. The example only constructs a URL; delivery and authorization remain application responsibilities.

Check the signature at the destination

Protect the receiving route with the documented signed middleware or perform the documented signature check in the handler. The fragment shows the middleware approach for an existing controller. An invalid or expired link must not perform the operation. Keep any authentication and object authorization required by the application: signature validation checks the URL’s integrity and expiry, not the recipient’s permission to mutate a particular record.

php Validate a signed URL on an existing route
use App\Http\Controllers\ReportController;
use Illuminate\Support\Facades\Route;

Route::get('/reports/{report}', [ReportController::class, 'show'])
    ->name('reports.show')->middleware('signed');

The signed middleware rejects invalid signatures or expiration. The controller must still enforce any required identity and object policy.

Separate a link from an effect

A GET request may be followed by email scanners, browser previews or crawlers. For a destructive or consequential action, use the link to show a confirmation page and require an appropriately protected state-changing request for the effect. If the business rule requires one use, record consumption atomically on the server and define the response to concurrent attempts. Expiration alone does not prevent repeated use before the deadline.

Test the whole contract

In an isolated application, create a link for a synthetic record and verify the intended successful response. Change a signed parameter and check rejection and unchanged durable state. Exercise expiration using a controlled test clock, then test a valid link held by an unauthorized user if identity is required. Test the actual externally visible host and scheme behind a proxy: mismatches can affect signature verification, so configure trusted proxy behavior deliberately rather than disabling validation.

Define what the URL signature actually protects

A signed URL is a URL whose application-generated signature lets Laravel detect changes to the signed URL components. A temporary signed route also carries an expiration time, which the validation mechanism checks. The promise is integrity and, when present, a time limit. It is not encryption: a recipient can read the path and query, copy the URL, and potentially share it. A valid link is a bearer capability unless the application adds identity and object authorization. Put only the minimum nonsecret identifiers in the URL and decide whether the operation is appropriate for a transferable link.

Generation and validation form one contract. The generator needs a configured application key, a named route, its required parameters, and the intended lifetime. The destination needs the documented signed middleware or explicit signature validation. A successful generation test alone does not establish that the destination checks the signature. An isolated fixture should use synthetic records and a disposable application key; never copy a real signature or secret into a test or log. The Laravel 12 snippets in this lesson are illustrative fragments requiring the configured route, application, and dependencies, and have not been executed here.

Reason about changes and time at the receiving boundary

After issuing a temporary link, compare an unchanged request with a request where a signed report identifier or query value has been altered. The latter must fail signature validation rather than loading a different resource. Adding an unsigned tracking parameter can also affect validation unless the application has deliberately configured a documented exception; ignoring parameters makes them mutable and they must not control authorization, identity, price, or other security decisions. Do not assume URL encoding, a proxy rewrite, or a copied query string preserves the exact request Laravel validates without a test.

Use a controlled clock to test before and after the expiration boundary. A valid, unexpired link can be used repeatedly during its lifetime unless a separate state rule prevents it. An expired link must not reach a protected effect, and tests should check both the response and unchanged durable data. Keep application clocks synchronized in deployment and define acceptable operational behavior around clock differences. Do not infer a guaranteed wall-clock outcome from a test that merely sleeps or from a timestamp displayed to the user; specify the time used by the signer and the validator.

Layer identity, scope, and authorization over integrity

A signature says the URL has not been altered according to the configured verification rule; it does not identify the person presenting it. For a report that belongs to one customer, require the intended authentication where the workflow calls for it and authorize the actual bound report against that actor. Test the same valid link with the intended synthetic user and a second user. Also test a missing or unrelated resource according to the application's disclosure policy. The signature must never replace tenant scoping or policy checks merely because the identifier is difficult to guess.

Some workflows intentionally allow anyone holding a link to view a limited resource. That is a product decision with consequences for forwarding, browser history, logs, referrer headers, and access to the destination. Minimize the exposed representation and lifetime, avoid placing passwords or personal details in the URL, and provide a revocation mechanism if the product requires one. A short expiration reduces the exposure window but does not prove that the correct person received the link. Use a separate delivery channel and account controls appropriate to the sensitivity of the resource.

Separate safe link inspection from a durable action

Mail scanners and previews can fetch a GET link automatically. If a link triggers a consequential update on GET, the scanner may perform the action before the intended person sees it. Use the signed GET to display a confirmation page, and require a protected state-changing request for the action. Keep the signature and any required session, CSRF, and authorization checks connected to the confirmation flow. Test an automatic fetch and assert that durable state is unchanged, then test an explicit confirmed request and its intended effect.

Single use requires server-side state, not merely a deadline. Store a synthetic link or operation identifier with a consumption marker and atomically transition it when the action succeeds. Design the transaction so competing attempts cannot both succeed and decide what happens if the operation fails before commit. A database conditional update or lock can be part of a solution, but its correctness depends on the target database, transaction boundary, and failure model. Test consecutive and concurrent requests on disposable data; an expiry timestamp alone does not record that a link was consumed.

Verify the externally visible request without exposing secrets

Absolute URL signatures can depend on the host and scheme Laravel sees. Behind a reverse proxy, compare the external URL generated for the synthetic link with the scheme, host, path, and query received by the application after trusted-proxy configuration. Configure only the proxies and headers appropriate to the deployment. A mismatch is a reason to inspect request reconstruction and signing mode, not to remove signature validation. If using the documented relative signing and validation mode, configure both ends consistently and understand that the host is then outside the signed relative URL.

Build an isolated test matrix for an unchanged valid link, a changed parameter, an expired link, a second actor, and repeat or concurrent use when required. Assert the response, selected record, and durable state separately. Record useful diagnostics such as route name, failure category, and sanitized host configuration without logging the full bearer URL, signature, or application key. A feature test establishes only the application's configured HTTP pipeline; it does not prove that an external mail provider delivers the link or that production proxy headers are trusted correctly. Verify those separate boundaries with appropriate controlled evidence.

20 worked examples

1. Temporary report link

Problem: Generate a short-lived signed URL for a synthetic report and named route.

  1. The generator uses the named route and substitutes synthetic report identifier 42.
  2. It includes an expiration and signature using the configured application key.
php Laravel 12 fragment or synthetic signed-link trace
$url = URL::temporarySignedRoute(
    'reports.show', now()->addMinutes(20), ['report' => 42]
);
// Fixture: reports.show is registered and an application key is configured.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: A temporary signed URL for report 42 is generated with a 20-minute deadline.

Why this result follows: The helper combines the route parameters and expiration with a signature; it does not send the URL.

2. Middleware validation

Problem: Protect a report route with the documented signature middleware.

  1. The route matches the report parameter and signed middleware checks the submitted URL.
  2. An unchanged unexpired URL can pass the signature boundary; any controller policy remains separate.
php Laravel 12 fragment or synthetic signed-link trace
Route::get('/reports/{report}', [ReportController::class, 'show'])
    ->name('reports.show')->middleware('signed');
// Request: unchanged unexpired signed URL; report 42 exists.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The request can proceed to the controller after signature validation.

Why this result follows: The middleware validates the signature and expiry before the protected route action is reached.

3. Changed resource identifier

Problem: Reject a link whose report identifier was changed after signing.

  1. The received path is not the same protected URL that was signed for report 42.
  2. The old signature cannot validate the altered path, so report 43 must not be displayed through this request.
php Laravel 12 fragment or synthetic signed-link trace
// Issued: signed URL for /reports/42
// Received: same signed query, path changed to /reports/43
Route::get('/reports/{report}', ReportController::class)->middleware('signed');

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: Signature validation rejects the tampered request.

Why this result follows: The signature detects changes to the protected URL components under the configured validation mode.

4. Expired link

Problem: Reject a temporary URL after its deadline using a controlled test clock.

  1. The link expires 20 minutes after the test clock at issuance.
  2. The request occurs after 21 minutes, so the documented expiry check rejects it.
php Laravel 12 fragment or synthetic signed-link trace
$url = URL::temporarySignedRoute('reports.show', now()->addMinutes(20), ['report' => 42]);
$this->travel(21)->minutes();
$this->get($url)->assertForbidden();
// Fixture: signed middleware enabled and test clock isolated.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The test expects 403 and no report action.

Why this result follows: Controlled time makes the expiration condition observable without waiting in real time.

5. Valid before expiry

Problem: Test a temporary URL while its synthetic deadline is still in the future.

  1. The test advances 10 minutes, leaving time before the 20-minute expiration.
  2. The unchanged link and all stated route and policy preconditions permit the response.
php Laravel 12 fragment or synthetic signed-link trace
$url = URL::temporarySignedRoute('reports.show', now()->addMinutes(20), ['report' => 42]);
$this->travel(10)->minutes();
$this->get($url)->assertOk();
// Fixture: signed route, existing report, and allowed actor.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The configured endpoint returns 200 in this fixture.

Why this result follows: An unmodified, unexpired signature can pass when the remaining application access checks also succeed.

6. Authenticate and authorize

Problem: Protect a signed link for a report that belongs to a particular user.

  1. Authentication and signature middleware are configured on the route.
  2. Even with a valid signature, the explicit policy denies access to this particular report.
php Laravel 12 fragment or synthetic signed-link trace
Route::get('/reports/{report}', function (Report $report) {
    Gate::authorize('view', $report);
    return view('reports.show', ['report' => $report]);
})->middleware(['auth', 'signed'])->name('reports.show');
// Fixture: valid link; policy denies current user.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The normal authorization response is 403 and the report view is not returned.

Why this result follows: A valid signed URL establishes integrity; the separate policy decides access for the current actor.

7. Missing resource

Problem: Distinguish an intact signed URL from a report that no longer exists.

  1. The signature can remain valid for the URL even when its target record changes.
  2. Implicit binding cannot find report 42 in the stated fixture, so the action cannot return its title.
php Laravel 12 fragment or synthetic signed-link trace
Route::get('/reports/{report}', fn (Report $report) => $report->title)
    ->name('reports.show')->middleware('signed');
// Fixture: valid signature for report 42, but report 42 was deleted.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The normal missing-model response is 404.

Why this result follows: URL integrity does not guarantee that a corresponding database record still exists.

8. Query tampering

Problem: Reject a modified signed query value on an unchanged route.

  1. The format query value is part of the issued signed URL in this fixture.
  2. Changing summary to full while retaining the original signature changes the protected data.
php Laravel 12 fragment or synthetic signed-link trace
// Issued signed query: report=42, format=summary
// Received query: report=42, format=full, original signature
// Validation: signed middleware, no ignored query parameters.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: Signature validation rejects the modified request.

Why this result follows: The signature protects the included query values rather than allowing the recipient to change them silently.

9. Ignored analytics parameter

Problem: Use an ignored query value only for nonsecurity analytics.

  1. The explicit validation call ignores utm_source when checking the signature.
  2. The value may be changed by the recipient and therefore must not affect access, price, or identity.
php Laravel 12 fragment or synthetic signed-link trace
if (! $request->hasValidSignatureWhileIgnoring(['utm_source'])) {
    abort(403);
}
// Fixture: only utm_source differs; report and other signed values are unchanged.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: Signature validation can pass despite a changed utm_source.

Why this result follows: Ignoring a parameter deliberately excludes it from integrity protection and makes it mutable.

10. Explicit invalid signature branch

Problem: Reject an invalid link before executing the report action.

  1. The explicit check evaluates the incoming URL before the service is called.
  2. An invalid signature enters the abort branch, so the show operation does not run.
php Laravel 12 fragment or synthetic signed-link trace
if (! $request->hasValidSignature()) {
    abort(403);
}
return $reports->show($report);
// Fixture: signature is invalid.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The response is 403 and the report service is not invoked.

Why this result follows: A fail-closed check at the receiving boundary prevents an invalid URL from reaching the action.

11. GET preview without mutation

Problem: Make an automatic mail preview safe for a consequential operation.

  1. A mail scanner may issue GET before the recipient opens the link.
  2. The stated controller only renders confirmation, so this automatic request does not consume the invitation.
php Laravel 12 fragment or synthetic signed-link trace
Route::get('/invitations/{invitation}', [InvitationController::class, 'confirm'])
    ->name('invitations.confirm')->middleware('signed');
// Fixture: confirm renders a page; it does not consume the invitation.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The confirmation page is returned and invitation state remains unchanged.

Why this result follows: A read-only confirmation GET separates link inspection from the later state-changing request.

12. Protected confirmation

Problem: Perform the effect only after an explicit protected confirmation.

  1. The confirmation form sends a state-changing POST to a URL valid for that receiving route.
  2. The configured CSRF, signature, authentication, and policy checks must all succeed before acceptance.
php Laravel 12 fragment or synthetic signed-link trace
Route::post('/invitations/{invitation}/accept', [InvitationController::class, 'accept'])
    ->middleware(['auth', 'signed']);
// Fixture: POST URL is independently signed; web CSRF and policy checks are configured.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: An authorized confirmed POST can accept the invitation once the service succeeds.

Why this result follows: A dedicated state-changing request preserves separate integrity, session, and authorization boundaries for the confirmed operation.

13. Repeated link before expiry

Problem: Recognize that expiration does not enforce a one-use rule.

  1. Both requests occur before the stated expiration and use the same intact link.
  2. Because no consumption state exists, the second use is not rejected merely for being repeated.
text Laravel 12 fragment or synthetic signed-link trace
// Synthetic trace: valid link expires at 12:20
12:05 GET /reports/42 -> accepted
12:06 GET /reports/42 -> accepted
// No server-side consumption rule exists.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: Both requests can be accepted while the link remains valid.

Why this result follows: An expiration deadline limits time, not the number of uses within that interval.

14. Atomic consumption

Problem: Use a conditional update to claim a one-use synthetic token.

  1. The conditional update matches the row only while consumed_at is null.
  2. After one successful claim, a later claim finds no eligible row; transaction and effect handling must be designed together.
php Laravel 12 fragment or synthetic signed-link trace
$claimed = DB::table('link_uses')
    ->where('id', $id)->whereNull('consumed_at')
    ->update(['consumed_at' => now()]);
if ($claimed !== 1) { abort(409); }
// Fixture: one row exists, consumed_at initially null; operation participates in a suitable transaction.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The first claim updates one row; a later claim updates zero and returns 409.

Why this result follows: A conditional state transition makes the consumption check and update one database operation for that row.

15. Rollback after failed operation

Problem: Keep consumption and a database effect in one defined transaction.

  1. The synthetic service throws while the transaction is still open.
  2. The database transaction rolls back its database changes, including the claim, under the configured connection.
php Laravel 12 fragment or synthetic signed-link trace
DB::transaction(function () use ($id, $service) {
    $claimed = DB::table('link_uses')->where('id', $id)->whereNull('consumed_at')->update(['consumed_at' => now()]);
    if ($claimed !== 1) { abort(409); }
    $service->applyDatabaseChange(); // fixture: throws before commit
});

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: No consumption or database effect is committed in this fixture.

Why this result follows: A transaction can couple database state changes on its connection; it does not undo external effects.

16. Relative signature mode

Problem: Use a matching relative signing and validation contract.

  1. The generator omits the domain from the signed URL by using relative mode.
  2. The receiving middleware is also configured for relative signature validation.
php Laravel 12 fragment or synthetic signed-link trace
$url = URL::temporarySignedRoute('reports.show', now()->addMinutes(20), ['report' => 42], absolute: false);
Route::get('/reports/{report}', ReportController::class)
    ->name('reports.show')->middleware('signed:relative');

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The relative signed URL can validate under the matching route and key.

Why this result follows: Both ends agree on the signed relative URL; this choice does not authenticate the host or the user.

17. Proxy scheme mismatch

Problem: Diagnose an absolute link generated as HTTPS but received as HTTP.

  1. The application reconstructs a different scheme from the externally signed URL.
  2. Inspect trusted proxy configuration and forwarded headers instead of disabling the signed middleware.
text Laravel 12 fragment or synthetic signed-link trace
// Generated external URL: https://portal.example.test/reports/42?...
// Application sees: http://portal.example.test/reports/42?...
// Signature mode: absolute; proxy configuration is incorrect.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The signature can fail until the application sees the correct external scheme.

Why this result follows: Absolute signature validation depends on the URL reconstructed by the receiving application.

18. Key rotation consideration

Problem: Plan for a link issued before the signing key is changed.

  1. The signature was generated using key A.
  2. The verifier now uses only key B, so it cannot validate the old signature under this fixture.
text Laravel 12 fragment or synthetic signed-link trace
// Day 1: issue temporary link using key A.
// Day 2: application signs and verifies using key B only.
// No key fallback is configured in this fixture.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The outstanding link fails verification after the key change.

Why this result follows: Signature verification depends on the configured key; rotation planning must account for outstanding links.

19. Safe diagnostics

Problem: Log a signature failure without recording a bearer URL or secret.

  1. The log records a route name and a broad failure category.
  2. It excludes the bearer link and signing key, reducing accidental disclosure in logs.
php Laravel 12 fragment or synthetic signed-link trace
Log::notice('Signed report link rejected', [
    'route' => $request->route()?->getName(),
    'category' => 'invalid_or_expired',
]);
// Do not log the full URL, signature, or application key.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: A sanitized diagnostic event is recorded without the signature.

Why this result follows: Operational evidence can identify a failure boundary without copying secret-bearing request material.

20. Tamper test with state check

Problem: Verify rejection of a changed report key and absence of mutation.

  1. Changing the path invalidates the signature for the original report URL.
  2. The response assertion and unchanged view counter check rejection and durable state independently.
php Laravel 12 fragment or synthetic signed-link trace
$url = URL::temporarySignedRoute('reports.show', now()->addMinutes(20), ['report' => 42]);
$tampered = str_replace('/reports/42', '/reports/43', $url);
$this->get($tampered)->assertForbidden();
$this->assertDatabaseHas('reports', ['id' => 43, 'views' => 0]);
// Fixture: signed middleware and isolated synthetic reports configured.

Illustrative fragment or trace requiring the stated application and synthetic fixtures; it has not been executed here.

Expected result: The test expects 403 and report 43 views remaining 0.

Why this result follows: A tampering test verifies both the signature boundary and the absence of the protected effect.

Common errors and fixes

A valid link is treated as proof of identity

Why it happens
The signature protects URL integrity, not the identity of its bearer.
How to fix it
Require authentication and authorize the target where the workflow needs identity.
Prevent it next time
Test two synthetic users against the same target.

A preview triggers a destructive GET

Why it happens
The link performs the mutation as soon as it is fetched.
How to fix it
Show a confirmation page and use a protected state-changing request.
Prevent it next time
Test automatic link fetching without a durable effect.

A supposedly one-time link works twice

Why it happens
Expiry was mistaken for a consumption record.
How to fix it
Record and atomically check consumption for the business action.
Prevent it next time
Test consecutive and concurrent attempts on disposable data.

20 practice exercises

1. A link expires in one hour but must be usable only once. What additional state is needed?

Show hint

A deadline does not record a previous use.

Show worked solution

Store a server-side identifier and consumption state, associate it with the intended operation, and atomically transition it on successful use. Test concurrent attempts and rollback behavior. The signed expiry limits time but does not by itself record consumption.

Store a server-side identifier and consumption state tied to the intended operation. Atomically claim the unused record and coordinate the protected database effect within a suitable transaction, with a defined response for later or concurrent attempts. Test rollback on failure; the signed expiration limits time but does not record use.

Check your solution

  • A consumption marker is stored and claimed atomically.
  • Concurrent attempts cannot both commit the protected effect.

2. A valid link fails only behind a reverse proxy. How would you investigate?

Show hint

Compare the URL seen by the signer and the receiver without exposing its signature.

Show worked solution

Compare the generated and received external scheme, host, path and query without publishing the signature. Inspect trusted-proxy configuration and route signature validation, then retest a valid and a tampered link. Do not bypass the middleware to hide the mismatch.

Compare the external scheme, host, path, and query structure with the request reconstructed by Laravel. Inspect trusted-proxy configuration and the signing and validation modes, then test an intact synthetic link and a tampered one. Keep signature validation active; a proxy mismatch is not a reason to bypass it.

Check your solution

  • The external and reconstructed scheme and host agree.
  • The valid link passes and the tampered link fails.

3. A temporary signed report URL lasts 30 minutes. List the generation and receiving-route requirements.

Show hint

The name, key, expiry, and verifier must agree.

Show worked solution

Register the named route, configure an application signing key, generate the URL with the synthetic report identifier and expiration, and validate it with signed middleware or the documented request check. Test an unchanged URL through the actual configured route. Generation alone does not establish receiving-side verification.

Check your solution

  • The generator has the named route and key.
  • The receiving path validates the signature.

4. A signed URL for report 8 is changed to report 9 without recomputing the signature. Predict the outcome.

Show hint

The path belongs to the protected URL.

Show worked solution

The changed report path no longer matches the signature generated for report 8, so normal signed middleware rejects the request. Assert the configured rejection and verify that report 9 is not disclosed or changed. Use synthetic records and do not print the bearer URL into logs.

Check your solution

  • The tampered request is rejected.
  • Report 9 remains undisclosed and unchanged.

5. A link is valid for 20 minutes. Design tests at 10 and 21 minutes with a controlled clock.

Show hint

Set time explicitly rather than sleeping.

Show worked solution

Issue the synthetic link at a known test time and advance the isolated clock by 10 minutes for the unexpired case. In a separate reset test advance 21 minutes and assert expiration rejection. Provide valid authentication and model fixtures so a different failure does not hide the signature result.

Check your solution

  • The 10-minute request can pass all stated checks.
  • The 21-minute request is rejected as expired.

6. A valid signed report link is forwarded to another signed-in user. What must the application check?

Show hint

Integrity does not identify the recipient.

Show worked solution

Authenticate the recipient when the workflow requires identity, scope the report lookup appropriately, and authorize the actual report with a policy. Test the same intact link as the intended actor and as a second actor. A denied actor must not receive private fields or cause a state change.

Check your solution

  • The intended actor is tested.
  • The second actor is denied according to policy.

7. A URL contains an email address and a signed identifier. Explain the exposure and safer design.

Show hint

A signature does not encrypt the query.

Show worked solution

Recipients, browser history, logs, and intermediaries may see URL data. Replace unnecessary personal details with a minimal synthetic or opaque server-side identifier and retrieve authorized data at the destination. Choose a suitable expiration and avoid logging full bearer links; the signature only protects integrity.

Check your solution

  • The URL contains no unnecessary personal detail.
  • Full bearer URLs are excluded from logs.

8. A signed GET immediately deletes an invitation. Propose a safer interaction and test.

Show hint

Automated link previews can issue GET.

Show worked solution

Make the signed GET display a confirmation without mutating the invitation. Require a separately protected state-changing request with the necessary signature, session, CSRF, and authorization checks to perform deletion. Test an automatic fetch for unchanged state and a deliberate confirmation for the intended effect.

Check your solution

  • GET leaves invitation state unchanged.
  • Only the protected confirmation can perform the effect.

9. A link must be used once even though it expires in an hour. Describe the required server state.

Show hint

Time and consumption are independent.

Show worked solution

Store a link identifier and consumption status associated with the intended operation. Atomically claim the unused record and coordinate the database effect within a suitable transaction; reject later claims. Test consecutive and concurrent attempts and define rollback behavior when the operation fails before commit.

Check your solution

  • A server-side consumption marker exists.
  • Only one competing claim can succeed.

10. A claim is marked consumed before a database operation throws. What transaction behavior should be tested?

Show hint

The claim and effect need one defined boundary.

Show worked solution

Run the conditional claim and database effect in an appropriate transaction on the intended connection. In an isolated fixture force the database operation to fail before commit and verify neither the claim nor partial database changes persist. Handle external effects separately because database rollback cannot undo them.

Check your solution

  • The consumption marker is rolled back.
  • No partial database effect is committed.

11. A tracking parameter may be changed after signing. What restrictions apply if validation ignores it?

Show hint

Ignored values are not integrity protected.

Show worked solution

Use the documented ignore mechanism only for a parameter whose mutability is acceptable, such as a nonsecurity analytics label. Never use that value to choose a user, resource permission, price, or other protected decision. Test changes to the ignored value separately from changes to protected parameters.

Check your solution

  • The ignored value has no security effect.
  • A protected parameter change still fails validation.

12. An absolute signed URL fails only behind a proxy. List the nonsecret facts to compare.

Show hint

Compare the external and reconstructed URL.

Show worked solution

Compare the expected scheme, host, path, and query structure with what the application reconstructs, without sharing the full signature. Inspect the trusted-proxy list and forwarded headers, then retest an unchanged synthetic link and a tampered link. Keep signature middleware enabled throughout the investigation.

Check your solution

  • The external scheme and host are compared.
  • Valid and tampered links are retested.

13. A relative signed URL is used on multiple hosts. Explain the corresponding validation and limitation.

Show hint

Both generator and verifier must use relative mode.

Show worked solution

Generate the URL with absolute false and validate it with the documented relative signed middleware mode. The host is not protected as part of that relative signature, so apply host routing and authorization appropriate to the application. Test the intended hosts and a tampered path independently.

Check your solution

  • Generation and validation both use relative mode.
  • Host and actor policy remain separate.

14. A signing key changes while links remain outstanding. Describe a controlled verification plan.

Show hint

Old links were signed under the earlier key.

Show worked solution

In a disposable environment issue a link under the prior key, change the verification configuration as planned, and test whether the old link remains accepted or is intentionally invalidated. Communicate the expected user experience and issue replacements where appropriate. Never record real application keys or live bearer URLs.

Check your solution

  • The old-link behavior is tested.
  • No real key or bearer link enters the evidence.

15. A recipient opens a valid link after the target report was deleted. Predict the two separate boundaries.

Show hint

URL validity and record existence differ.

Show worked solution

The signature can remain valid because the URL was not altered and has not expired. Model binding then fails to find the deleted report and normally returns 404 under the default missing-model behavior. Test the response and confirm that no replacement or unrelated report is exposed.

Check your solution

  • The signature and model lookup are considered separately.
  • No unrelated report is disclosed.

16. A developer logs every rejected URL in full. Explain the risk and replace the diagnostic.

Show hint

The link itself may be a bearer capability.

Show worked solution

A full signed URL can be copied from logs and used by anyone with access while it remains valid. Record a sanitized route name and broad failure category instead, avoiding the signature, key, and sensitive query values. Review existing log retention and use synthetic examples in tests.

Check your solution

  • The full bearer URL is not logged.
  • The diagnostic still identifies the route and category.

17. A valid signature reaches a controller that forgets to call its policy. Design a regression test.

Show hint

A valid signature must not imply permission.

Show worked solution

Create a synthetic report and two users, issue one intact link, and request it as the user denied by the report policy. Assert the expected denial and absence of private report content. Also test the permitted user so the policy test distinguishes an access bug from a broken link.

Check your solution

  • The denied user cannot see protected content.
  • The permitted user can use the valid link.

18. A tampered signed request returns an error but increments a view counter. Explain the defect and check.

Show hint

The protected effect must occur after verification.

Show worked solution

Move or enforce signature validation before the counter update and any protected action. In a disposable feature test alter a signed path, assert the expected rejection, and verify the counter remains unchanged. Test the valid path separately so both the rejection and intended behavior are established.

Check your solution

  • The tampered request is rejected.
  • Its view counter remains unchanged.

19. A one-use link is opened simultaneously by two requests. State the expected invariant.

Show hint

A sequential check followed by a write is not enough.

Show worked solution

Use an atomic conditional claim or suitable locking within the transaction that owns the database effect. Exercise competing attempts against a disposable target database and assert that exactly one can commit the intended effect. Define a clear response for the loser and for a failed transaction.

Check your solution

  • At most one effect commits.
  • The losing request has a defined response.

20. An expired link is rejected, but the test used the wrong host. Improve the test design.

Show hint

Isolate the reason for rejection.

Show worked solution

First establish that the unchanged URL is accepted before expiration under the correct host, signature mode, actor, and fixture. Then advance a controlled clock beyond expiry and assert rejection with unchanged state. A test that fails earlier on host reconstruction does not prove expiration handling.

Check your solution

  • The pre-expiry control succeeds.
  • Only the clock changes for the expiry case.

Key takeaways

  • A signature protects integrity and can enforce expiry; it is not identity or single-use state.
  • Test the link, policy and resulting state at the real HTTP boundary.
  • A signed URL protects integrity and may expire, but does not encrypt its contents or identify its bearer.
  • A one-use rule needs atomic server-side consumption state and a defined effect boundary.
  • Proxy reconstruction and signing mode must agree without exposing bearer links in diagnostics.

Official references