Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Daryl Rowland committed Aug 24, 2016
1 parent 139e9dc commit 68c06e2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,26 @@ var server = app.listen(process.env.PORT || '8080', function () {
});

```

## Authenticating Requests
You can mark routes in your JSON file as requiring authentication like this:
```javascript
...
"authRequired": true,
...
```

You must then provide an authenticator function to the CheeseToastie library that will run against authenticated requests and return either a user object or null (if the user is not logged in/their token is not valid).

```javascript
cheeseToastie.setAuthenticatorMethod(function(token, callback) {
// Silly example, normally you'd be decoding a JSON Web Token
if (token && token == "1234") {
return callback({name: "Daryl"});
}

return callback(null);
});

cheeseToastie.start(__dirname, app);
```

0 comments on commit 68c06e2

Please sign in to comment.