Three login methods: password, magic link (passwordless) and OAuth (60+ providers via KnpUOAuth2ClientBundle).
The response is identical for unknown addresses, so the form does not reveal which accounts exist. If OAuth is configured, provider buttons also appear on the login page.
Rate limits, per 15 minutes; a client is an IPv4 address or an IPv6 /64:
| Step | Limit | framework.rate_limiter |
|---|---|---|
| Email step, magic links and codes | 20 per client, 5 per email address | login_email, login_address |
| Password attempts | 5 per account and client, 25 per client | login_throttling_account, login_throttling_network |
Users can be defined in config/users.yaml and synced to the database by the flat extension, to version-control who has access.
users:
- email: admin@example.com
roles: [ROLE_SUPER_ADMIN]
locale: en
username: Admin
- email: editor@example.com
roles: [ROLE_EDITOR]
locale: fr
username: Editor
php bin/console pw:flat:user-sync # users only
php bin/console pw:flat:sync # pages, media and users
config/users.yaml, user sync is skipped and no user is touched.Step 1 of the login form emails every existing account two links:
Their tokens are:
A used, expired or superseded link never works again, except that a login link still offers code recovery (below) for 24 hours after it was sent.
Opening a login link on any device loads a page without consuming it. Its script submits a CSRF-protected POST once the page is active and visible; HEAD and GET never authenticate. Without JavaScript, the page offers a sign-in button.
If the link is used, expired or superseded, Receive a sign-in code starts a new email authentication attempt. No code is sent by merely opening the page. The second email contains an eight-digit code, valid for ten minutes with five attempts across browsers. Requests share the login form’s IP/address limits, with at least one minute between codes for a link. Recovery ends 24 hours after the link was sent: the page then returns to the login form with the expired-link message, even for a code already sent, so the visitor requests a new link. Only a hash is stored; the code never appears in a URL. Successful recovery revokes sessions issued by that link, while preserving password/OAuth sessions and sessions issued by other links. A full browser scanner can still complete the automatic login before recovery; the code cannot undo access that has already occurred. Opening a link while already signed in as its account goes straight to the admin.
Disabled by default. When enabled, the password step links to /login/forgot-password, which emails a set-password link (single-use, valid one hour). The page answers the same way for unknown addresses and shares the login form’s rate limits.
pushword:
enable_password_reset: true
An account created with pw:user:create --require-password-change can only set a new password at /login/change-password until it does.
composer require knpuniversity/oauth2-client-bundle
composer require league/oauth2-google # Google
composer require thenetworg/oauth2-azure # Microsoft/Azure
composer require league/oauth2-github # GitHub
composer require league/oauth2-facebook # Facebook
# Full list: https://github.com/thephpleague/oauth2-client/blob/master/docs/providers/thirdparty.md
config/packages/knpu_oauth2_client.yaml with redirect_route: pushword_oauth_check and redirect_params: { provider: <name> } — see the provider examples below. A login button appears for each configured provider.OAuth never creates users: only accounts that already exist (from users.yaml or the admin) can log in, and an unknown email is refused.
https://your-domain.com/login/oauth/google/checkConfiguration:
# config/packages/knpu_oauth2_client.yaml
knpu_oauth2_client:
clients:
google:
type: google
client_id: '%env(OAUTH_GOOGLE_CLIENT_ID)%'
client_secret: '%env(OAUTH_GOOGLE_CLIENT_SECRET)%'
redirect_route: pushword_oauth_check
redirect_params: { provider: google }
access_type: online
# Optional: restrict to Google Workspace domain
hosted_domain: '%env(default::OAUTH_GOOGLE_HOSTED_DOMAIN)%'
https://your-domain.com/login/oauth/microsoft/checkConfiguration:
# config/packages/knpu_oauth2_client.yaml
knpu_oauth2_client:
clients:
microsoft:
type: azure
client_id: '%env(OAUTH_MICROSOFT_CLIENT_ID)%'
client_secret: '%env(OAUTH_MICROSOFT_CLIENT_SECRET)%'
redirect_route: pushword_oauth_check
redirect_params: { provider: microsoft }
# Optional: restrict to specific tenant (default: "common" for any account)
tenant: '%env(default:oauth_microsoft_tenant_default:OAUTH_MICROSOFT_TENANT)%'
parameters:
oauth_microsoft_tenant_default: common
https://your-domain.com/login/oauth/github/checkConfiguration:
# config/packages/knpu_oauth2_client.yaml
knpu_oauth2_client:
clients:
github:
type: github
client_id: '%env(OAUTH_GITHUB_CLIENT_ID)%'
client_secret: '%env(OAUTH_GITHUB_CLIENT_SECRET)%'
redirect_route: pushword_oauth_check
redirect_params: { provider: github }
Add your OAuth credentials to .env.local:
# Google
OAUTH_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
OAUTH_GOOGLE_CLIENT_SECRET=your-client-secret
# Microsoft
OAUTH_MICROSOFT_CLIENT_ID=your-azure-client-id
OAUTH_MICROSOFT_CLIENT_SECRET=your-azure-client-secret
# GitHub
OAUTH_GITHUB_CLIENT_ID=your-github-client-id
OAUTH_GITHUB_CLIENT_SECRET=your-github-client-secret
For local development, use https://localhost or https://127.0.0.1 as your redirect URI in the OAuth provider console. You may need to run your Symfony server with HTTPS:
symfony server:ca:install
symfony server:start
A super administrator can browse the admin as any account that reaches ROLE_EDITOR, from Log in as in the row menu of the user list. An amber banner then stays at the top of every admin page until its Back to my account button returns you to the user list under your own session.
Every change made meanwhile is saved under the borrowed account: a page’s editedBy names that editor, not you.
Symfony’s switch_user handles both forms on a dedicated POST route with CSRF protection. Custom admin templates can use impersonation_form() and impersonation_exit_form() for the form action and hidden fields. Only ROLE_ALLOWED_TO_SWITCH may switch, and ROLE_SUPER_ADMIN is the only role that inherits it.
For custom sensitive actions, Symfony’s recent authentication checks can require a fresh sign-in. Pair them with a re-authentication entry point that works for the site’s enabled login methods. Test that users with passwordless accounts can complete the challenge.
For a site that uses a single identity provider, Symfony’s native OpenID Connect authenticator is an alternative integration. Bind verified identities to the site’s existing accounts and check that unknown identities are refused before switching providers.
.env.local or environment variables.OAUTH_GOOGLE_HOSTED_DOMAIN to limit to your organizationOAUTH_MICROSOFT_TENANT instead of “common”The OAuth email doesn’t match any user in the database. Add the user to config/users.yaml and run:
php bin/console pw:flat:user-sync
The OAuth provider didn’t return an email. Ensure your OAuth app has the email scope permission configured in the provider’s console.
knpuniversity/oauth2-client-bundle is installedconfig/packages/knpu_oauth2_client.yaml configuration exists and is validphp bin/console cache:clear.env: MAILER_DSN=smtp://user:pass@smtp.example.com:587