nette/security
Nette Security is a compact PHP library for authentication and authorization: secure password hashing (bcrypt/argon2), user identities and login, role and permission checks, and CSRF protection. It works standalone or as part of the Nette Framework.
SimpleAuthenticator – stored passwords may now be crypt-format hashes (anything password_hash() produces) and can be freely mixed with plain-text ones. The format is detected automatically, so hashes just work in the security: users: config section with no extra option. A hash whose algorithm the PHP build doesn't know fails closed instead of being compared as plain text, and plain-text comparison is timing-safe.Passwords::bcrypt() and Passwords::argon2id() – name the algorithm instead of juggling PASSWORD_* constants and options arrays: Passwords::bcrypt(12) or Passwords::argon2id(memoryCost: 65536). Omitted parameters keep PHP's defaults, and argon2id() fails with a clear exception on builds without Argon2 support.rules section lets you define permissions declaratively next to your roles and resources:
security:
rules:
allow:
- [guest, article, view]
- [registered, comment, [add, edit]]
- [admin]
deny:
- [banned, comment, add]
Each rule is [role(s), resource(s), privilege(s)]; an omitted or null item means "all", and a bare string grants or revokes everything for that role. Malformed rules are rejected at config time, not at runtime.logout() no longer touches the storage when there is nothing to change, so logging out a guest doesn't needlessly regenerate the session ID or overwrite the logout reason. A stored authentication vetoed by wakeupIdentity() (a revoked token, say) is still properly cleared.Permission::isAllowed() now saves and restores the queried role and resource, making it re-entrant and exception-safe – an assertion callback can call isAllowed() again without corrupting the results of the outer query.Guest identity – an IdentityHandler authenticator may now implement getGuestIdentity(): ?IIdentity to hand anonymous visitors a real identity. When present, getIdentity(), getId() and getRoles() transparently fall back to it, so guests carry their own roles and data instead of just the $guestRole string. The guest identity is resolved on read only and never written to storage.
$persistIdentity – the new User::$persistIdentity property lets you decide what happens to the identity after logout or expiration. It stays available for personalization by default; flip it to false and getIdentity()/getId() return null once the user is no longer logged in. Configurable straight from the security.authentication DI section.
SessionStorage no longer refreshes the sliding expiration timestamp once the session has already expired – an expired identity stays expired instead of being silently kept alive for another round
Adopted nette/phpstan-rules and made static analysis a mandatory part of the build, then resolved the errors it surfaced
Improved phpDoc types and descriptions across the codebase
A small maintenance release headlined by a fix to session-based identity storage, plus a tightening of the project's static analysis setup and a round of phpDoc polish.
nette/phpstan-rules and made static analysis a mandatory part of the build, then resolved the errors it surfaced$user => $username #73SessionStorage::setExpiration() does not overwrite data in the sessionverifyPassword()refreshStorage() to clear identity cache. (#46) (#50)User::setExpiration() second argument accept also bool $clearIdentitylogout() steps reorderinInRole() works with object RoleFor the details you can have a look at the diff.
[@Tracy](https://github.com/Tracy)\Bar nette/di#245hash(): Password can not be empty. (#47)For the details you can have a look at the diff.
For the details you can have a look at the diff.
For the details you can have a look at the diff.
getAuthorizatorIfExists()hasAuthenticator() & hasAuthorizator()For the details you can have a look at the diff.
For the details you can have a look at the diff.
setFactory() instead of misused setClass()For the details you can have a look at the diff.
For the details you can have a look at the diff.
For the details you can have a look at the diff.
hash() removed option 'salt' (BC break)For the details you can have a look at the diff.
For the details you can have a look at the diff.
For the details you can have a look at the diff.
For the details you can have a look at the diff.
For the details you can have a look at the diff.
For the details you can have a look at the diff.
The first standalone release. For more information see readme.md.
How can I help you explore Laravel packages today?