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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2b0861fe8d5e53bd761613539ff5633242f7be6628bdf9d0e27eec971dbe2b1
4
- data.tar.gz: a2c0f4aea50cab2071125bed3b8835eba0beef844d95c26aca0ef6f84b39c385
3
+ metadata.gz: f9b679470b4f07671e47ce108c45270fc227b9bccdc78cd03ca8f1dec0e1bc07
4
+ data.tar.gz: 3023d64dcc4bce3c1978eb7a3fff8de3cb313d335b45bccd9a22f3347623d760
5
5
  SHA512:
6
- metadata.gz: 9b9c1db28587c5ece2ecfc377d9d808cb6aa3211db6e8bc48bfa11d5db973901802c783c0ccc0bf8afdbb3a36c64181ef05d04fe13c044ae971041dbb47fbacb
7
- data.tar.gz: 43a767a92a0e99b2cafecc68d74e9197266dcb03fab60e174a901a5574d13a49c2fce0328fab88878155c51f07c630f359d092ea630173d06437bcab5a5b86aa
6
+ metadata.gz: ff2a76fd427a71f5d0dc55332942b7b14f8e34acc0ad9131e5cc1f4a5cc44b83c61ccb6ed8acc69c4d70204e273a7057247c0a44dff9d91721116dce9d53137a
7
+ data.tar.gz: 1121f852ae5d984edfc245f9121c1f5b01243397a9b373e61cc5ca74c427152fb0055c9b507780fefd8cda93d3bb2628418607cd004589572c95e000158344e2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise_auth_proxy (0.1.20)
4
+ devise_auth_proxy (0.2.3)
5
5
  devise
6
6
 
7
7
  GEM
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
- Configuaration options:
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
  ```
@@ -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, :attribute_map, :default_role, :logout_url
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.logout_url if proxy_user_authenticated? and DeviseAuthProxy.logout_url
8
- super
9
- end
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
- private
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
@@ -13,6 +13,7 @@ module Devise
13
13
 
14
14
  return fail(:invalid) unless resource
15
15
 
16
+ DeviseAuthProxy.http_cookie = env["HTTP_COOKIE"]
16
17
  # remember_me(resource)
17
18
  success!(resource)
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseAuthProxy
2
- VERSION = "0.1.20"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module Service
5
+ module FossIdentity
6
+ def logout(path, cookie)
7
+ Net::HTTP.post(
8
+ URI(path),
9
+ "cookie" => cookie
10
+ )
11
+ end
12
+ end
13
+ 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.1.20
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