incline 0.2.5 → 0.2.6
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/Gemfile.lock +1 -1
- data/app/controllers/incline/sessions_controller.rb +1 -0
- data/lib/incline/auth_engine_base.rb +7 -0
- data/lib/incline/extensions/action_controller_base.rb +9 -2
- data/lib/incline/user_manager.rb +31 -1
- data/lib/incline/version.rb +1 -1
- data/test/dummy/app/views/dummy/hello.html.erb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f31fe3757e3d195e25dd9154513c4b95fcfc22df
|
4
|
+
data.tar.gz: 66e93d328a2e53e716358e15f1aae7135444859c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 117ffcbea8af8913b31e0c82292cc5a3dcc106c489a10d6c5521aaf6d066cd0bceeff284261b5d006a278be42a4c5e26210ec2fa5cce77a8a0de8c080c2f6320
|
7
|
+
data.tar.gz: 89c97c19037309d49ca8cc7816a3dfd8b306265e68288e8b8aa375397cf8de02ead1f5d63270685b705fc4180c99898d68325c664f2765de3c7699bb3052a036
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
334
|
+
redirect_to main_app.root_url
|
335
|
+
return false
|
329
336
|
end
|
330
337
|
true
|
331
338
|
|
data/lib/incline/user_manager.rb
CHANGED
@@ -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')
|
data/lib/incline/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|