← Back to Pull requests

feat(auth): honour remember_me and token_expiration_minutes on issued tokens #170

Open
unknown opened this pull request with 332 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 15, 2026 01:53 UTC
Author

What

  • POST auth/login accepts an optional boolean remember_me (a non-boolean answers 422). true gives the issued token the new remember_me_expiration_minutes lifetime (MAGIC_STARTER_REMEMBER_ME_EXPIRATION, default null, which falls back to token_expiration_minutes; a non-positive or empty value reads as unset). The 2FA challenge token carries the flag, so POST auth/two-factor-challenge issues the token with the lifetime the sign-in asked for.

  • token_expiration_minutes (MAGIC_STARTER_TOKEN_EXPIRATION) was documented as the token lifetime but nothing read it, so a host that set it got tokens that never expire. It now sets expires_at on every token the package issues (login, registration, 2FA challenge, OTP, guest, social, handoff). Null or 0 keeps today's tokens without their own expiry; sanctum.expiration still applies on top.

  • Docs (configuration, authentication, the Boost guideline and the two Boost skill references) and the CHANGELOG follow.
  • Why

    The Flutter starter's login screen has a "Remember me" checkbox that sent remember_me and the backend ignored it, so the control did nothing (found by a fresh independent audit; Anilcan decided on 2026-11-15 to implement it now). Reading the code for it showed the dead token_expiration_minutes key.

    Compatibility

    Defaults stay null, so nothing changes for a host that configures neither key. A host app that overrides createAuthToken or signInResponse in a controller subclass must add the new trailing optional $remember parameter to keep PHP's signature compatibility.

    Testing

  • New tests/Http/Controllers/AuthTokenLifetimeTest.php (13 tests against real Sanctum) plus one guest-claim test; the new tests failed before the code (checked by the author).

  • Full suite 4315 tests, 19522 assertions, 0 failures (5 existing skips); vendor/bin/pint --test passed; PHPStan level 6 clean.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Password sign-ins can include an optional remember_me choice. Remembered sign-ins and their completed two-factor challenges can use a separate configured token lifetime.
    Package-issued tokens support a configurable lifetime; an unset or non-positive lifetime leaves tokens without a package-level expiry. Sanctum expiration may still apply.
    Documentation
    * Updated authentication and configuration guidance to explain the remember-me option, accepted values, token lifetime settings, and fallback behavior.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 332 lines (+249 / -83) across 4 files Reviewer: coderabbitai[bot] Review duration: 7m
    All Vouch review confidence checks passed
    Residual risk 0.41 = Change Risk (0.65) × (1 − Review Confidence (0.38)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 332 lines diff across 4 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 89% · Reviewer familiarity: 35%
    37%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.347
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.065
    Real PR Conversation Timeline
    1 comments
    "Review active on #170"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 37.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.3% (HIGH) · Higher = larger blast radius
    65.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 37.8% · Lower = rushed or shallow review
    37.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 40.6% · Moderate risk
    40.6%