diff --git a/README.md b/README.md index 782a3ce..04973e6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#loopback-example-access-control +# loopback-example-access-control ``` $ git clone https://github.com/strongloop/loopback-example-access-control @@ -19,16 +19,16 @@ LoopBack. The application consists of four types of users: Each user type has permission to perform tasks based on their role and the application's ACL (access control list) entries. -##Prerequisites +## Prerequisites -###Tutorials +### Tutorials - [Getting started with LoopBack](http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack) - [Tutorial series - step 1](https://github.com/strongloop/loopback-example#step-one---the-basics) - [Tutorial series - step 2](https://github.com/strongloop/loopback-example#step-two---relations-and-filter) - [Tutorial series - step 3](https://github.com/strongloop/loopback-example#step-three---adding-application-logic) -###Knowledge +### Knowledge - [EJS](https://github.com/visionmedia/ejs) - [body-parser](https://github.com/expressjs/body-parser) @@ -36,11 +36,11 @@ application's ACL (access control list) entries. - [LoopBack models](http://docs.strongloop.com/display/LB/Defining+models) - [LoopBack adding application logic](http://docs.strongloop.com/display/LB/Adding+application+logic) -##Procedure +## Procedure -###Create the application +### Create the application -####Application information +#### Application information - Name: `loopback-example-access-control` - Directory to contain the project: `loopback-example-access-control` @@ -51,9 +51,9 @@ $ slc loopback loopback-example-access-control $ cd loopback-example-access-control ``` -###Add the models +### Add the models -####Model information +#### Model information - Name: `user` - Datasource: `db (memory)` - Base class: `User` @@ -94,7 +94,7 @@ $ slc loopback:model user ... # follow the prompts, repeat for `team` and `project` ``` -###Define the remote methods +### Define the remote methods Define three remote methods in [`project.js`](https://github.com/strongloop/loopback-example-access-control/blob/master/common/models/project.js): @@ -102,9 +102,9 @@ Define three remote methods in [`project.js`](https://github.com/strongloop/loop - [`donate`](https://github.com/strongloop/loopback-example-access-control/blob/master/common/models/project.js#L15-L31) - [`withdraw`](https://github.com/strongloop/loopback-example-access-control/blob/master/common/models/project.js#L33-54) -###Create the model relations +### Create the model relations -####Model relation information +#### Model relation information - `user` - has many @@ -128,7 +128,7 @@ Define three remote methods in [`project.js`](https://github.com/strongloop/loop - Property name for the relation: `user` - Custom foreign key: `ownerId` -###Add model instances +### Add model instances Create a boot script named [`sample-models.js`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/boot/sample-models.js). @@ -143,7 +143,7 @@ This script does the following: - [Creates a role named `admin` and adds a role mapping to make `Bob` an `admin`](/server/boot/sample-models.js#L50-L65) -###Configure server-side views +### Configure server-side views > LoopBack comes preconfigured with EJS out-of-box. This means we can use > server-side templating by simply setting the proper view engine and a @@ -160,7 +160,7 @@ Create [`index.ejs` in the views directory](https://github.com/strongloop/loopba [Configure `server.js`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/server.js#L11-L20) to use server-side templating. Remember to import the [`path`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/server.js#L4) package. -###Add routes +### Add routes Create [`routes.js`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/boot/routes.js). This script does the following: @@ -171,13 +171,13 @@ Create [`routes.js`](https://github.com/strongloop/loopback-example-access-contr > When you log in sucessfully, `projects.html` is rendered with the authenticated user's access token embedded into each link. -###Create the views +### Create the views Create the [`views` directory](https://github.com/strongloop/loopback-example-access-control/tree/master/server/views) to store views. In this directory, create [`index.ejs`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/views/index.ejs) and [`projects.ejs`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/views/projects.ejs). -###Create a role resolver +### Create a role resolver Create [`role-resolver.js`](https://github.com/strongloop/loopback-example-access-control/blob/master/server/boot/role-resolver.js). @@ -186,11 +186,11 @@ Create [`role-resolver.js`](https://github.com/strongloop/loopback-example-acces > denied. Otherwise, we check to see if the user is a team member and process > the request accordingly. -###Create ACL entries +### Create ACL entries > ACLs are used to restrict access to application REST endpoints. -####ACL information +#### ACL information - Deny access to all project REST endpoints - Select the model to apply the ACL entry to: `(all existing models)` @@ -236,9 +236,9 @@ $ slc loopback:acl # follow the prompts, repeat for each ACL listed above ``` -###Try the application +### Try the application -Start the server (`node .`) and open [`localhost:3000`][localhost] in your browser to view the app. You will see logins and explanations related to each user type we created: +Start the server (`node .`) and open [`localhost:3000`](http://localhost:3000) in your browser to view the app. You will see logins and explanations related to each user type we created: - Guest `Guest` - Role = $everyone, $unauthenticated