Repository navigation
fix: forms pass their own errors; sessions end after a password change; queued welcome #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
83ef968
1a5a544
ad8428a
9fe7f2a
9774247
2b85324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| namespace Modules\Auth\Listeners; | ||
|
|
||
| use Illuminate\Auth\Events\Login; | ||
| use Illuminate\Auth\SessionGuard; | ||
| use Illuminate\Support\Facades\Auth; | ||
|
|
||
| /** | ||
| * Signing in stores a fingerprint of the password in the session, and `AuthenticateSession` | ||
| * ends the session once it stops matching. An account with no password (a social sign-up) | ||
| * gets none, so a first password would leave its sessions open (sc-1259). This stores the | ||
| * fingerprint of no password instead: setting one changes it like any other change. | ||
| */ | ||
| class FingerprintPasswordlessSession | ||
| { | ||
| public function handle(Login $event): void | ||
| { | ||
| $guard = Auth::guard($event->guard); | ||
|
|
||
| if (! $guard instanceof SessionGuard || $event->user->getAuthPassword()) { | ||
| return; | ||
| } | ||
|
|
||
| session()->put('password_hash_'.$event->guard, $guard->hashPasswordForCookie(null)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ | |
| use App\Models\User; | ||
| use Filament\Facades\Filament; | ||
| use Illuminate\Cache\RateLimiting\Limit; | ||
| use Illuminate\Contracts\Http\Kernel; | ||
| use Illuminate\Http\Request; | ||
| use Illuminate\Session\Middleware\AuthenticateSession; | ||
| use Illuminate\Support\Facades\Auth; | ||
| use Illuminate\Support\Facades\Gate; | ||
| use Illuminate\Support\Facades\RateLimiter; | ||
|
|
@@ -38,6 +40,12 @@ public function boot(): void | |
|
|
||
| Gate::policy(User::class, UserPolicy::class); | ||
|
|
||
| // A session ends when its user's password changes (a change, a reset, a magic-link | ||
| // takeover): the session keeps a fingerprint of the hash and this compares it on every | ||
| // request. Registered here, like tenancy's guards: one an app had to add by hand would | ||
| // fail open when forgotten (sc-714). | ||
| $this->app->make(Kernel::class)->appendMiddlewareToGroup('web', AuthenticateSession::class); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. End every other session of an account at a password change, including sessions with no stored fingerprint.
This can happen in the magic-link takeover path. A social sign-up creates a passwordless, unverified account, and anyone can register that account with another person's address. An attacker who signs up through a social provider keeps a session on that account. When the owner takes it over and the account receives a random password, the attacker's session passes the check. The same happens when an owner sets a first password through the Security panel. Pre-release sessions that stay idle through a password change behave the same way. The required behavior is that a password change or takeover ends every other session of the account, including sessions that have no fingerprint. Choose the mechanism deliberately. Recording a fingerprint for passwordless sessions is not possible through the current middleware, because it returns early when the password is null.
|
||
|
|
||
| // A magic link proves the inbox it was sent to. A new address voids the old links, | ||
| // or one would sign in (and verify) an address it never reached. Every writer counts. | ||
| User::updated(function (User $user): void { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.