Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
angular-reaccess
Advanced tools
AngularJS tools to customize users interfaces based on their rights on the REST API.
AngularJS tools to customize users interfaces based on their rights on the REST API.
See those slides to know more about the
reaccess
project principles.
Consider the following template:
<button
ng-show="'USER_ADD' | sfReaccess"
ng-click="addUser()">Add a user</button>
<div ng-repeat="user in users">
{{ user.name }}
<button
ng-show="'USER_EDIT' | sfReaccess:user"
ng-click="editUser(user)">Edit this user</button>
<button
ng-show="USER_DELETE' | sfReaccess:user"
ng-click="removeUser(user)">Delete this user</button>
</div>
It will display add/edit/delete buttons depending on the user rights comparing to the methods and pathes set for the given predefined rights.
Predefined rights are set in your application configuration like this:
angular.module('myApp')
.config(['sfReaccessServiceProvider', 'profileService', function(sfReaccessServiceProvider) {
// Setting templated rights
$sfReaccessServiceProvider.setPredefinedRights({
'USER_ADD': [{
path: '/users/:id',
methods: ['GET', 'POST']
}],
'USER_EDIT':[{
path: '/users/:id',
methods: ['PUT']
}],
'USER_DELETE': [{
path: '/users/:id',
methods: ['GET', 'DELETE']
}]
});
}]);
User rights are set by using the sfReaccessService.setRights()
method,
they look like this:
sfReaccessService.setRights([{
path: "/users/:_id/?.*",
methods: [
"OPTIONS",
"HEAD",
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
]
},{
path: "/organisations/:organisation_id/?.*",
methods: [
"OPTIONS",
"HEAD",
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
]
}]);
Path values are templated regular expressions. To set objects where to search
for template expressions values, use sfReaccessService.setValues()
:
sfReaccessService.setValues([{
_id: 1,
organisation_id: 1
}]);
You can enable sfReaccess debug mode globally:
angular.module('myApp')
.config(['sfReaccessServiceProvider', function(sfReaccessServiceProvider) {
// Set debug mode
$sfReaccessServiceProvider.debug(true);
}]);
Or locally as an argument to the angular filter:
<button
ng-show="'USER_ADD' | sfReaccess: undefined : true"
ng-click="addUser()">Add a user</button>
To contribute to this project, first run the following to setup the development environment:
npm install
bower install
Then, run the tests and debug with Karma:
npm run dev
If you use Express for your backend, you may be interested by the
express-reaccess
middleware.
FAQs
AngularJS tools to customize users interfaces based on their rights on the REST API.
We found that angular-reaccess demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.