devise_auth_proxy 0.1.21 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 534445c6cec839a905a3613b9176120f861c8ffa675480fe8d3bed6af578d7d1
4
- data.tar.gz: 32d16d25d81b7fa809a3d0f4098cee4d1b503d02e02aa005a210c2ff9c359cb7
3
+ metadata.gz: 4eee02acab727c5c249dd73a115f2b0b9c99b899e5065137336026925c7bf839
4
+ data.tar.gz: e7645975acffcc8586068e5d4576a42563491b7963b366b54a79a64224431d26
5
5
  SHA512:
6
- metadata.gz: 9c829539ca1cd28fcc88b6c22bdf246c893e08d4ffc6a53597556035c56f672aaa826ff5199542d7eb80587eeae910e4a459a0a3b5ad3251d5a1eace3b0e0cf4
7
- data.tar.gz: 3097326e004414afb88e6eb2f45f2064e4914084e9001874cae9f4e72c9b838112e9e8ed5558eb5f984b5919fdb20f4bd42e366922ae220ccc3d189dff2f4d7c
6
+ metadata.gz: e47ec1f80c8554d065fdee759dc8e9fd19101d4d51644875b2aa5d0e4b13c6d25652e2f7d414ee0c4c21610667e1692af41b44482d5db610c2b01963c1ea3cac
7
+ data.tar.gz: 42a3585e6f77b701732c782664487decd489bc1783931b5f08e99069c8dd8c731ded7b7666262bdbb9a8309ee31bdbc14c52880e96ab86bb757cfcc00588c297
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise_auth_proxy (0.1.21)
4
+ devise_auth_proxy (0.2.4)
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,9 +1,20 @@
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)
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
17
+
7
18
  return DeviseAuthProxy.logout_url if DeviseAuthProxy.logout_url
8
19
  super
9
20
  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.21"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module Service
5
+ class 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.21
4
+ version: 0.2.4
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