Pushword provides a flexible authentication system with multiple login methods: password, magic link (passwordless), and OAuth (supports 60+ providers via KnpUOAuth2ClientBundle).
The login page offers a two-step flow:
Additionally, if OAuth is configured, provider buttons appear on the login page.
Users can be defined in config/users.yaml and synced to the database (via flat extension). This is useful for version-controlled user management or clone instance.
Create config/users.yaml:
users:
- email: admin@example.com
roles: [ROLE_SUPER_ADMIN]
locale: en
username: Admin
- email: editor@example.com
roles: [ROLE_EDITOR]
locale: fr
username: Editor
# Sync users from config/users.yaml to database
php bin/console pw:flat:user-sync
# Or use the global flat sync (includes users if configured)
php bin/console pw:flat:sync
Important behaviors:
users.yaml doesn't exist, a template file is created automaticallyUsers without a password receive a magic link email when they try to login. The email contains:
Tokens are:
Enable social login with any OAuth provider supported by KnpUOAuth2ClientBundle (60+ providers including Google, Microsoft, GitHub, Facebook, etc.).
# Core bundle (required)
composer require knpuniversity/oauth2-client-bundle
# Add providers you need
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
# See full list: https://github.com/thephpleague/oauth2-client/blob/master/docs/providers/thirdparty.md
config/packages/knpu_oauth2_client.yaml to configure your providers: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
OAuth buttons automatically appear on the login page for each configured provider.
Only users already defined in users.yaml (or created in admin) can login via OAuth. If the OAuth email doesn't match an existing user, login is refused. OAuth won't create new users automatically.
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
.env.local or environment variables.OAUTH_GOOGLE_HOSTED_DOMAIN to limit to your organizationOAUTH_MICROSOFT_TENANT instead of "common"users.yaml to control who can access the admin. OAuth won't create new users automatically.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