You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love for you to contribute to CASL and help make it even better than it is
4
+
today! As a contributor, here are the guidelines I would like you to follow:
5
+
6
+
-[Question or Problem?](#question)
7
+
-[Issues and Bugs](#issue)
8
+
-[Feature Requests](#feature)
9
+
-[Submission Guidelines](#submit)
10
+
-[Coding Rules](#rules)
11
+
-[Commit Message Guidelines](#commit)
12
+
13
+
## <aname="question"></a> Got a Question or Problem?
14
+
15
+
Do not open issues for general support questions as I want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [gitter chat][gitter].
16
+
17
+
## <aname="issue"></a> Found a Bug?
18
+
If you find a bug in the source code, you can help by [submitting an issue](#submit-issue) or even better, you can [submit a Pull Request](#submit-pr) with a fix.
19
+
20
+
## <aname="feature"></a> Missing a Feature?
21
+
You can *request* a new feature by [submitting an issue](#submit-issue) to this GitHub Repository. If you would like to *implement* a new feature, please submit an issue with a proposal for your work first, to be sure that somebody else hasn't started to do the same.
22
+
23
+
## <aname="submit"></a> Submission Guidelines
24
+
25
+
### <aname="submit-issue"></a> Submitting an Issue
26
+
27
+
Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.
28
+
29
+
Please provide steps to reproduce for found bug (using http://plnkr.co or similar), this will help to understand and fix the issue faster.
30
+
31
+
### <aname="submit-pr"></a> Submitting a Pull Request (PR)
32
+
Before you submit your Pull Request (PR) consider the following guidelines:
33
+
34
+
* Search [GitHub](https://github.com/stalniy/casl/pulls) for an open or closed PR
35
+
that relates to your submission. You don't want to duplicate effort.
36
+
* Make your changes in a new git branch:
37
+
38
+
```sh
39
+
git checkout -b my-fix-branch master
40
+
```
41
+
42
+
***include appropriate test cases**.
43
+
* Follow defined [Coding Rules](#rules).
44
+
* Run all test suites `npm test`
45
+
* Commit your changes using a descriptive commit message that follows defined [commit message conventions](#commit). Adherence to these conventions is necessary because release notes are automatically generated from these messages.
46
+
* Push your branch to GitHub:
47
+
48
+
```shell
49
+
git push origin my-fix-branch
50
+
```
51
+
* In GitHub, send a pull request to `casl:master`.
52
+
* If somebody from project contributors suggest changes then:
53
+
* Make the required updates.
54
+
* Re-run all test suites to ensure tests are still passing.
55
+
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request). Basically you can use `git commit -a --amend` and `git push --force origin my-fix-branch`in order to keep single commit in the feature branch.
56
+
57
+
That's it! Thank you for your contribution!
58
+
59
+
## <a name="rules"></a> Coding Rules
60
+
To ensure consistency throughout the source code, keep these rules in mind as you are working:
61
+
62
+
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
63
+
* All public API methods **must be documented**.
64
+
* Project follows [Airbnb's JavaScript Style Guide][js-style-guide] with [some exceptions](.eslintrc). All these will be checked by Travis ci when you submit your PR
The project have very precise rules over how git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**. But also, git history is used to **generate the change log**.
69
+
70
+
The commit message format is borrowed from Angular projects and you can find [more details in this document][commit-message-format]
[](https://gitter.im/stalniy-casl/casl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
+
6
8
7
9
CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access. All permissions are defined in a single location (the `Ability` class) and not duplicated across controllers, views, and database queries.
* provides ES6 build, so you are able to shake out unused functionality
26
+
27
+
## Getting started
28
+
29
+
CASL allows you to use any data layer (e.g., `mongoose`, raw `mongodb` adapter, `sequalize`) and any HTTP framework (e.g., `koa`, `express`, `feathersjs`). It doesn't force you to choose even a database (however currently is the best integrated with MongoDB).
30
+
31
+
CASL concentrates all attention at what a user can actually do and allows to create abilities in DSL style. Lets see how
32
+
33
+
### 1. Define Abilities
34
+
35
+
Lets define `Ability` for a blog website where visitors:
36
+
* can read everything.
37
+
* can manage (i.e., create, update, delete, read) posts which were created by them
db.collection('posts').find(query) // find all Posts where author equals 'me'
89
+
db.close();
90
+
})
91
+
```
92
+
93
+
And if you use [mongoose](https://github.com/Automattic/mongoose), you are lucky because CASL provides mongoose middleware which hides all boilerplate under convenient `accessibleBy` method.
CASL is written in pure ES6 and has no dependencies on Node.js or other environments. That means you can use it on UI side. It may be useful if you need to show/hide some UI functionality based on what user can do in application.
0 commit comments