shutl_auth 0.8.1 → 0.8.2
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.
- data/Gemfile +4 -0
- data/config/license_finder.yml +20 -0
- data/doc/dependencies.csv +34 -0
- data/doc/dependencies.db +0 -0
- data/doc/dependencies.html +1298 -0
- data/lib/shutl/auth/access_token_request.rb +5 -1
- data/lib/shutl/auth/authenticated_request.rb +17 -3
- data/lib/shutl/auth/version.rb +1 -1
- data/lib/shutl_auth.rb +8 -0
- metadata +12 -2
@@ -13,7 +13,10 @@ module Shutl
|
|
13
13
|
c = client
|
14
14
|
|
15
15
|
Shutl::NetworkRetry.retry "Authentication Service Error" do
|
16
|
-
handling_exceptions
|
16
|
+
handling_exceptions do
|
17
|
+
Shutl::Auth.logger.debug "executing Rack::OAuth2::Client request"
|
18
|
+
c.access_token!
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
@@ -22,6 +25,7 @@ module Shutl
|
|
22
25
|
def handling_exceptions
|
23
26
|
yield
|
24
27
|
rescue Rack::OAuth2::Client::Error => e
|
28
|
+
Shutl::Auth.logger.error "Rack::OAuth2::Client::Error: #{e.message}"
|
25
29
|
case e.message
|
26
30
|
when /The client identifier provided is invalid, the client failed to authenticate, the client did not include its credentials, provided multiple client credentials, or used unsupported credentials type\./
|
27
31
|
raise_invalid_credentials
|
@@ -18,24 +18,38 @@ module Shutl
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def request_access_token
|
21
|
-
|
21
|
+
Shutl::Auth.logger.debug "request_access_token: in session? #{!!session[:access_token]}"
|
22
|
+
return read_token if read_token
|
22
23
|
|
24
|
+
Shutl::Auth.logger.debug "requesting new access token"
|
23
25
|
Shutl::Auth.access_token!
|
24
26
|
end
|
25
27
|
|
26
28
|
def access_token
|
27
|
-
|
29
|
+
return read_token if read_token
|
30
|
+
set_token request_access_token
|
28
31
|
end
|
29
32
|
|
30
33
|
def authenticated_request &blk
|
31
34
|
begin
|
32
35
|
yield
|
33
36
|
rescue Shutl::UnauthorizedAccess => e
|
34
|
-
|
37
|
+
Shutl::Auth.logger.debug "Shutl::UnauthorizedAccess - resetting access token"
|
38
|
+
set_token nil
|
35
39
|
access_token
|
36
40
|
yield
|
37
41
|
end
|
38
42
|
end
|
43
|
+
|
44
|
+
def read_token
|
45
|
+
Shutl::Auth.logger.debug "access token #{session[:access_token]}"
|
46
|
+
session[:access_token]
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_token(token)
|
50
|
+
Shutl::Auth.logger.debug "setting access token #{token}"
|
51
|
+
session[:access_token] = token
|
52
|
+
end
|
39
53
|
end
|
40
54
|
end
|
41
55
|
end
|
data/lib/shutl/auth/version.rb
CHANGED
data/lib/shutl_auth.rb
CHANGED
@@ -6,6 +6,8 @@ require "shutl/auth/version"
|
|
6
6
|
require "shutl/auth/access_token_request"
|
7
7
|
require "shutl/auth/authenticated_request"
|
8
8
|
|
9
|
+
require 'logger'
|
10
|
+
|
9
11
|
module Shutl
|
10
12
|
module Auth
|
11
13
|
extend self
|
@@ -15,5 +17,11 @@ module Shutl
|
|
15
17
|
def config
|
16
18
|
yield self
|
17
19
|
end
|
20
|
+
|
21
|
+
def logger
|
22
|
+
return ::Rails.logger if Kernel.const_defined?(:Rails)
|
23
|
+
return ::Shutl.logger if Shutl.respond_to? :logger
|
24
|
+
Logger.new('/dev/null')
|
25
|
+
end
|
18
26
|
end
|
19
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shutl_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: retriable
|
@@ -154,6 +154,10 @@ files:
|
|
154
154
|
- LICENSE.txt
|
155
155
|
- README.md
|
156
156
|
- Rakefile
|
157
|
+
- config/license_finder.yml
|
158
|
+
- doc/dependencies.csv
|
159
|
+
- doc/dependencies.db
|
160
|
+
- doc/dependencies.html
|
157
161
|
- lib/shutl/auth/access_token_request.rb
|
158
162
|
- lib/shutl/auth/authenticated_request.rb
|
159
163
|
- lib/shutl/auth/version.rb
|
@@ -178,12 +182,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
182
|
- - ! '>='
|
179
183
|
- !ruby/object:Gem::Version
|
180
184
|
version: '0'
|
185
|
+
segments:
|
186
|
+
- 0
|
187
|
+
hash: 1364072325301481292
|
181
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
189
|
none: false
|
183
190
|
requirements:
|
184
191
|
- - ! '>='
|
185
192
|
- !ruby/object:Gem::Version
|
186
193
|
version: '0'
|
194
|
+
segments:
|
195
|
+
- 0
|
196
|
+
hash: 1364072325301481292
|
187
197
|
requirements: []
|
188
198
|
rubyforge_project:
|
189
199
|
rubygems_version: 1.8.23
|