gds-sso 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module GDS
2
2
  module SSO
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
@@ -1,6 +1,13 @@
1
1
  require 'warden'
2
2
  require 'gds-sso/user'
3
3
 
4
+ def logger
5
+ if Rails.logger # if we are actually running in a rails app
6
+ Rails.logger
7
+ else
8
+ env['rack.logger']
9
+ end
10
+ end
4
11
 
5
12
  Warden::Manager.after_authentication do |user, auth, opts|
6
13
  # We've successfully signed in.
@@ -32,7 +39,7 @@ Warden::Strategies.add(:gds_sso) do
32
39
  end
33
40
 
34
41
  def authenticate!
35
- Rails.logger.debug("Authenticating with gds_sso strategy")
42
+ logger.debug("Authenticating with gds_sso strategy")
36
43
 
37
44
  if request.env['omniauth.auth'].nil?
38
45
  fail!("No credentials, bub")
@@ -58,7 +65,7 @@ Warden::Strategies.add(:gds_bearer_token) do
58
65
  end
59
66
 
60
67
  def authenticate!
61
- Rails.logger.debug("Authenticating with gds_bearer_token strategy")
68
+ logger.debug("Authenticating with gds_bearer_token strategy")
62
69
 
63
70
  begin
64
71
  access_token = OAuth2::AccessToken.new(oauth_client, token_from_authorization_header)
@@ -137,7 +144,7 @@ Warden::Strategies.add(:gds_sso_api_access) do
137
144
  end
138
145
 
139
146
  def authenticate!
140
- Rails.logger.debug("Authenticating with gds_sso_api_access strategy")
147
+ logger.debug("Authenticating with gds_sso_api_access strategy")
141
148
 
142
149
  auth = Rack::Auth::Basic::Request.new(env)
143
150
 
@@ -177,7 +184,7 @@ Warden::Strategies.add(:mock_gds_sso) do
177
184
  end
178
185
 
179
186
  def authenticate!
180
- Rails.logger.warn("Authenticating with mock_gds_sso strategy")
187
+ logger.warn("Authenticating with mock_gds_sso strategy")
181
188
 
182
189
  test_user = GDS::SSO.test_user
183
190
  test_user ||= ENV['GDS_SSO_MOCK_INVALID'].present? ? nil : GDS::SSO::Config.user_klass.first
@@ -204,7 +211,7 @@ Warden::Strategies.add(:mock_gds_sso_api_access) do
204
211
  end
205
212
 
206
213
  def authenticate!
207
- Rails.logger.debug("Authenticating with mock_gds_sso_api_access strategy")
214
+ logger.debug("Authenticating with mock_gds_sso_api_access strategy")
208
215
  success!(GDS::SSO::ApiUser.new)
209
216
  end
210
217
  end