devise_auth_proxy 0.1.20 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/lib/devise_auth_proxy.rb +8 -1
- data/lib/devise_auth_proxy/helper.rb +12 -7
- data/lib/devise_auth_proxy/strategy.rb +1 -0
- data/lib/devise_auth_proxy/version.rb +1 -1
- data/lib/service/foss_identity.rb +13 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9b679470b4f07671e47ce108c45270fc227b9bccdc78cd03ca8f1dec0e1bc07
|
4
|
+
data.tar.gz: 3023d64dcc4bce3c1978eb7a3fff8de3cb313d335b45bccd9a22f3347623d760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2a76fd427a71f5d0dc55332942b7b14f8e34acc0ad9131e5cc1f4a5cc44b83c61ccb6ed8acc69c4d70204e273a7057247c0a44dff9d91721116dce9d53137a
|
7
|
+
data.tar.gz: 1121f852ae5d984edfc245f9121c1f5b01243397a9b373e61cc5ca74c427152fb0055c9b507780fefd8cda93d3bb2628418607cd004589572c95e000158344e2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,12 +24,14 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
Invoke hook
|
26
26
|
* Add `:auth_proxy_authenticatable` symbol to `devise` statement in User model, before other authentication strategies (e.g., `:database_authenticatable`).
|
27
|
+
* Add `include DeviseAuthProxy::Helper` to ApplicationController to override `after_sign_out_path_for` of devise if you want to modify the redirect url after sign out.
|
27
28
|
|
28
|
-
|
29
|
+
Configuration options:
|
29
30
|
* `env_key` - String (default: 'AUTH_PROXY'). Request environment key for the proxy user id.
|
30
31
|
* `attribute_map` - Hash (default: {}). Map of User model attributes to request environment keys for updating the local user when auto-creation is enabled.
|
31
32
|
* `auto_create` - Boolean (default: false). Whether to auto-create a local user from the proxy user attributes. Note: Also requires adding the Warden callbacks as shown below.
|
32
33
|
* `auto_update` - Boolean (default: false). Whether to auto-update authenticated user attributes from proxy user attributes.
|
34
|
+
* `default_role` - List (default: []). A list of role default for new user. If your application integrate with CanCan of something like that.
|
33
35
|
* `logout_url` - String (default: '/'). For redirecting to a proxy user logout URL after signing out of the Rails application. Include DeviseAuthProxy::ControllerBehavior in your application controller to enable (by overriding Devise's after_sign_out_path_for).
|
34
36
|
|
35
37
|
|
@@ -43,6 +45,7 @@ DeviseAuthProxy.configure do |config|
|
|
43
45
|
config.auto_create = true
|
44
46
|
config.auto_update = true
|
45
47
|
config.attribute_map = { email: 'mail' }
|
48
|
+
config.default_role = ['role_name / role_id']
|
46
49
|
config.logout_url = "http://localhost:3000/logout"
|
47
50
|
end
|
48
51
|
```
|
data/lib/devise_auth_proxy.rb
CHANGED
@@ -3,7 +3,9 @@ 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,
|
6
|
+
attr_accessor :env_key, :auto_create, :auto_update, :auth_key,
|
7
|
+
:attribute_map, :default_role, :logout_service, :logout_url,
|
8
|
+
:http_cookie
|
7
9
|
end
|
8
10
|
|
9
11
|
# request.env key for remote user name
|
@@ -26,11 +28,16 @@ module DeviseAuthProxy
|
|
26
28
|
# Set default role for new user.
|
27
29
|
self.default_role = []
|
28
30
|
|
31
|
+
# Set the service using to logout.
|
32
|
+
self.logout_service = nil
|
33
|
+
|
29
34
|
# Settings for redirecting to the remote user logout URL
|
30
35
|
# Enable by including DeviseAuthProxy::Controllers::Helpers in ApplicationController
|
31
36
|
# (it overrides Devise's after_sign_out_path_for method).
|
32
37
|
self.logout_url = '/'
|
33
38
|
|
39
|
+
self.http_cookie = nil
|
40
|
+
|
34
41
|
def self.configure
|
35
42
|
yield self
|
36
43
|
end
|
@@ -1,17 +1,22 @@
|
|
1
|
+
require 'service/foss_identity'
|
2
|
+
|
1
3
|
module DeviseAuthProxy
|
2
4
|
module Helper
|
3
5
|
|
4
6
|
# Modify session controller after user log out.
|
5
7
|
# To redirect user to a custom url.
|
6
8
|
def after_sign_out_path_for(resource_or_scope)
|
7
|
-
DeviseAuthProxy.
|
8
|
-
|
9
|
-
|
9
|
+
unless DeviseAuthProxy.logout_service.nil?
|
10
|
+
case DeviseAuthProxy.logout_service
|
11
|
+
when 'foss_identity'
|
12
|
+
Service::FossIdentity.logout(DeviseAuthProxy.logout_url, DeviseAuthProxy.http_cookie)
|
13
|
+
else
|
14
|
+
# do nothing
|
15
|
+
end
|
16
|
+
end
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
def proxy_user_authenticated?
|
14
|
-
DeviseAuthProxy.proxy_user_id(request.env).present?
|
18
|
+
return DeviseAuthProxy.logout_url if DeviseAuthProxy.logout_url
|
19
|
+
super
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_auth_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QuangTK
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/devise_auth_proxy/model.rb
|
50
50
|
- lib/devise_auth_proxy/strategy.rb
|
51
51
|
- lib/devise_auth_proxy/version.rb
|
52
|
+
- lib/service/foss_identity.rb
|
52
53
|
homepage: https://github.com/me0den/devise_auth_proxy
|
53
54
|
licenses:
|
54
55
|
- MIT
|