omniauth-slack 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +79 -10
- data/lib/omniauth/strategies/slack.rb +15 -4
- data/lib/omniauth-slack/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b291a4ae7bb944ff8ca89710650f99ab928a2143
|
|
4
|
+
data.tar.gz: 7cc3ed52232e9a2fd8877e1f28c03ec833fca132
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c04b6dfc85fc63c4bdecca97783bdd8b514590b5b7adf76a2ec7c16e986660e3ff11ceb698deefedd2ee1236aaea715cb958574c7f660bb66ce0ad34655179d
|
|
7
|
+
data.tar.gz: 468d6b8e90e61be21dd9aed38cead230b9021347f73e1405d48daaff08b5c460edfbce23b58135402d6ce5acee0abf85ec34fbb2b48394fadb362db8c909f40a
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,24 +1,90 @@
|
|
|
1
1
|
# Omniauth::Slack
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This Gem contains the Slack strategy for OmniAuth.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Before You Begin
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
+
## Using This Strategy
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
First start by adding this gem to your Gemfile:
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'omniauth-slack'
|
|
19
|
+
```
|
|
20
20
|
|
|
21
|
-
|
|
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
|
+
[](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(
|
|
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
|
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:
|
|
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:
|
|
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.
|
|
91
|
+
rubygems_version: 2.2.2
|
|
92
92
|
signing_key:
|
|
93
93
|
specification_version: 4
|
|
94
94
|
summary: OmniAuth strategy for Slack
|