Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
badave committed Jan 10, 2013
1 parent 6986e76 commit b83d404
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions README.md
Expand Up @@ -11,34 +11,34 @@ Add to `dependencies`:

## Installing via npm

$ npm install authenticate
npm install authenticate

## Usage

var authenticate = require("authenticate");

app.use(authenticate.middleware({
encrypt_key: "", // Add any key for encrypting data
validate_key: "", // Add any key for signing data
// Paths that are required to be public by the API
publicPaths: {
"POST": {
loginPath: "/login",
registrationPath: "/register",
resetPasswordPath: "/resetpassword"
},
"PUT": {
changePasswordPath: "/changepassword"
}
}
}));
var authenticate = require("authenticate");

// Inside of app.configure
app.use(authenticate.middleware({
encrypt_key: "", // Add any key for encrypting data
validate_key: "", // Add any key for signing data
// Paths that are required to be public by the API
publicPaths: {
"POST": {
loginPath: "/login",
registrationPath: "/register",
resetPasswordPath: "/resetpassword"
},
"PUT": {
changePasswordPath: "/changepassword"
}
}
}));

## And then...

All paths not contained in publicPaths will require an access token. The access token can be passed to a frontend client after the client is authenticated via some form of login. For example, making a POST to /login with email and password, verifying email and password are correct, and then passing the access token to the client. Here is the JSON for an access token being passed to the client.

var authenticate = require("authenticate");

{
"access_token": authenticate.serializeToken(client_id, user_id)
}
var authenticate = require("authenticate");
{
"access_token": authenticate.serializeToken(client_id, user_id)
}

0 comments on commit b83d404

Please sign in to comment.