Skip to content

fatherabraham-hms/passport-avalon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Passport-Avalon

Node.js passport connector for Avalon OAuth servers, based on mjpearson's wordpress passport connector.

Passport strategy for authenticating with Avalon Federated Login using the OAuth 2.0 API.

Install

$ npm install passport-avalon

Usage

Configure Strategy

The Avalon authentication strategy authenticates users using an Avalon login account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a client ID, client secret, and callback URL.

passport.use(new AvalonStrategy({
    clientID: CLIENT_ID,
    clientSecret: CLIENT_SECRET
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ AvalonId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authorize(), specifying the 'Avalon' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/avalon',
  passport.authorize('avalon'));

app.get('/auth/avalon/callback', 
  passport.authorize('avalon', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Thanks

License

The MIT License

Copyright (c) 2014 Avalon Consulting LLC

About

Node.js passport connector for Avalon OAuth servers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published