Releases: adonisjs/bouncer
Release 3.1.4
This release addresses missing dependencies needed for strict package managers like Yarn
and pnpm
.
We've also updated several development dependencies and automated the release process using GitHub Actions.
3.1.4 (2024-11-07)
Fix types to support async policy methods
Full Changelog: v3.1.2...v3.1.3
Do not cache policies when running in hot mode
- refactor: do not store policies in global cache in hot mode 123d662
- refactor: bypass policies cache when running in hot mode 82d7f4b
- chore: update dependencies 993ab43
Full Changelog: v3.1.1...v3.1.2
Fix configure command
Fix node ace configure @adonisjs/bouncer
which didnt @adonisjs/bouncer/commands
in Adonis RC file
Commits
- test: assertion for checking bouncer commands has been registered via configure deebe24
- Add commands to rcFile 658b71d
What's Changed
- Add commands to rcFile by @brunolipe-a in #12
New Contributors
- @brunolipe-a made their first contribution in #12
Full Changelog: v3.1.0...v3.1.1
Update i18n error identifier and JSONAPI error code
The error code for the JSONAPI response has been updated to E_AUTHORIZATION_FAILURE
. And the identifier for reading i18n messages has been updated to errors.E_AUTHORIZATION_FAILURE
Commits
- refactor: update error handler i18n message identifier and JSONAPI error code 4d3ec8b
- chore: update dependencies 676338d
Full Changelog: v3.0.0...v3.1.0
Stable major release
Please consult the following release to view list of breaking changes
- Breaking changes - https://github.com/adonisjs/bouncer/releases/tag/v3.0.0-0
Commits
- chore: publish under latest tag 03c0b70
- Merge pull request #11 from adonisjs/next dd143e1
- chore: bundle types.ts file via tsup as well b74f570
- refactor: export stubsRoot 5cca17f
- chore: update dependencies 42c90e3
What's Changed
- Merge to develop for final release by @thetutlage in #11
New Contributors
- @thetutlage made their first contribution in #11
Full Changelog: v2.3.0...v3.0.0
Auto register policy created via make:policy command to policies collection
- fix: convert import path to use unix slash 429435d
- refactor: upgrade configure hook to use latest APIs 528fbb0
- feat: auto register policy to policies list 44fbb51
- chore: update dependencies and use EmitterLike 5636804
Full Changelog: v3.0.0-1...v3.0.0-2
Improvements to configure package process
- feat: create initial policies and abilities files 2c0b82a
Full Changelog: v3.0.0-0...v3.0.0-1
First pre-release targeting v6
Breaking changes
- Package is now ESM only
- The
@ioc
prefixed imports have been removed.
- import Bouncer from '@ioc:Adonis/Addons/Bouncer'
+ import { Bouncer } from '@adonisjs/bouncer'
- import { BasePolicy } from '@ioc:Adonis/Addons/Bouncer'
+ import { BasePolicy } from '@adonisjs/bouncer'
- import { action } from '@ioc:Adonis/Addons/Bouncer'
+ import { action } from '@adonisjs/bouncer'
- Remove public property
bouncer.actions
in favor ofbouncer.abilities
. We get rid of theactions
keyword because it is generic and can be used in many different contexts, whereas abilities are more specific. - Remove
bouncer.BasePolicy
in favor of direct import.
- import { BasePolicy } from '@ioc:Adonis/Addons/Bouncer'
+ import { BasePolicy } from '@adonisjs/bouncer'
- Remove
bouncer.action
in favor of direct import.
- import { action } from '@ioc:Adonis/Addons/Bouncer'
+ import { action } from '@adonisjs/bouncer'
- Remove
bouncer.before
andbouncer.after
hooks. Use policies for hooks. - Remove the
bouncer.registerPolicies
method. Policies collection can be defined using a plain old JavaScript object.
- export const { policies } = Bouncer.registerPolicies({
- PostPolicy: () => import('App/Policies/PostPolicy')
- })
+ export const { policies } = {
+ PostPolicy: () => import('#policies/post_policy')
+ })
- The
Bouncer.deny
method now returns an instance of theAuthorizationResponse
class. Earlier, it used to return a tuple. However, the input arguments are still the same. - Remove method
resolvePolicy
. It was meant to be used internally anyway, but it is not needed anymore. E_AUTHORIZATION_FAILURE
is now self-handled and will convert itself to an HTTP response.- Remove methods
bouncer.can
andbouncer.cannot
. Instead, usebouncer.edgeHelpers.can
. Thebouncer.can
andbouncer.cannot
methods were used by Edge templates, so now they must be grabbed from theedgeHelpers
property.
- bouncer.can('PostPolicy.edit', new Post())
+ bouncer.edgeHelpers.can('PostPolicy.edit', new Post())
- bouncer.cannot('PostPolicy.edit', new Post())
+ bouncer.edgeHelpers.cannot('PostPolicy.edit', new Post())
Sharing abilities with Bouncer
In the old version, the abilities were called actions and were defined inside the start/bouncer.ts
file using the Bouncer.define
method.
In this latest release, we get rid of the keyword actions
and use abilities
. You may continue to define abilities using the Bouncer.define
method. However, you must update the initialize_bouncer_middleware
file and register them with Bouncer as follows.
import { abilities, policies } from '#start/bouncer'
Bouncer.create(
() => ctx.auth.user,
abilities,
policies
)
New features
- Use
@allowGuest
to allow a policy action to be executed for guest users. Earlier, you had to use the@action({ allowGuest: true })
decorator. Think of this new decorator as a shorthand alternative. - Bouncer now emits the
authorization:finished
event you may use to inspect the response of authorization checks. - You may now use translations for authorization error messages. Read the documentation to learn more.
- Policies can now inject dependencies inside the constructor that will be resolved using the IoC container.
Commits
- docs: add README file 44ca3be
- ci: skip edge compiler output tests on windows e47c0d3
- ci: update checks yaml file a58144c
- feat: add support for make:policy command 324002e
- refactor: accept ability options as first parameter 2cd6e43
- refactor: convert edgeHelpers method to edgeHelpers property 1070b91
- feat: abilities builder to be compatible with the old API eedc514
- refactor: rename Bouncer.define to Bouncer.ability fe350be
- refactor: make bouncer.policies and bouncer.abilities public 6e45c38
- feat: add configure command ed989c2
- feat: add provider 5eff877
- feat: add edge plugin for registering tags 506697d
- feat: add events 28ad309
- feat: implement policies hooks 9e28719
- feat: finish abilities and policies API b3ffcb1
- feat: implement bouncer actions 2567f6f
Full Changelog: v2.3.0...v3.0.0-0
Update dependencies
Full Changelog: v2.2.7...v2.3.0