Skip to content

Commit

Permalink
Update protected route middleware docs
Browse files Browse the repository at this point in the history
- The stormpath middleware, stormpath.authenticationRequired, depends
  on cookie-parser being defined.  Cookie-parser will attach cookies
  from the request and attach them to the canonical req object in
  express.  This property is then used by the middelware to verify
  the authenticity of the user and properly secure the route.
- This commit provides additional requirements to users who are
  leveraging the authenticationRequired middleware

Closes stormpath#602
  • Loading branch information
oshalygin committed Feb 22, 2017
1 parent 80cf1a4 commit 18449f8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ Follow these steps to add Stormpath user authentication to your Express.js app.
//...
});
```

The `stormpath.authenticationRequired` middleware depends on the `cookie-parser` middleware, make sure that you are including the `cookie-parser` prior to all of your secured routes:

```javascript
var express = require('express');
var stormpath = require('express-stormpath');
var cookieParser = require('cookie-parser');

var app = express();

// Include the cookier-parser middleware prior to securing the route with 'stormpath.authenticationRequired'
app.use(cookieParser());
app.use(stormpath.init(application, stormpathConfiguration));


app.get('/secret', stormpath.authenticationRequired, function(req, res){
//...
});
```

For API services that use HTTP Basic Auth, use
`stormpath.apiAuthenticationRequired`:
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Change Log

All library changes, in descending order.

Version 3.2.1
-------------

- Updated documentation to reference cookie-parser dependency when using `stormpath.authenticationRequired` middleware

Version 3.2.0
-------------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-stormpath",
"version": "3.2.0",
"version": "3.2.1",
"description": "Build simple, secure web applications with Stormpath and Express!",
"keywords": [
"express",
Expand Down

0 comments on commit 18449f8

Please sign in to comment.