dox_auth 3.0.2
dox_auth: ^3.0.2 copied to clipboard
Authentication package for dox framework with JWT and session drivers.
3.0.2 #
- New: gates and policies, for what a user may do.
Gate.define('update-post', (User user, Post post) => ...)adds a rule. The user and subject types come from the function.Policy<User, Post>holds the rules of one model. Add it withGate.policy<Post>(PostPolicy()).Gate.allows,denies,authorize(403 when denied),inspect,anyandall.Gate.beforeandGate.afterhooks.Policy.beforefor one policy.GateResponse.deny('reason')gives the message of the 403.- A guest is denied, unless the user type is nullable.
req.can,req.cannotandreq.authorizeuse the user ofreq.auth.Can('update', param: 'post')middleware. A guest gets 401, a denied user gets 403. Withparam, the subject is theRoute.bindvalue.
3.0.1 #
JwtAuthDriverkeeps old tokens working after anAPP_KEYchange. When a token has a wrong signature, it tries each old key fromAppConfig.previousKeys. New tokens are signed with the current key only. An expired token or a bad claim still fails at once.- New
previousSecretsoption onJwtAuthDriver, for a JWT secret that is notAPP_KEY. - Needs dox_core 3.0.1.
3.0.0 #
- The first stable release.
- The package now lives in its own repo: dartondox/dox-auth. Nothing changes for users: same package name, same API.
3.0.0-rc.1 #
- Breaking:
JwtAuthDriverno longer signs with theSecretKeytext as it is. The HMAC key is made from it with HKDF-SHA256 and the labeldox:jwt. Existing tokens become invalid after this version. Users must log in again.driver.signingKeygives the key, for another service that checks the tokens. - Security:
JwtAuthDriver.verifyTokenaccepts only the configuredalgorithm. A token with another algorithm in its header is rejected. - Security:
attemptonly puts a string or a number into the user query. A map or a list as the email (or another identifier) fails the login. AuthMiddlewareandAuth.setUsersetreq.authdirectly. They no longer put the auth into the request input.UnAuthorizedExceptiontakes adynamic message, so a map message works.APP_ENV=testingis treated liketestfor the short secret check: only a warning.
3.0.0-alpha.17 #
- Uses dox_orm 3.0.0-alpha.12.
3.0.0-alpha.16 #
- Version bump only, to match the other packages.
3.0.0-alpha.15 #
- Docs: the README and the example set up auth in an
AppAuthProviderthat extendsDoxProvider.
3.0.0-alpha.14 #
- New:
Auth().setUser(req, user)sets the logged-in user onreq.auth, with no token and no password check. Use it in your own auth middleware, like an API key check. - Docs: how to write a custom guard. Extend
AuthDriver, return the user fromverifyToken, and useAuthMiddleware(guard: 'api'). The README and the authentication page show an API key example. - Fix: importing
dox_authanddox_coretogether gave an "ambiguous import" error forAUTH_REQUEST_KEY.dox_authno longer has its own copy. The one indox_coreis used.
3.0.0-alpha.13 #
- Version bump only, to match the other packages.
3.0.0-alpha.12 #
- New:
SessionAuthDriverkeeps the login in the session, for web pages. UseAuth().attemptSession(req, credentials),Auth().loginSession(req, user)andAuth().logout(req). Login and logout give the session a new id. NeedsSessionMiddleware. - New:
AuthMiddleware(redirectTo: '/login')sends a guest to that page instead of a 401. - Docs: with the default
cookiesession driver, an old copy of the cookie still works after logout. The README now says to use thecachedriver when logout must end old cookies. - Change: the password check of
attemptmoved toAuthDriver.checkCredentials, so all drivers share it.
3.0.0-alpha.11 #
- Version bump only, to match the other packages.
3.0.0-alpha.10 #
- Version bump only, to match the other packages.
3.0.0-alpha.9 #
- Version bump only, to match the other packages.
3.0.0-alpha.8 #
- Security: a JWT secret (
SecretKey) shorter than 32 bytes stops the app with anArgumentErrorwhenAPP_ENVis notdevelopment,localortest. In those envs it prints one warning line. Make a key withdox key:generateoropenssl rand -hex 32. Hashnow comes fromdox_core. dox_auth had its own copy.package:dox_auth/src/hash.dartre-exports it. No change in behaviour. dox_auth now depends on dox_core.
3.0.0-alpha.7 #
- Perf:
attemptruns bcrypt in another isolate (Isolate.run). Before, each login blocked the server isolate for the whole hash. - Perf: the dummy hash for unknown users is made when the driver is created, in another isolate. Before, the first login paid for two hashes.
- New:
JwtAuthDriver(hashRounds: 10). Set it to the bcrypt cost of your stored hashes. - New:
JwtAuthDriver(userCacheTtl: ...). Keeps the user of a token in memory for this time, soverifyTokendoes not runfind(id)on every request. Off by default. - Security:
JwtAuthDriverthrowsArgumentErrorwhen theSecretKeyis empty. Before, an app with noAPP_KEYsigned tokens with an empty key, so anyone could make a token for any user. - Security:
attemptruns bcrypt also when no user is found, or when the user has no password. Before, an unknown email answered much faster than a wrong password, so the time told which emails have an account.
3.0.0-alpha.6 #
- Version bump only, to match the other packages.
3.0.0-alpha.5 #
- Breaking:
JwtAuthDriver.expiresInis 1 hour by default. Before, it wasnull, and tokens never expired. - New: named guards work. Use
Auth(guard: 'admin')andAuthMiddleware(guard: 'admin'). Before, onlydefaultGuardwas used. - A token keeps its guard name in the
audclaim. A token from one guard does not work on another guard. verifyTokenchecks theissclaim whenissueris set.- Breaking:
AuthDrivermethods get the guard name as a new parameter.AuthEngine().guard(name)replacesAuthEngine().driverandAuthEngine().provider.
3.0.0-alpha.4 #
- Version bump only, to match the other packages.
3.0.0-alpha.3 #
- Version bump only, to match the other packages.
3.0.0-alpha.2 #
- Needs Dart 3.13 or newer.
- All dependencies updated to their latest versions.
dart_jsonwebtoken3.4 (pointycastle4).
3.0.0-alpha.1 #
- Version 3 of Dox. All Dox packages now share one version.
- Needs Dart 3.6 or newer.
- See the release notes for all main changes.
- Uses
dox_orm(wasdox_query_builder). dart_jsonwebtoken3.
2.0.0 #
- Compatible for core version 2.0.
1.0.1 #
- Initial version.