devise_auth_proxy 0.1.18 → 0.2.1
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/README.md +4 -1
- data/lib/devise_auth_proxy.rb +4 -1
- data/lib/devise_auth_proxy/helper.rb +22 -0
- data/lib/devise_auth_proxy/manager.rb +2 -0
- data/lib/devise_auth_proxy/strategy.rb +2 -1
- data/lib/devise_auth_proxy/version.rb +1 -1
- data/lib/service/foss_identity.rb +13 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69eb82aa5afcfbafa90b4c4e1cbfca6a55e07b9ae8ed5405980b06b5eea7496b
|
4
|
+
data.tar.gz: 33a6e309d5d40efe6aac23b0f81f1d9cfe279e63374054e93bca45949ca15aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fde955533784af6929e8ba6c9e99e9601ed8bd6f849ef4cf5605728ba8f7ca680785c570fec559f4e3d4b580be11d3277d35c06818cf178d0f17bc881a88b9e6
|
7
|
+
data.tar.gz: 5bc91de4d5784cad0f582693481dc7dc47a7726693bfb7fe009cb687757d176bf57ecf9885d775c6e85cf7536f38818d338f26197c99b4522e1cddb114523a86
|
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,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, :default_role, :logout_url
|
6
|
+
attr_accessor :env_key, :auto_create, :auto_update, :auth_key, :attribute_map, :default_role, :logout_service, :logout_url
|
7
7
|
end
|
8
8
|
|
9
9
|
# request.env key for remote user name
|
@@ -26,6 +26,9 @@ module DeviseAuthProxy
|
|
26
26
|
# Set default role for new user.
|
27
27
|
self.default_role = []
|
28
28
|
|
29
|
+
# Set the service using to logout.
|
30
|
+
self.logout_service = nil
|
31
|
+
|
29
32
|
# Settings for redirecting to the remote user logout URL
|
30
33
|
# Enable by including DeviseAuthProxy::Controllers::Helpers in ApplicationController
|
31
34
|
# (it overrides Devise's after_sign_out_path_for method).
|
@@ -0,0 +1,22 @@
|
|
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
|
+
unless DeviseAuthProxy.logout_service.nil?
|
8
|
+
case DeviseAuthProxy.logout_service
|
9
|
+
when 'foss_identity'
|
10
|
+
Service::FossIdentity.logout(DeviseAuthProxy.logout_url, session[:http_cookie])
|
11
|
+
else
|
12
|
+
# do nothing
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
session.delete(:http_cookie)
|
17
|
+
|
18
|
+
return DeviseAuthProxy.logout_url if DeviseAuthProxy.logout_url
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.2.1
|
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,10 +44,12 @@ 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
|
50
51
|
- lib/devise_auth_proxy/version.rb
|
52
|
+
- lib/service/foss_identity.rb
|
51
53
|
homepage: https://github.com/me0den/devise_auth_proxy
|
52
54
|
licenses:
|
53
55
|
- MIT
|