Package Exports
- @adonisjs/auth
- @adonisjs/auth/src/Auth/Manager
- @adonisjs/auth/src/Exceptions
- @adonisjs/auth/src/Middleware/AuthInit
- @adonisjs/auth/src/Schemes/Base
- @adonisjs/auth/src/Schemes/BaseToken
- @adonisjs/auth/src/Schemes/Jwt
- @adonisjs/auth/src/Serializers
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@adonisjs/auth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
AdonisJs Auth 🔒
Fully blown authentication provider for Adonis framework
Adonisjs auth is an authentication provider to add authentication layer to your apps.
What's in the box?
- Support for multiple authentication schemes like Jwt, Sessions, Basic auth and Personal API tokens.
- Support for Lucid and Database serializer.
- Easy to extend API to add your own serializers and schemes.
- Runtime middleware.
Installation
You can install the package from npm.
adonis install @adonisjs/authMake sure to read instructions.md file.
Node/OS Target
This repo/branch is supposed to run fine on all major OS platforms and targets Node.js >=7.0
Development
Great! If you are planning to contribute to the framework, make sure to adhere to following conventions, since a consistent code-base is always joy to work with.
Run the following command to see list of available npm scripts.
npm runTests & Linting
- Lint your code using standardJs. Run
npm run lintcommand to check if there are any linting errors. - Make sure you write tests for all the changes/bug fixes.
- Also you can write regression tests, which shows that something is failing but doesn't breaks the build. Which is actually a nice way to show that something fails. Regression tests are written using
test.failing()method. - Make sure all the tests are passing on
travisandappveyor.
General Practices
Since Es6 is in, you should strive to use latest features. For example:
- Use
Spreadoverargumentskeyword. - Never use
bindorcall. After calling these methods, we cannot guarantee the scope of any methods and in AdonisJs codebase we do not override the methods scope. - Make sure to write proper docblock.
Issues & PR
It is always helpful if we try to follow certain practices when creating issues or PR's, since it will save everyone's time.
- Always try creating regression tests when you find a bug (if possible).
- Share some context on what you are trying to do, with enough code to reproduce the issue.
- For general questions, please create a forum thread.
- When creating a PR for a feature, make sure to create a parallel PR for docs too.
Regression Tests
Regression tests are tests, which shows how a piece of code fails under certain circumstance, but the beauty is even after the failure, the test suite will never fail. Actually is a nice way to notify about bugs, but making sure everything is green.
The regression tests are created using
test.failing('2 + 2 is always 4, but add method returns 6', (assert) => {
assert.true(add(2, 2), 4)
})Now since the add method has a bug, it will return 6 instead of 4. But the build will pass.