New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

adonis-imperium

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonis-imperium - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

7

package.json
{
"name": "adonis-imperium",
"version": "0.1.1",
"version": "0.1.2",
"description": "This package is an **authorization provider** built on top of [imperium](https://github.com/mono-js/imperium).",

@@ -19,3 +19,8 @@ "repository": {

"standard": "12.0.1"
},
"standard": {
"globals": [
"use"
]
}
}

@@ -115,9 +115,44 @@ # Adonis Imperium

```js
Route.get('/admin/posts', 'Admin/PostController.index')
Route.get('/posts', 'PostController.index')
.middleware(['auth', 'is:Admin'])
Route.get('/admin/posts', 'Admin/PostController.show')
.middleware(['auth', 'can:showPost'])
Route.put('/posts/:id', 'PostController.update')
.middleware(['auth', 'can:updatePost'])
```
You can also use AdonisJs resources:
```js
Route.resource('posts', 'PostController')
.only(['index', 'show', 'store', 'update', 'destroy']) // .apiOnly()
.middleware(new Map([
[['store', 'update', 'destroy'], ['auth']],
[['store'], ['can:storePost']],
[['update'], ['can:updatePost']],
[['destroy'], ['can:destroyPost']]
]))
.validator(new Map([
[['store'], ['StorePost']],
[['update'], ['UpdatePost']]
]))
```
### Config
In order to configure how the `can` middleware will process the route context (like in validators or controllers) you can define functions in `config/acl.js`:
```js
module.exports = {
updatePost: ({ params }) => ({ post: params.id }),
destroyPost: ({ params }) => ({ post: params.id }),
storePost: ({ params, request }) => {
const { type } = request.post()
return {
type
}
}
}
```
### API

@@ -124,0 +159,0 @@

2

src/Middleware/Can.js
'use strict'
/* global use */
const AuthorizationException = require('../Exceptions')

@@ -6,0 +4,0 @@

'use strict'
/* global use */
const Imperium = use('Imperium')

@@ -6,0 +4,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc