Download the PHP package marten-cz/nette-jwt-user-storage without Composer
On this page you can find all versions of the php package marten-cz/nette-jwt-user-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marten-cz/nette-jwt-user-storage
More information about marten-cz/nette-jwt-user-storage
Files in marten-cz/nette-jwt-user-storage
Package nette-jwt-user-storage
Short Description Nette IUserStorage implementation using JWT instead of sessions.
License MIT
Informations about the package nette-jwt-user-storage
nette-jwt-user-storage
Nette IUserStorage implementation using JWT access token instead of PHP sessions.
Disclaimer: If you don't know what JWT is, please refer to JWT draft or to JWT homepage.
On user login, the application stores jwt_access_token cookie instead of bad old PHPSESSID one.
The cookie contains an encoded JWT signed by the application. The user authentication is then based
on verifying the JWT rather than the session.
Warning: CSRF protection rules still apply!
This means you no longer need to solve PHP session implementation, scaling and testing problems.
All the things that you would normally store in the SessionStorage can be stored in a key-value
storage, where the JWT is a key.
This also means your application is ready to become SPA in the future. :)
Configuration
Register the extension in your config.neon.
Then configure its required properties.
Both the JWT and the cookie in which it's stored is by default set to expire in 20 days. If you want to fiddle
with expiration time, use expiration option:
By default, jti and iat (see JWT draft) are added
to your JWTs. If you don't want to use them, set generateJti and generateIat options to false.
If you want to define your own Nette\Security\IIdentity serializer, which serializes your identity implementation
into the JWT body, you can implement Marten\Nette\JwtStorage\\IIdentitySerializer
and register it in configuration.
And that's it, you're ready to go!
Known issues
- If you are developing an app with JWT User Storage and you still see
PHPSESSIDin your cookies, it's probably because Tracy\Tracy uses it.
Discussion threads
- Czech discussion thread on Nette Forum
Literature
All versions of nette-jwt-user-storage with dependencies
nette/security Version ^3.0
nette/http Version ^3.0
firebase/php-jwt Version ^3.0|^4.0|^5.0