New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cantina-auth-facebook

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cantina-auth-facebook

Facebook authentication for cantina

  • 4.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

cantina-auth-facebook

Facebook authentication for Cantina.

Dependencies

  • auth - Authentication support provided by cantina-auth

Adds Middleware

  • Facebook authentication middleware under the authURL route.

Configuration

  • successRedirect - Where to redirect after the authentication succeeds.
  • failureRedirect - Where to redirect if the authentication fails.
  • clientID - Facebook app client id.
  • clientSecret - Facebook app client secret.
  • callbackURL - Callback URL (publicly accessible) for authentication.
  • authURL - A path to initiation the authentication process.
  • scope - ?

Defaults

{
  'auth-facebook': {
    successRedirect: '/',
    failureRedirect: '/',
    authURL: '/login'
  }
}

Usage

Your application MUST provide handlers for serializing, deserializing, and verifying users.

  • app.serializeUser
  • app.deserializeUser
  • app.verifyFacebookUser

Example

var app = require('cantina').createApp();

app.boot(function(err) {
  if (err) return console.error(err);

  app.conf.add({
    'auth-facebook': {
      clientID: 'your id here',
      clientSecret: 'your secret here',
      callbackURL: 'http://mydomain.com/auth/facebook/callback',
      authURL: '/login/facebook',
      scope: 'email'
    }
  });

  app.serializeUser = function(user, cb) {
    return cb(null, user);
  };
  app.deserializeUser = function(obj, cb) {
    return cb(null, obj);
  };
  app.verifyFacebookUser = function(token, tokenSecret, profile, done) {
    return done(null, profile);
  };

  app.require('cantina-web');
  app.require('cantina-redis');
  app.require('cantina-session');
  app.require('cantina-auth');
  app.require('cantina-auth-facebook');

  app.start(function(err) {
    if (err) return console.error(err);

    app.middleware.get('/', function index(req, res) {
      res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
      if (req.isAuthenticated()) {
        res.end('Welcome, <a href="https://facebook.com/' + req.user.username + '">' + req.user.displayName + '</a>!');
      }
      else {
        res.end('<a href="/login/facebook">click here to login via Facebook</a>');
      }
    });
  });
});

Developed by Terra Eclipse

Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.

FAQs

Package last updated on 03 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc