Skip to content

Configuring Password Protection and Expiration

Gate sensitive links behind SHA-256 passwords, schedule UTC expiration timestamps, and enforce click limits.

Configuring Password Protection and Expiration

Confidential pitch decks, time-delimited flash sales, and embargoed announcements require restricted access without complex authentication walls. This guide configures edge-enforced password gates, ISO 8601 expiration timestamps, and click ceilings that automatically disable access at Cloudflare Anycast edge nodes.


Prerequisites

  • Workspace permissions: Owner, Admin, or Member role in your Shaf organization.
  • A destination URL requiring access controls or time bounds.
  • A strong passphrase for password-gated deployments.

Implementation Recipe

  1. Configure Password Protection

    Protect your short link by supplying a passphrase during creation or updating an existing link:

    curl -X POST "https://shaf.app/api/v1/links" \
      -H "Authorization: Bearer $SHAF_API_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://example.com/embargoed-press-release",
        "slug": "confidential-q4",
        "domain": "shaf.is",
        "password": "SecurePassphrase2026!"
      }'
    1. Open the Link Editor modal.
    2. Expand the Security & Access section.
    3. Toggle Password Protection to On.
    4. Enter your passphrase. Shaf hashes the password using SHA-256 before persisting to D1.
  2. Set Expiration Timestamp & Click Limit

    Apply automated decommission criteria:

    curl -X PATCH "https://shaf.app/api/v1/links/lnk_01j8k9m4" \
      -H "Authorization: Bearer $SHAF_API_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "expiresAt": "2026-12-31T23:59:59Z",
        "clickLimit": 1000,
        "expiredUrl": "https://example.com/promotion-ended"
      }'
    Parameter Type Behavior
    expiresAt string (ISO 8601 UTC) Exact timestamp after which the link ceases resolving.
    clickLimit integer Maximum successful redirects permitted before automatic deactivation.
    expiredUrl string Custom fallback redirect for visitors attempting to access an expired link.
  3. Edge Gate Enforcement

    When access criteria fail or expiration triggers:

    • Password Protected: Shaf intercepts the redirect and returns an HTTP 200 password challenge screen. Validating the passphrase sets an encrypted session cookie and resumes the redirect.
    • Expired: Shaf halts routing and returns HTTP 302 to expiredUrl or HTTP 410 Gone.

Verification

Test edge gate evaluation using curl:

  1. Probe a password-protected link without credentials:

    curl -I "https://shaf.is/confidential-q4"

    Expected output:

    HTTP/2 200 OK
    content-type: text/html; charset=utf-8
    x-shaf-gate: password-required
  2. Submit the password challenge:

    curl -i -X POST "https://shaf.is/confidential-q4" \
      -H "Content-Type: application/x-www-form-urlencoded" \
      -d "password=SecurePassphrase2026!"

    Expected output:

    HTTP/2 308 Permanent Redirect
    location: https://example.com/embargoed-press-release
    set-cookie: shaf_pass_confidential-q4=...; Path=/; HttpOnly; Secure; SameSite=Lax

Common Gotchas

Issue / Error Root Cause Solution
Forgotten passphrase Passwords are saved as one-way SHA-256 hashes and cannot be retrieved. Open link settings in the dashboard and assign a new passphrase.
Premature expiration Timestamp provided in local timezone rather than UTC. Ensure ISO 8601 strings terminate with Z (e.g. 2026-12-31T23:59:59Z).
Click quota consumed by bots Search crawlers or social preview bots visited the link. Shaf’s bot defense engine filters verified automated crawlers from the click tally automatically.
Visitor bypassed password gate Browser cached 308 redirect from before password protection was toggled. Clear browser cache or test in a Private / Incognito browser session.

Type to search…

↑↓ navigate↵ selectEsc close