Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-slack-ponycode

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-slack-ponycode

Slack authentication strategy for Passport.

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

passport-slack

Passport strategy for authenticating with Slack using the OAuth 2.0 API.

This module lets you authenticate using Slack in your Node.js applications. By plugging into Passport, Slack authentication can be easily integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-slack-ponycode

Usage

Configure Strategy

The Slack authentication strategy authenticates users using a Slack account and OAuth tokens. The strategy requires a verify callback, which receives the access token and corresponding secret as arguments, as well as user which contains the authenticated user's slack info. The verify callback must call done providing a user to complete authentication.

In order to identify your application to Slack, specify the clientID, clientSecret, and redirect URL within options. The client ID and secret are obtained by creating an application at Slacks's api site.

var SlackStrategy = require('./passport-slack').SlackStrategy;
passport.use( 'slack', new SlackStrategy({
    clientID: "[slack client id]",
    clientSecret:"[slack client secret]",
    callbackURL: "[host]/authenticate/callback",
    slackTeam: "[optional slack team id to force joining a team]"
}, function( token, tokenSecret, profile, done ){

    // This is your chance to find a User in your database.
    var User = neoteric.model('User');
    User.findBySlackId( profile.id, function( error, existingUser ){
        if( error ) return done( error, false );

        if( existingUser ){
            done( error, existingUser );
        }else{
            var newUser = new User();
            newUser.username = parsedBody.user;
            newUser.slackId = slackId;
            newUser.save( function( error, newUser ){
                done( error, newUser );
            });
        }
    });

}));
Authenticate Requests

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

For example, as route middleware in an Express application:

app.get('/auth/slack',
  passport.authenticate('slack'));

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

Credits

License

The MIT License

Copyright (c) 2014 Josh Kennedy <http://ponycode.com/>

Keywords

FAQs

Package last updated on 11 Sep 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