Giter VIP home page Giter VIP logo

omniauth-slack-openid.rb's Introduction

omniauth-slack-openid.rb

Gem Version Test Status codecov

An OmniAuth strategy for implementing Sign-in with Slack using OpenID Connect.

Official documentation: https://api.slack.com/authentication/sign-in-with-slack

Sponsored by Kisko Labs.

Install

Using Bundler:

bundle add omniauth-slack-openid

Using RubyGems:

gem install omniauth-slack-openid

Gemfile

gem 'omniauth-slack-openid'

Usage with Devise

Create Slack app and configure OAuth & Permissions to have the following Redirect URLs:

Copy Client ID and Client Secret to your environment (e.g. .env.local file):

SLACK_CLIENT_ID=1234567890.1234567890
SLACK_CLIENT_SECRET=1234567890abcdef1234567890abcdef

Add the following to your config/initializers/devise.rb:

  config.omniauth(
    :slack_openid,
    ENV.fetch("SLACK_CLIENT_ID"),
    ENV.fetch("SLACK_CLIENT_SECRET"),
    {
      scope: "openid,email,profile",
      redirect_uri: Rails.env.development? ? "https://localhost:3000/user/auth/slack_openid/callback" : nil,
      provider_ignores_state: Rails.env.development?
    }
  )

In order to test the callback in development, try logging in and then manually update URL to use http instead of https.

Generating uid

Gem has own generate_uid method that concatenates team_id and user_id, you can use it with custom parameters:

def resolve_user_session(team_id, user_id)
  uid = OmniAuth::Strategies::SlackOpenid.generate_uid(team_id, user_id)
  UserSession.find_by(uid: uid, provider: "slack-openid")
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/amkisko/omniauth-slack-openid.rb

Publishing

rm omniauth-slack-openid-*.gem
gem build omniauth-slack-openid.gemspec
gem push omniauth-slack-openid-*.gem

License

The gem is available as open source under the terms of the MIT License.

omniauth-slack-openid.rb's People

Contributors

amkisko avatar kwent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.