omniauth-slack 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56fa690c9ed21986df0a47a898a9e384946e727d
4
- data.tar.gz: 5792269667716d39e2022f3e895fa04a7e1463be
3
+ metadata.gz: b291a4ae7bb944ff8ca89710650f99ab928a2143
4
+ data.tar.gz: 7cc3ed52232e9a2fd8877e1f28c03ec833fca132
5
5
  SHA512:
6
- metadata.gz: 1ab14ed8bd87c3a0d2ffdefce23977d8c564e7ac54c08ccc7570336e41b3705ed96f5d4730142cc74e2cad2fdbadccc876e41e74e1de32ea7a23c18a16558c5d
7
- data.tar.gz: 1d4954fbc14dfe249020306288afd937eedad65a5f159517e818eb7bb6bd77a2353c7e58f7e5d5b3615b16fc981f1cd35cbadc659e8b3424e4b151be3f71bc13
6
+ metadata.gz: 8c04b6dfc85fc63c4bdecca97783bdd8b514590b5b7adf76a2ec7c16e986660e3ff11ceb698deefedd2ee1236aaea715cb958574c7f660bb66ce0ad34655179d
7
+ data.tar.gz: 468d6b8e90e61be21dd9aed38cead230b9021347f73e1405d48daaff08b5c460edfbce23b58135402d6ce5acee0abf85ec34fbb2b48394fadb362db8c909f40a
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea/
data/README.md CHANGED
@@ -1,24 +1,90 @@
1
1
  # Omniauth::Slack
2
2
 
3
- TODO: Write a gem description
3
+ This Gem contains the Slack strategy for OmniAuth.
4
4
 
5
- ## Installation
5
+ ## Before You Begin
6
6
 
7
- Add this line to your application's Gemfile:
7
+ You should have already installed OmniAuth into your app; if not, read the [OmniAuth README](https://github.com/intridea/omniauth) to get started.
8
8
 
9
- gem 'omniauth-slack'
10
9
 
11
- And then execute:
10
+ Now sign into the [Slack application dashboard](https://api.slack.com/applications) and create an application. Take note of your API keys.
12
11
 
13
- $ bundle
14
12
 
15
- Or install it yourself as:
13
+ ## Using This Strategy
16
14
 
17
- $ gem install omniauth-slack
15
+ First start by adding this gem to your Gemfile:
18
16
 
19
- ## Usage
17
+ ```ruby
18
+ gem 'omniauth-slack'
19
+ ```
20
20
 
21
- TODO: Write usage instructions here
21
+ If you need to use the latest HEAD version, you can do so with:
22
+
23
+ ```ruby
24
+ gem 'omniauth-slack', github: 'kmrshntr/omniauth-slack'
25
+ ```
26
+
27
+ Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
28
+
29
+ ```ruby
30
+ Rails.application.config.middleware.use OmniAuth::Builder do
31
+ provider :slack, "API_KEY", "API_SECRET", scope: "client"
32
+ end
33
+ ```
34
+
35
+ Replace `"API_KEY"` and `"API_SECRET"` with the appropriate values you obtained [earlier](https://api.slack.com/applications).
36
+
37
+ If you are using [Devise](https://github.com/plataformatec/devise) then it will look like this:
38
+
39
+ ```ruby
40
+ Devise.setup do |config|
41
+ # other stuff...
42
+
43
+ config.omniauth :slack, ENV["SLACK_APP_ID"], ENV["SLACK_APP_SECRET"], scope: 'client'
44
+
45
+ # other stuff...
46
+ end
47
+ ```
48
+
49
+ Slack lets you choose from a [few different scopes](https://api.slack.com/docs/oauth#auth_scopes).
50
+
51
+
52
+ ## Authentication Options
53
+
54
+ ### State
55
+
56
+ > *unique string to be passed back upon completion*
57
+
58
+ > The state parameter should be used to avoid forgery attacks by passing in a value that's unique to the user you're authenticating and checking it when auth completes.
59
+
60
+ for a logged in user, you might want to include state, for example with devise:
61
+
62
+ `https://www.yourapp.com/users/auth/slack?state=1234-foobutter`
63
+
64
+ creates an auth session with `state`
65
+
66
+ After a successful auth, the callback request will include `request.env["omniauth.params"]` hash
67
+
68
+ ```ruby
69
+ class CallbackController < ApplicationController
70
+ def slack
71
+ request.env["omniauth.params"]["state"]
72
+ # => "1234-foobutter"
73
+ end
74
+ end
75
+ ```
76
+
77
+ ### Team
78
+
79
+ > If you don't pass a team param, the user will be allowed to choose which team they are authenticating against. Passing this param ensures the user will auth against an account on that particular team.
80
+
81
+ If you need to ensure that the users use the team whose team_id is 'XXXXXXXX', you can do so by passing `:team` option in your `config/initializers/omniauth.rb` like this:
82
+
83
+ ```ruby
84
+ Rails.application.config.middleware.use OmniAuth::Builder do
85
+ provider :slack, "API_KEY", "API_SECRET", scope: "identify,read,post", team: 'XXXXXXXX'
86
+ end
87
+ ```
22
88
 
23
89
  ## Contributing
24
90
 
@@ -27,3 +93,6 @@ TODO: Write usage instructions here
27
93
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
94
  4. Push to the branch (`git push origin my-new-feature`)
29
95
  5. Create new Pull Request
96
+
97
+
98
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kmrshntr/omniauth-slack/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -6,7 +6,7 @@ module OmniAuth
6
6
 
7
7
  option :name, "slack"
8
8
 
9
- option :authorize_options, [ :scope, :team ]
9
+ option :authorize_options, [ :scope, :team ]
10
10
 
11
11
  option :client_options, {
12
12
  site: "https://slack.com",
@@ -22,6 +22,13 @@ module OmniAuth
22
22
 
23
23
  info do
24
24
  {
25
+ name: user_info['user']['profile']['real_name_normalized'],
26
+ email: user_info['user']['profile']['email'],
27
+ nickname: raw_info['user'],
28
+ first_name: user_info['user']['profile']['first_name'],
29
+ last_name: user_info['user']['profile']['last_name'],
30
+ description: user_info['user']['profile']['title'],
31
+ image: user_info['user']['profile']['image_192'],
25
32
  team: raw_info['team'],
26
33
  user: raw_info['user'],
27
34
  team_id: raw_info['team_id'],
@@ -30,13 +37,17 @@ module OmniAuth
30
37
  end
31
38
 
32
39
  extra do
33
- {:raw_info => raw_info}
40
+ {:raw_info => raw_info, :user_info => user_info}
41
+ end
42
+
43
+ def user_info
44
+ @user_info ||= access_token.get("/api/users.info?user=#{raw_info['user_id']}").parsed
34
45
  end
35
46
 
36
47
  def raw_info
37
- @raw_info ||= access_token.get('/api/auth.test').parsed
48
+ @raw_info ||= access_token.get("/api/auth.test").parsed
38
49
  end
39
50
 
40
51
  end
41
52
  end
42
- end
53
+ end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Slack
3
- VERSION = "1.0.1"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kimura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-24 00:00:00.000000000 Z
11
+ date: 2015-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.4.1
91
+ rubygems_version: 2.2.2
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: OmniAuth strategy for Slack