Skip to content

Commit

Permalink
docs(README): update authorization details
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanfoster committed Jul 13, 2016
1 parent 44c7c33 commit bd4e1cf
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class UserController extends parch.Controller {

## Authentication and Authorization [WIP]

Authentication and authorization is handled using [jwt](https://jwt.io/), with more
Authorization is handled using [jwt](https://jwt.io/), with more
options coming in the future. To disable auth for specific routes, use the
`authentication.unauthenticated` array. Empty by default, you can give a string
or regex expression to skip your unauthenticated routes
Expand All @@ -236,6 +236,25 @@ const parch = new parch.Application({
});
```

In order to authenticate a user, create and sign a JWT token to send back to the
client. The authorization middleware will then look for this token in the
`Authorization` header. [see jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)

```javascript
const jwt = require("jsonwebtoken");
const app = require("express")();

app.post("/login", function (req, res, next) {
const token = jwt.sign({ userId: 1 }, "secret");

res.send({ token });
});
```

```bash
curl http://my-server.com/protectedRoute -H 'Authorization: Bearer <token>'
```

## Static content

> TODO
Expand Down

0 comments on commit bd4e1cf

Please sign in to comment.