A GraphQL authentication component with OAuth2 support, magic link authentication, and JWT tokens.
Before using the authentication component, you need to generate the required OAuth2 keys:
composer run generate-keys
This script will generate:
- JWT Private/Public Key Pair: Used for signing and verifying JWT tokens
- Encryption Key: Used for encrypting authorization and refresh codes
The keys will be saved to:
config/jwt/private.key
- JWT private key (keep secure!)config/jwt/public.key
- JWT public keyconfig/autoload/auth.local.php
- Contains only the encryption key
Important: The script will fail if keys already exist to prevent accidental overwriting.
The script uses configurable OpenSSL parameters for JWT key generation:
-
digestAlg: Hash algorithm (
sha256
,sha384
,sha512
)sha256
: Fast, widely supported (default)sha384
: More secure, good balancesha512
: Most secure, slower
-
privateKeyBits: Key size in bits (
2048
,3072
,4096
)2048
: Fast, minimum recommended (default)3072
: Good security/performance balance4096
: Maximum security, slower
-
privateKeyType: Key algorithm (
RSA
,DSA
,DH
,EC
)RSA
: Most widely supported (default)EC
: Elliptic Curve, smaller keys, good performance
For Docker environments, you can override the key paths using environment variables:
export JWT_PRIVATE_KEY_PATH=/app/keys/jwt/private.key
export JWT_PUBLIC_KEY_PATH=/app/keys/jwt/public.key
export AUTH_LOCAL_CONFIG_PATH=/app/config/autoload/auth.local.php
composer run generate-keys
The component uses the following default configuration structure:
'auth' => [
'jwt' => [
'privateKeyPath' => 'config/jwt/private.key',
'publicKeyPath' => 'config/jwt/public.key',
'passphrase' => null, // Set via environment if needed
'keyGeneration' => [
'digestAlg' => 'sha256', // sha256, sha384, sha512
'privateKeyBits' => 2048, // 2048, 3072, 4096
'privateKeyType' => 'RSA', // RSA, DSA, DH, EC
],
],
'token' => [
'accessTokenTtl' => 60, // 1 hour (in minutes)
'loginTtl' => 10, // 10 minutes
'refreshTokenTtl' => 10080, // 1 week (in minutes)
'registrationTtl' => 1440, // 24 hours (in minutes)
],
]
Need to create a class that implements SendVerificationEmailInterface and configure it