Passport strategies for authenticating with MediaWiki using OAuth 1.0a. Documentation and code shamelessly adapted from Jared Hanson's Passport-Google-OAuth.
This module lets you authenticate using MediaWiki in your Node.js applications. By plugging into Passport, MediaWiki authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install$ npm install passport-mediawiki-oauth
Usage of OAuth 1.0 Configure Strategy
The MediaWiki OAuth 1.0 authentication strategy authenticates users using a MediaWiki account and OAuth tokens. The strategy requires a verify
callback, which accepts these credentials and calls done
providing a user, as well as options
specifying a consumer key, consumer secret, and callback URL.
Authenticate Requestsvar MediaWikiStrategy = require('passport-mediawiki-oauth').OAuthStrategy;
Â
passport.use(new MediaWikiStrategy({
    consumerKey: MEDIAWIKI_CONSUMER_KEY,
    consumerSecret: MEDIAWIKI_CONSUMER_SECRET,
    callbackURL: MEDIAWIKI_CALLBACK_URL
  },
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ mediawikiGlobalId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));
Use passport.authenticate()
, specifying the 'mediawiki'
strategy, to authenticate requests.
For example, as route middleware in an Express application:
Examplesapp.get('/auth/mediawiki',
  passport.authenticate('mediawiki', { scope: MEDIAWIKI_AUTH_SCOPE }));
Â
app.get('/auth/mediawiki/callback',Â
  passport.authenticate('mediawiki', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });
For a complete, working example, refer to the OAuth 1.0 example. To get it up and running, you can do:
$ cd examples/oauth
$ npm install
$ node app.js
Tests
$ npm install --dev
$ make test
Credits
License
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4