Configuration
VAPID Support
To enable the VAPID header feature, you must install a JWS Provider (see installation) and configure it with your public and private key (see this page to create these keys)
When using lcobucci/jwt
, the configuration is very similar.
You cannot enable both web-token
and lcobucci/jwt
at the same time
Token Lifetime
By default, the library generates VAPID headers that are valid for 1 hour. You can change this value if needed. The parameter requires a relative string as showed in the PHP documentation.
The token lifetime should not be greater than 24 hours. Most of the Web Push Services will reject such long-life tokens
Payload Support
Padding
To obfuscate the real length of the notifications, messages can be padded before encryption. This operation consists in the concatenation of your message and arbitrary data in front of it. When encrypted, the messages will have the same size which reduces attacks.
By default, the padding is set to recommended
i.e. ~3k bytes.
Acceptable values for this parameter are:
none
: no paddingrecommended
: default valuemax
: see warning belowan integer: should be between
0
and4078
or3993
forAESGCM
andAES128GCM
respectively
Please don't use "none
" unless your are sending notifications in a development environment.
The value "max
" increases the integrity protection of the messages, but there are known issues on Android and notification are not correctly delivered.
Caching
The notifications may have a payload. This payload is encrypted on server side and, during this process, a random key is generated.
The creation of this random key takes approximately 150ms and can impact your server performance when sending thousand of notifications at once.
To reduce the impact on your server, you can enable the caching feature and reuse the encryption key for a defined period of time.
As encryption keys will be stored in the cache, you should make sure the cache is not shared otherwise you may have a security issue.
This parameter requires a PSR-6 Cache compatible service. If you set Psr\Log\CacheItemPoolInterface
, the default Symfony cache will be used.
You can see the impact of this feature on the CI/CD Pipelines of this library. Go the https://github.com/Spomky-Labs/web-push/actions?query=workflow%3ABenchmark and find a summary table displayed at the end of each test.
Debugging
If you have troubles sending notifications, you can log some messages from the libray. To do so, you just have to set the parameter logger in the configuration.
This parameter requires a PSR-3 logger. If you set Psr\Log\LoggerInterface
, the Symfony logger will be used (PSR-3 copmpatible).
Last updated