4.0.1 • Published 5 years ago

@trigo/atrix-acl v4.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Atrix ACL

Atrix plugin providing Access Control Lists to requests to specific routes.

Compatibility

atrix-acl >= 4.0.0 work with artix >= 6.0.0. For versin compatible with atrix < 6.0.0 checkouot v3 branch

Configuration

Sample Configuration:

acl: {
	aclDefinition: path.join(__dirname, './acls'),
	allowInject: true,
	tokenResourceAccessRoleKey: 'pathfinder-app',
	endpoints: [
		'^(?!(/alive|/reset))',
	],
}
  • aclDefinition - path to the aclDefinition file, should return a method which returns an array of ACLs
  • allowInject - allow hapi-inject routes, without applying ACLs
  • tokenResourceAccessRoleKey - name of the default app in the JWT-token
  • endpoints - endpoints which should be ignored

ACL Definitions

Example:

{	role: 'admin', path: '/*a', method: '*' }

Allow user with role admin to access all paths with all methods

{ role: 'editor1', path: '/pets/:petId', method: 'put' }

Allow user with role editor1 access to path /pets/:petId with PUT method

{ userId: '242', path: '/pets/123', method: 'get' }

Allow user with userId 242 access to specific resource path /pets/123 with GET method

{ userId: '242', transition: 'cancel:speaker', method: '*' }

Allow user with userId 242 to perform transition 'cancel:speaker'

{ userId: '242', transition: 'cancel:(*_)', method: '*' }

Allow user with userId 242 to perform any transition starting with 'cancel:'

The AtrixACL uses route-parser npm package, to test incoming paths against the defined routes (similar to Hapi route definition).

Rules / Token

The user role is extracted from the JWToken via the authorization header. The AtrixACL plugin assumes the following format of a token:

credentials: {
	preferred_username: "john.doe",
	email: "john.doe@test.com",
	name: "John Doe",
	resource_access: {
		voegb: { roles: ['admin'] },
		ak: { roles: ['admin'] },
		'pathfinder-app': { roles: ['super-admin'] },
	}
}

Given a configuration with the tokenResourceAccessRoleKey set to pathfinder-app, the AtrixACL uses this value as the default-role for the user (in the example above: 'super-admin')

If a x-pathfinder-tenant-ids header field is present, all the corresponding (tenant-specific) roles are extracted from the token and also tested agains the ACLs.

Requests

The AtrixACL plugin hooks into two handlers of the hapi request-lifecycle:

  • onPreHandler
  • onPreResponse

onPreHandler

The plugins checks if the current user/role has access to the requested route. If not, it returns status-code 401. The options allowInject and endpoints are taken into consideration.

onPreResponse

The plugins checks if a _links object is present in the response (or, if response-body is an array, in every item of the array) and manipulates the response-body. If present, every link/href in the hatr-links object is tested agains the ACLs and set to false, if the user/role has no access to a specific action/transition.

4.0.1

5 years ago

4.0.0-0

5 years ago

3.16.0

6 years ago

3.15.1

6 years ago

3.15.0

6 years ago

3.14.1

6 years ago

3.14.0

6 years ago

3.13.1

6 years ago

3.13.0

6 years ago

3.12.4

6 years ago

3.12.3

6 years ago

3.12.2

6 years ago

3.12.1

6 years ago

3.12.0

6 years ago

3.11.7

6 years ago

3.11.6

6 years ago

3.11.5

6 years ago

3.11.4

6 years ago

3.11.3

6 years ago

3.11.2

6 years ago

3.11.1

6 years ago

3.11.0

6 years ago

3.10.2

6 years ago

3.10.1

6 years ago

3.10.0

6 years ago

3.9.0

6 years ago

3.8.4

6 years ago

3.8.3

6 years ago

3.8.2

6 years ago

3.8.1

6 years ago

3.8.0

6 years ago

3.7.2

6 years ago

3.7.1

6 years ago

3.7.0

6 years ago

3.6.0

6 years ago

3.5.0

6 years ago

3.4.5

6 years ago

3.4.4

6 years ago

3.4.3

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago