diff --git a/lib/omniauth-slack.rb b/lib/omniauth-slack.rb new file mode 100644 index 0000000..8da1d60 --- /dev/null +++ b/lib/omniauth-slack.rb @@ -0,0 +1,2 @@ +require 'omniauth-slack/version' +require 'omniauth/strategies/slack' \ No newline at end of file diff --git a/lib/omniauth/slack/version.rb b/lib/omniauth-slack/version.rb similarity index 100% rename from lib/omniauth/slack/version.rb rename to lib/omniauth-slack/version.rb diff --git a/lib/omniauth/slack.rb b/lib/omniauth/slack.rb deleted file mode 100644 index fcbf487..0000000 --- a/lib/omniauth/slack.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "omniauth/slack/version" - -module Omniauth - module Slack - # Your code goes here... - end -end diff --git a/lib/omniauth/strategies/slack.rb b/lib/omniauth/strategies/slack.rb new file mode 100644 index 0000000..67d0d4e --- /dev/null +++ b/lib/omniauth/strategies/slack.rb @@ -0,0 +1,27 @@ +require 'omniauth/strategies/oauth2' + +module OmniAuth + module Strategies + class Slack < OmniAuth::Strategies::OAuth2 + + option :name, "slack" + + option :client_options, { + site: "https://slack.com", + token_url: "/api/oauth.access" + } + + option :auth_token_params, { + mode: :query, + param_name: 'token' + } + + extra do + { + 'members' => access_token.get('/api/users.list').parsed['members'] + } + end + + end + end +end \ No newline at end of file diff --git a/omniauth-slack.gemspec b/omniauth-slack.gemspec index 17603c9..8a0d0a1 100644 --- a/omniauth-slack.gemspec +++ b/omniauth-slack.gemspec @@ -1,16 +1,14 @@ # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'omniauth/slack/version' +require File.expand_path('../lib/omniauth-slack/version', __FILE__) Gem::Specification.new do |spec| spec.name = "omniauth-slack" spec.version = Omniauth::Slack::VERSION spec.authors = ["kimura"] spec.email = ["kimura@enigmo.co.jp"] - spec.description = %q{TODO: Write a gem description} - spec.summary = %q{TODO: Write a gem summary} - spec.homepage = "" + spec.description = %q{OmniAuth strategy for Slack} + spec.summary = %q{OmniAuth strategy for Slack} + spec.homepage = "https://github.com/kmrshntr/omniauth-slack.git" spec.license = "MIT" spec.files = `git ls-files`.split($/) @@ -18,6 +16,8 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] + spec.add_runtime_dependency 'omniauth-oauth2' "~> 1.1.2" + spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" end