devise_auth_proxy 0.1.15 → 0.1.20
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/Gemfile.lock +1 -1
- data/lib/devise_auth_proxy.rb +5 -2
- data/lib/devise_auth_proxy/helper.rb +17 -0
- data/lib/devise_auth_proxy/manager.rb +13 -7
- data/lib/devise_auth_proxy/model.rb +0 -1
- data/lib/devise_auth_proxy/strategy.rb +6 -2
- data/lib/devise_auth_proxy/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b0861fe8d5e53bd761613539ff5633242f7be6628bdf9d0e27eec971dbe2b1
|
4
|
+
data.tar.gz: a2c0f4aea50cab2071125bed3b8835eba0beef844d95c26aca0ef6f84b39c385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9c1db28587c5ece2ecfc377d9d808cb6aa3211db6e8bc48bfa11d5db973901802c783c0ccc0bf8afdbb3a36c64181ef05d04fe13c044ae971041dbb47fbacb
|
7
|
+
data.tar.gz: 43a767a92a0e99b2cafecc68d74e9197266dcb03fab60e174a901a5574d13a49c2fce0328fab88878155c51f07c630f359d092ea630173d06437bcab5a5b86aa
|
data/Gemfile.lock
CHANGED
data/lib/devise_auth_proxy.rb
CHANGED
@@ -3,7 +3,7 @@ require 'devise_auth_proxy/version'
|
|
3
3
|
|
4
4
|
module DeviseAuthProxy
|
5
5
|
class << self
|
6
|
-
attr_accessor :env_key, :auto_create, :auto_update, :auth_key, :attribute_map, :logout_url
|
6
|
+
attr_accessor :env_key, :auto_create, :auto_update, :auth_key, :attribute_map, :default_role, :logout_url
|
7
7
|
end
|
8
8
|
|
9
9
|
# request.env key for remote user name
|
@@ -23,6 +23,9 @@ module DeviseAuthProxy
|
|
23
23
|
# Map of User model attributes to request.env keys for updating a local user when auto-creation is enabled.
|
24
24
|
self.attribute_map = {}
|
25
25
|
|
26
|
+
# Set default role for new user.
|
27
|
+
self.default_role = []
|
28
|
+
|
26
29
|
# Settings for redirecting to the remote user logout URL
|
27
30
|
# Enable by including DeviseAuthProxy::Controllers::Helpers in ApplicationController
|
28
31
|
# (it overrides Devise's after_sign_out_path_for method).
|
@@ -32,7 +35,7 @@ module DeviseAuthProxy
|
|
32
35
|
yield self
|
33
36
|
end
|
34
37
|
|
35
|
-
def self.
|
38
|
+
def self.proxy_user_id(env)
|
36
39
|
case env_key
|
37
40
|
when Proc
|
38
41
|
env_key.call(env)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DeviseAuthProxy
|
2
|
+
module Helper
|
3
|
+
|
4
|
+
# Modify session controller after user log out.
|
5
|
+
# To redirect user to a custom url.
|
6
|
+
def after_sign_out_path_for(resource_or_scope)
|
7
|
+
DeviseAuthProxy.logout_url if proxy_user_authenticated? and DeviseAuthProxy.logout_url
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def proxy_user_authenticated?
|
14
|
+
DeviseAuthProxy.proxy_user_id(request.env).present?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -27,31 +27,37 @@ module DeviseAuthProxy
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def create_user
|
30
|
-
unless Devise.mappings[:
|
30
|
+
unless Devise.mappings[:admin_user].strategies.include?(:database_authenticatable)
|
31
31
|
return klass.create(user_criterion)
|
32
32
|
end
|
33
33
|
|
34
34
|
random_password = SecureRandom.hex(16)
|
35
|
-
attrs = user_criterion.merge({
|
35
|
+
attrs = user_criterion.merge({
|
36
|
+
password: random_password,
|
37
|
+
password_confirmation: random_password,
|
38
|
+
roles: DeviseAuthProxy.default_role
|
39
|
+
})
|
40
|
+
|
41
|
+
|
36
42
|
klass.create(attrs)
|
37
43
|
end
|
38
44
|
|
39
45
|
def update_user(user)
|
40
|
-
user.update_attributes(
|
46
|
+
user.update_attributes(proxy_user_attributes)
|
41
47
|
end
|
42
48
|
|
43
49
|
protected
|
44
50
|
|
45
|
-
def
|
51
|
+
def proxy_user_attributes
|
46
52
|
DeviseAuthProxy.attribute_map.inject({}) { |h, (k, v)| h[k] = env[v] if env.has_key?(v); h }
|
47
53
|
end
|
48
54
|
|
49
55
|
def user_criterion
|
50
|
-
{auth_key =>
|
56
|
+
{auth_key => proxy_user_id}
|
51
57
|
end
|
52
58
|
|
53
|
-
def
|
54
|
-
DeviseAuthProxy.
|
59
|
+
def proxy_user_id
|
60
|
+
DeviseAuthProxy.proxy_user_id(env)
|
55
61
|
end
|
56
62
|
|
57
63
|
def auth_key
|
@@ -5,12 +5,16 @@ module Devise
|
|
5
5
|
class AuthProxyAuthenticatable < Authenticatable
|
6
6
|
|
7
7
|
def valid?
|
8
|
-
DeviseAuthProxy.
|
8
|
+
DeviseAuthProxy.proxy_user_id(env).present?
|
9
9
|
end
|
10
10
|
|
11
11
|
def authenticate!
|
12
12
|
resource = mapping.to.find_for_auth_proxy_authentication(env)
|
13
|
-
|
13
|
+
|
14
|
+
return fail(:invalid) unless resource
|
15
|
+
|
16
|
+
# remember_me(resource)
|
17
|
+
success!(resource)
|
14
18
|
end
|
15
19
|
|
16
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_auth_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QuangTK
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- bin/setup
|
45
45
|
- devise_auth_proxy.gemspec
|
46
46
|
- lib/devise_auth_proxy.rb
|
47
|
+
- lib/devise_auth_proxy/helper.rb
|
47
48
|
- lib/devise_auth_proxy/manager.rb
|
48
49
|
- lib/devise_auth_proxy/model.rb
|
49
50
|
- lib/devise_auth_proxy/strategy.rb
|