Skip to content

Releases: adonisjs/bouncer

Fix types to support async policy methods

24 May 09:10
Compare
Choose a tag to compare
  • fix: allow async policy actions at types level fa3ef8c
  • chore: update dependencies 2a2a85c

Full Changelog: v3.1.2...v3.1.3

Do not cache policies when running in hot mode

26 Apr 04:33
Compare
Choose a tag to compare
  • 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

25 Jan 20:52
Compare
Choose a tag to compare

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

New Contributors

Full Changelog: v3.1.0...v3.1.1

Update i18n error identifier and JSONAPI error code

22 Jan 14:21
Compare
Choose a tag to compare

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

09 Jan 11:17
dd143e1
Compare
Choose a tag to compare

Please consult the following release to view list of breaking changes

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

New Contributors

Full Changelog: v2.3.0...v3.0.0

Auto register policy created via make:policy command to policies collection

25 Dec 13:34
Compare
Choose a tag to compare
  • 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

05 Dec 16:01
Compare
Choose a tag to compare
  • feat: create initial policies and abilities files 2c0b82a

Full Changelog: v3.0.0-0...v3.0.0-1

First pre-release targeting v6

05 Dec 11:57
Compare
Choose a tag to compare
Pre-release

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 of bouncer.abilities. We get rid of the actions 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 and bouncer.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 the AuthorizationResponse 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 and bouncer.cannot . Instead, use bouncer.edgeHelpers.can. The bouncer.can and bouncer.cannot methods were used by Edge templates, so now they must be grabbed from the edgeHelpers 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

22 May 12:41
Compare
Choose a tag to compare
  • chore: update dependencies 9cb05c3
  • chore: update dependencies 583e3fd

Full Changelog: v2.2.7...v2.3.0

Update dependencies

08 Apr 12:08
Compare
Choose a tag to compare
  • chore: update dependencies 4fd7781
  • chore: update dependencies f0b61d5

v2.2.6...v2.2.7