You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: document OAuth/forum auth changes in 2.0 upgrade guide (#511)
Covers ResponseFactory::make() signature change, removal of authenticationComplete(),
makeLoggedInResponse/makeRegistrationResponse promoted to protected, the new
POST /api/registration-token endpoint, _flarum_auth and _flarum_linked query params,
and SignUpModal label additions. Includes a warning pointing developers to the
fof/oauth upgrade notes for the companion package changes.
Copy file name to clipboardExpand all lines: docs/extend/update-2_0.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -413,6 +413,74 @@ Checkout this example from the mentions extension:
413
413
414
414
:::
415
415
416
+
### OAuth / Forum Auth
417
+
418
+
##### <spanclass="breaking">Breaking</span>
419
+
420
+
**`ResponseFactory::make()` — new `$returnTo` argument and return type change**
421
+
422
+
`Flarum\Forum\Auth\ResponseFactory::make()` now requires a fourth argument `string $returnTo = '/'` and always returns a `RedirectResponse` instead of an `HtmlResponse`. The old popup-based HTML response has been removed entirely.
The `$returnTo` value must be a validated same-origin relative path (starting with `/`). Passing an absolute URL is a security risk — validate it before passing it in.
`authenticationComplete()` existed solely to close the old popup window. It has been removed. Extensions that called it can drop the call entirely — the new redirect flow handles everything server-side.
437
+
438
+
**`makeLoggedInResponse()` and `makeRegistrationResponse()` are now `protected`**
439
+
440
+
Both helper methods on `ResponseFactory` are now `protected`, making them official extension points. Subclass `ResponseFactory` and override either method to customise login redirect behaviour or the registration handoff mechanism.
441
+
442
+
```php
443
+
class MyResponseFactory extends ResponseFactory
444
+
{
445
+
protected function makeLoggedInResponse(User $user, string $returnTo): ResponseInterface
446
+
{
447
+
// Custom behaviour — e.g. append your own query params
$this->container->extend(ResponseFactory::class, fn () => new MyResponseFactory(...));
457
+
```
458
+
459
+
**New `POST /api/registration-token` endpoint**
460
+
461
+
A new unauthenticated endpoint accepts a short-lived registration token in the POST body and returns only `username`, `email`, and `provided[]`. Sensitive fields (provider name, identifier, payload internals) are never exposed. The token is submitted in the body — not the URL — so it never appears in server access logs, browser history, or Referer headers.
462
+
463
+
This endpoint is CSRF-exempt (token possession is the credential) and is primarily used by the frontend to pre-populate the sign-up modal after an OAuth redirect.
464
+
465
+
**`_flarum_auth` and `_flarum_linked` query parameters**
466
+
467
+
The new redirect flow uses two query parameters appended to the `returnTo` URL:
468
+
469
+
*`_flarum_auth=<token>` — set when a new user arrives via OAuth and must complete registration. The frontend detects this on boot, strips it, fetches `username`/`email`/`provided` from `POST /api/registration-token`, and opens the `SignUpModal` pre-populated.
470
+
*`_flarum_linked=<provider>` — set when an existing user's account is linked to an OAuth provider for the first time (either via email-match during login, or a manual link from the security page). The frontend detects this on boot and shows a confirmation modal.
471
+
472
+
Both parameters are stripped from the URL immediately on the client without a page reload.
473
+
474
+
:::warning fof/oauth also updated
475
+
476
+
If your extension extends or depends on **FriendsOfFlarum/oauth**, that package has been significantly updated alongside these core changes. The popup flow has been removed, `AbstractOAuthController` has moved from `fof/extend` into `fof/oauth` itself, and several other breaking changes apply. See the fof/oauth upgrade notes for the full migration guide.
477
+
478
+
:::
479
+
480
+
#### <spanclass="notable">Notable</span>
481
+
482
+
*`SignUpModal` fields (Username, Email, Password) now render a visible `<label>` element above each input. If your extension renders additional fields in `SignUpModal`, consider adding a label for consistency.
0 commit comments