incline 0.2.5 → 0.2.6

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: 065df6ffb292cb4efbfdbeeedb604e55f945d69c
4
- data.tar.gz: 23822bbc55ccad1a75bfa6cdbdaa1198f8aa30d4
3
+ metadata.gz: f31fe3757e3d195e25dd9154513c4b95fcfc22df
4
+ data.tar.gz: 66e93d328a2e53e716358e15f1aae7135444859c
5
5
  SHA512:
6
- metadata.gz: b84ed7084d1c1fe23e47d7ddc9db46d0488921dcff442aa5be93e96c112d744780c4eff804330e94c19bfcbf779fab8e077fd14d74b405a52197063cf1cf09da
7
- data.tar.gz: 64abec92b9d281e89daf05c4f93f9a83a5c979b9a407a74380a0bef69f6a75168273f80a98c9b39d6ca8255a60c51980ed8fe66935e11d34d6f034267f1e4519
6
+ metadata.gz: 117ffcbea8af8913b31e0c82292cc5a3dcc106c489a10d6c5521aaf6d066cd0bceeff284261b5d006a278be42a4c5e26210ec2fa5cce77a8a0de8c080c2f6320
7
+ data.tar.gz: 89c97c19037309d49ca8cc7816a3dfd8b306265e68288e8b8aa375397cf8de02ead1f5d63270685b705fc4180c99898d68325c664f2765de3c7699bb3052a036
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  log/*.log
3
3
  pkg/
4
4
  tmp/
5
+ .ssl/
5
6
  config/secrets.yml
6
7
  test/dummy/db/*.sqlite3
7
8
  test/dummy/db/*.sqlite3-journal
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incline (0.2.5)
4
+ incline (0.2.6)
5
5
  ansi (~> 1.5.0)
6
6
  bcrypt
7
7
  bootstrap-sass
@@ -12,6 +12,7 @@ module Incline
12
12
  ##
13
13
  # GET /incline/login
14
14
  def new
15
+
15
16
  end
16
17
 
17
18
  ##
@@ -16,6 +16,13 @@ module Incline
16
16
  def authenticate(email, password, client_ip)
17
17
  nil
18
18
  end
19
+
20
+ ##
21
+ # The begin_external_authentication method takes a request object to determine if it should process authentication or
22
+ # return nil. If it decides to process authentication, it should return a URL to redirect to.
23
+ def begin_external_authentication(request)
24
+ nil
25
+ end
19
26
 
20
27
  protected
21
28
 
@@ -284,6 +284,13 @@ module Incline::Extensions
284
284
 
285
285
  # an authenticated user must exist.
286
286
  unless logged_in?
287
+
288
+ if (auth_url = ::Incline::UserManager.begin_external_authentication(request))
289
+ ::Incline::Log.debug 'Redirecting for external authentication.'
290
+ redirect_to auth_url
291
+ return false
292
+ end
293
+
287
294
  store_location
288
295
 
289
296
  raise_not_logged_in "You need to login to access '#{request.fullpath}'.",
@@ -323,9 +330,9 @@ module Incline::Extensions
323
330
  end
324
331
 
325
332
  rescue ::Incline::NotAuthorized => err
326
-
327
333
  flash[:danger] = err.message
328
- redirect_to main_app.root_url and return false
334
+ redirect_to main_app.root_url
335
+ return false
329
336
  end
330
337
  true
331
338
 
@@ -108,20 +108,46 @@ module Incline
108
108
  nil
109
109
  end
110
110
 
111
+ ##
112
+ # The begin_external_authentication method takes a request object to determine if it should process authentication or
113
+ # return nil. If it decides to process authentication, it should return a URL to redirect to.
114
+ def begin_external_authentication(request)
115
+ # We don't have an email domain to work from.
116
+ # Instead, we'll call each engine's authenticate_external method.
117
+ # If one of them returns a user, then we return that value and skip further processing.
118
+ auth_engines.each do |dom,engine|
119
+ unless engine.nil?
120
+ url = engine.begin_external_authentication(request)
121
+ return url unless url.blank?
122
+ end
123
+ end
124
+ nil
125
+ end
126
+
111
127
  ##
112
128
  # Attempts to authenticate the user and returns the model on success.
113
129
  def self.authenticate(email, password, client_ip)
114
130
  default.authenticate email, password, client_ip
115
131
  end
116
132
 
133
+ ##
134
+ # The begin_external_authentication method takes a request object to determine if it should process authentication or
135
+ # return nil. If it decides to process authentication, it should return a URL to redirect to.
136
+ def self.begin_external_authentication(request)
137
+ default.begin_external_authentication request
138
+ end
139
+
117
140
  ##
118
141
  # Registers an authentication engine for one or more domains.
119
142
  #
120
143
  # The +engine+ passed in should take an options hash as the only argument to +initialize+
121
144
  # and should provide an +authenticate+ method that takes the +email+, +password+, and
122
- # +client_ip+.
145
+ # +client_ip+. You can optionally define an +authenticate_external+ method that takes the
146
+ # current +request+ as the only parameter.
123
147
  #
124
148
  # The +authenticate+ method of the engine should return an Incline::User object on success or nil on failure.
149
+ # The +begin_external_authentication+ method of the engine should return a URL to redirect to on success
150
+ # or nil on failure.
125
151
  #
126
152
  # class MyAuthEngine
127
153
  # def initialize(options = {})
@@ -131,6 +157,10 @@ module Incline
131
157
  # def authenticate(email, password, client_ip)
132
158
  # ...
133
159
  # end
160
+ #
161
+ # def begin_external_authentication(request)
162
+ # ...
163
+ # end
134
164
  # end
135
165
  #
136
166
  # Incline::UserManager.register_auth_engine(MyAuthEngine, 'example.com', 'example.net', 'example.org')
@@ -1,3 +1,3 @@
1
1
  module Incline
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -1 +1,3 @@
1
1
  <h1>Congrats, this is the DUMMY root.</h1>
2
+
3
+ <%= console if Rails.env.development? %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: incline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beau Barker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails