Skip to content

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Apr 3, 2013
1 parent e7b5e53 commit 2a483e8
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions README.md
Expand Up @@ -25,8 +25,8 @@ can range from verifying username and password credentials, delegated
authentication using [OAuth](http://oauth.net/) (for example, via [Facebook](http://www.facebook.com/) authentication using [OAuth](http://oauth.net/) (for example, via [Facebook](http://www.facebook.com/)
or [Twitter](http://twitter.com/)), or federated authentication using [OpenID](http://openid.net/). or [Twitter](http://twitter.com/)), or federated authentication using [OpenID](http://openid.net/).


Before asking passport to authenticate a request, the strategy (or strategies) Before authenticating requests, the strategy (or strategies) used by an
used by an application must be configured. application must be configured.


passport.use(new LocalStrategy( passport.use(new LocalStrategy(
function(username, password, done) { function(username, password, done) {
Expand All @@ -43,8 +43,8 @@ sessions to work, the authenticated user must be serialized to the session, and
deserialized when subsequent requests are made. deserialized when subsequent requests are made.


Passport does not impose any restrictions on how your user records are stored. Passport does not impose any restrictions on how your user records are stored.
Instead, you provide a function to Passport which implements the necessary Instead, you provide functions to Passport which implements the necessary
serialization and deserialization logic. In typical applications, this will be serialization and deserialization logic. In a typical application, this will be
as simple as serializing the user ID, and finding the user by ID when as simple as serializing the user ID, and finding the user by ID when
deserializing. deserializing.


Expand All @@ -58,30 +58,28 @@ deserializing.
}); });
}); });


#### Connect/Express Middleware #### Middleware


To use Passport in a [Connect](http://senchalabs.github.com/connect/) or To use Passport in an [Express](http://expressjs.com/) or
[Express](http://expressjs.com/)-based application, configure it with the [Connect](http://senchalabs.github.com/connect/)-based application, configure it
required `passport.initialize()` middleware. If your applications uses with the required `passport.initialize()` middleware. If your applications uses
persistent login sessions (recommended, but not required), `passport.session()` persistent login sessions (recommended, but not required), `passport.session()`
middleware must also be used. middleware must also be used.


app.configure(function() { app.configure(function() {
app.use(express.static(__dirname + '/../../public'));
app.use(express.cookieParser()); app.use(express.cookieParser());
app.use(express.bodyParser()); app.use(express.bodyParser());
app.use(express.session({ secret: 'keyboard cat' })); app.use(express.session({ secret: 'keyboard cat' }));
app.use(passport.initialize()); app.use(passport.initialize());
app.use(passport.session()); app.use(passport.session());
app.use(app.router); app.use(app.router);
app.use(express.static(__dirname + '/../../public'));
}); });


#### Authenticate Requests #### Authenticate Requests


Passport provides an `authenticate()` function (which is standard Passport provides an `authenticate()` function, which is used as route
Connect/Express middleware), which is utilized to authenticate requests. middleware to authenticate requests.

For example, it can be used as route middleware in an Express application:


app.post('/login', app.post('/login',
passport.authenticate('local', { failureRedirect: '/login' }), passport.authenticate('local', { failureRedirect: '/login' }),
Expand All @@ -92,7 +90,7 @@ For example, it can be used as route middleware in an Express application:
## Examples ## Examples


For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-local/tree/master/examples/login) For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-local/tree/master/examples/login)
included in [Passport-Local](https://github.com/jaredhanson/passport-local). included in [passport-local](https://github.com/jaredhanson/passport-local).


## Strategies ## Strategies


Expand Down

0 comments on commit 2a483e8

Please sign in to comment.