ginjo-omniauth-slack 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +19 -2
- data/lib/omniauth-slack/version.rb +1 -1
- data/lib/omniauth/strategies/slack.rb +43 -26
- data/omniauth-slack.gemspec +3 -3
- data/test/helper.rb +1 -0
- data/test/support/shared_examples.rb +10 -0
- data/test/test.rb +4 -0
- metadata +9 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3ff842e9cfab56ecf724517abbf5c5b11dcf342
|
4
|
+
data.tar.gz: eb8b4443126f1544eaf1b73580785a23dcd87512
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d99aca16201b6367f87df3989e9c06b928ea7be002faaa9734ae52021a53d9473a238c85afe39a194c18775baefaa455bbdb1c6fe5d7c58c62643164707e9641
|
7
|
+
data.tar.gz: cebc21d494e97c0a44dacdf428762630e4d2a9f48eb14f09fa38fb7990106d2bb204921276be3f33102d167d0d582cf8f7d43ddb6661270f8d33cb80c89d4850
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,24 @@
|
|
1
|
-
## v2.4.
|
1
|
+
## v2.4.1(2018-09-18)
|
2
|
+
|
3
|
+
* Set `client_options[:auth_scheme]` to `:basic_auth`, as OAuth2 gem does not yet make this the default. [wbr]
|
4
|
+
|
5
|
+
* Stop using `:setup` option to manipulate site uri subdomain. [wbr]
|
6
|
+
|
7
|
+
* Override `client` method to manipulate site uri subdomain. [wbr]
|
8
|
+
|
9
|
+
* Allow `apps.permissions.users.list` call to be excluded by user. [wbr]
|
10
|
+
|
11
|
+
* Fix gemspec dep for omniauth-oauth2. [wbr]
|
12
|
+
|
13
|
+
* Add experimental class method `ad_hoc_client`. [wbr]
|
14
|
+
|
15
|
+
|
16
|
+
## v2.4.0 (2018-08-28)
|
2
17
|
|
3
18
|
Initial release of ginjo-omniauth-slack
|
4
19
|
|
20
|
+
* Update gemspec dependencies.
|
21
|
+
|
5
22
|
* Add/fix AuthHash `extra['scopes_requested']`. [wbr]
|
6
23
|
|
7
24
|
* Refactor building of AuthHash to dynamically call additional API requests if necessary, scope permitting. [wbr]
|
@@ -35,7 +52,7 @@ Initial release of ginjo-omniauth-slack
|
|
35
52
|
* Add test coverage for new functionality. [wbr]
|
36
53
|
|
37
54
|
|
38
|
-
### Additional changes logged between 2.
|
55
|
+
### Additional changes logged between 2.3.0 release and ginjo fork/refactor
|
39
56
|
|
40
57
|
The specifics of these commits may or may not be relevant in the ginjo fork, but their functionality is covered in one way or another.
|
41
58
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'omniauth/strategies/oauth2'
|
2
2
|
require 'thread'
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
module OmniAuth
|
5
6
|
module Strategies
|
@@ -11,17 +12,8 @@ module OmniAuth
|
|
11
12
|
|
12
13
|
option :client_options, {
|
13
14
|
site: 'https://slack.com',
|
14
|
-
token_url: '/api/oauth.access'
|
15
|
-
|
16
|
-
|
17
|
-
# Add team_domain to site subdomain if provided in auth url or provider options.
|
18
|
-
option :setup, lambda{|env|
|
19
|
-
strategy = env['omniauth.strategy']
|
20
|
-
team_domain = strategy.request.params['team_domain'] || strategy.options[:team_domain]
|
21
|
-
site = strategy.options[:client_options]['site']
|
22
|
-
strategy.options[:client_options].site = (
|
23
|
-
!team_domain.to_s.empty? ? site.sub(/\:\\\\/, "://#{team_domain}.") : site
|
24
|
-
)
|
15
|
+
token_url: '/api/oauth.access',
|
16
|
+
auth_scheme: :basic_auth
|
25
17
|
}
|
26
18
|
|
27
19
|
option :auth_token_params, {
|
@@ -51,10 +43,14 @@ module OmniAuth
|
|
51
43
|
end
|
52
44
|
|
53
45
|
info do
|
54
|
-
|
55
|
-
|
46
|
+
|
47
|
+
unless skip_info?
|
48
|
+
define_additional_data
|
49
|
+
semaphore
|
50
|
+
end
|
56
51
|
|
57
52
|
num_threads = options.preload_data_with_threads.to_i
|
53
|
+
|
58
54
|
if num_threads > 0 && !skip_info?
|
59
55
|
preload_data_with_threads(num_threads)
|
60
56
|
end
|
@@ -147,6 +143,7 @@ module OmniAuth
|
|
147
143
|
raw_info: @raw_info
|
148
144
|
}
|
149
145
|
end
|
146
|
+
|
150
147
|
|
151
148
|
# Pass on certain authorize_params to the Slack authorization GET request.
|
152
149
|
# See https://github.com/omniauth/omniauth/issues/390
|
@@ -157,29 +154,37 @@ module OmniAuth
|
|
157
154
|
params[v.to_sym] = request.params[v]
|
158
155
|
end
|
159
156
|
end
|
157
|
+
log(:debug, "Authorize_params #{params.to_h}")
|
160
158
|
end
|
161
159
|
end
|
162
160
|
|
163
|
-
# Get a new OAuth2::Client and define custom
|
164
|
-
# *
|
161
|
+
# Get a new OAuth2::Client and define custom behavior.
|
162
|
+
# * overrides previous omniauth-strategies-oauth2 :client definition.
|
165
163
|
#
|
166
164
|
# * Log API requests with OmniAuth.logger
|
167
165
|
# * Add API responses to @raw_info hash
|
166
|
+
# * Set auth site uri with custom subdomain (if provided).
|
168
167
|
#
|
169
168
|
def client
|
170
|
-
st_raw_info = raw_info
|
171
169
|
new_client = super
|
172
|
-
log(:debug, "New client #{new_client}.")
|
173
170
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
171
|
+
team_domain = request.params['team_domain'] || options[:team_domain]
|
172
|
+
if !team_domain.to_s.empty?
|
173
|
+
site_uri = URI.parse(options[:client_options]['site'])
|
174
|
+
site_uri.host = "#{team_domain}.slack.com"
|
175
|
+
new_client.site = site_uri.to_s
|
176
|
+
log(:debug, "Oauth site uri with custom team_domain #{site_uri}")
|
177
|
+
end
|
178
|
+
|
179
|
+
st_raw_info = raw_info
|
180
|
+
new_client.define_singleton_method(:request) do |*args|
|
181
|
+
OmniAuth.logger.send(:debug, "(slack) API request #{args[0..1]}; in thread #{Thread.current.object_id}.")
|
182
|
+
request_output = super(*args)
|
183
|
+
uri = args[1].to_s.gsub(/^.*\/([^\/]+)/, '\1') # use single-quote or double-back-slash for replacement.
|
184
|
+
st_raw_info[uri.to_s]= request_output
|
185
|
+
request_output
|
182
186
|
end
|
187
|
+
|
183
188
|
new_client
|
184
189
|
end
|
185
190
|
|
@@ -342,7 +347,7 @@ module OmniAuth
|
|
342
347
|
#
|
343
348
|
# Returns [<id>: <resource>]
|
344
349
|
def apps_permissions_users_list
|
345
|
-
return {} unless !skip_info? && is_app_token?
|
350
|
+
return {} unless !skip_info? && is_app_token? && is_not_excluded?
|
346
351
|
semaphore.synchronize {
|
347
352
|
@apps_permissions_users_list_raw ||= access_token.get('/api/apps.permissions.users.list')
|
348
353
|
@apps_permissions_users_list ||= @apps_permissions_users_list_raw.parsed['resources'].inject({}){|h,i| h[i['id']] = i; h}
|
@@ -388,6 +393,18 @@ module OmniAuth
|
|
388
393
|
end
|
389
394
|
end
|
390
395
|
|
396
|
+
def self.ad_hoc_client(client_id, client_key, token)
|
397
|
+
puts default_options['client_options'].to_yaml
|
398
|
+
::OAuth2::AccessToken.new(
|
399
|
+
::OAuth2::Client.new(
|
400
|
+
client_id,
|
401
|
+
client_key,
|
402
|
+
default_options['client_options'].map{|k,v| [k.to_sym, v]}.to_h
|
403
|
+
),
|
404
|
+
token
|
405
|
+
)
|
406
|
+
end
|
407
|
+
|
391
408
|
end
|
392
409
|
end
|
393
410
|
end
|
data/omniauth-slack.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.authors = ['kimura', 'ginjo']
|
8
8
|
spec.email = ['kimura@enigmo.co.jp', 'wbr@mac.com']
|
9
9
|
spec.description = %q{OmniAuth strategy for Slack}
|
10
|
-
spec.summary = %q{OmniAuth strategy for Slack, based on
|
11
|
-
spec.homepage = 'https://github.com/
|
10
|
+
spec.summary = %q{OmniAuth strategy for Slack, based on OAuth2 and OmniAuth}
|
11
|
+
spec.homepage = 'https://github.com/ginjo/omniauth-slack.git'
|
12
12
|
spec.license = 'MIT'
|
13
13
|
|
14
14
|
spec.files = `git ls-files`.split($/)
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
|
-
spec.add_runtime_dependency 'omniauth-oauth2',
|
19
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '>= 1.4.0'
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '>= 1.11.2'
|
22
22
|
spec.add_development_dependency 'rake'
|
data/test/helper.rb
CHANGED
@@ -16,6 +16,16 @@ module OAuth2StrategyTests
|
|
16
16
|
@options = { :client_options => { "authorize_url" => "https://example.com" } }
|
17
17
|
assert_equal "https://example.com", strategy.client.options[:authorize_url]
|
18
18
|
end
|
19
|
+
|
20
|
+
test "should transfer team_domain from options to client.site uri" do
|
21
|
+
@options = { :team_domain => 'subdomain' }
|
22
|
+
assert_equal "https://subdomain.slack.com", strategy.client.site
|
23
|
+
end
|
24
|
+
|
25
|
+
test "should transfer team_domain from request.params to client.site uri" do
|
26
|
+
@request.stubs(:params).returns({ 'team_domain' => 'subdomain2' })
|
27
|
+
assert_equal "https://subdomain2.slack.com", strategy.client.site
|
28
|
+
end
|
19
29
|
end
|
20
30
|
|
21
31
|
module AuthorizeParamsTests
|
data/test/test.rb
CHANGED
@@ -19,6 +19,10 @@ class ClientTest < StrategyTestCase
|
|
19
19
|
test "has correct token url" do
|
20
20
|
assert_equal "/api/oauth.access", strategy.client.options[:token_url]
|
21
21
|
end
|
22
|
+
|
23
|
+
test "has correct auth_scheme" do
|
24
|
+
assert_equal :basic_auth, strategy.client.options[:auth_scheme]
|
25
|
+
end
|
22
26
|
|
23
27
|
test 'request logs api call' do
|
24
28
|
OAuth2::Client.class_eval do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ginjo-omniauth-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kimura
|
@@ -9,28 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth2
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.4'
|
21
|
-
- - "~>"
|
18
|
+
- - ">="
|
22
19
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
20
|
+
version: 1.4.0
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
|
-
- - "
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '1.4'
|
31
|
-
- - "~>"
|
25
|
+
- - ">="
|
32
26
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
27
|
+
version: 1.4.0
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: bundler
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +102,7 @@ files:
|
|
108
102
|
- test/helper.rb
|
109
103
|
- test/support/shared_examples.rb
|
110
104
|
- test/test.rb
|
111
|
-
homepage: https://github.com/
|
105
|
+
homepage: https://github.com/ginjo/omniauth-slack.git
|
112
106
|
licenses:
|
113
107
|
- MIT
|
114
108
|
metadata: {}
|
@@ -128,10 +122,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
122
|
version: '0'
|
129
123
|
requirements: []
|
130
124
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.2.2
|
132
126
|
signing_key:
|
133
127
|
specification_version: 4
|
134
|
-
summary: OmniAuth strategy for Slack, based on
|
128
|
+
summary: OmniAuth strategy for Slack, based on OAuth2 and OmniAuth
|
135
129
|
test_files:
|
136
130
|
- test/helper.rb
|
137
131
|
- test/support/shared_examples.rb
|