devise_auth_proxy 0.1.18 → 0.2.1

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: 6af0161c4e1be59158764e92b23d952b05fbadd5bb598721863cfe0ab219e162
4
- data.tar.gz: 741d9df632d84752cf516922a340736080a46ac3fd9406eeb0fc6fa324136dac
3
+ metadata.gz: 69eb82aa5afcfbafa90b4c4e1cbfca6a55e07b9ae8ed5405980b06b5eea7496b
4
+ data.tar.gz: 33a6e309d5d40efe6aac23b0f81f1d9cfe279e63374054e93bca45949ca15aa0
5
5
  SHA512:
6
- metadata.gz: 32ad9668c368c4789a8cdcc6bda6128e9c8d3ceeec19d525fadab659150ecbce004fb0c457e12416b0231f4eb0ac38eb083ebf8812faf267a3571ee642025c6c
7
- data.tar.gz: c4e24436f33df434673b83045155a60d68eca83f7419e9e19ae01c6bea3bd9e81620e38d38dac9b9c4ecc2de61519a73cd737179f76e240c972386491eef0a20
6
+ metadata.gz: fde955533784af6929e8ba6c9e99e9601ed8bd6f849ef4cf5605728ba8f7ca680785c570fec559f4e3d4b580be11d3277d35c06818cf178d0f17bc881a88b9e6
7
+ data.tar.gz: 5bc91de4d5784cad0f582693481dc7dc47a7726693bfb7fe009cb687757d176bf57ecf9885d775c6e85cf7536f38818d338f26197c99b4522e1cddb114523a86
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise_auth_proxy (0.1.18)
4
+ devise_auth_proxy (0.2.1)
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,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
@@ -37,6 +37,8 @@ module DeviseAuthProxy
37
37
  password_confirmation: random_password,
38
38
  roles: DeviseAuthProxy.default_role
39
39
  })
40
+
41
+
40
42
  klass.create(attrs)
41
43
  end
42
44
 
@@ -13,7 +13,8 @@ module Devise
13
13
 
14
14
  return fail(:invalid) unless resource
15
15
 
16
- remember_me(resource)
16
+ session[:http_cookie] = env["HTTP_COOKIE"]
17
+ # remember_me(resource)
17
18
  success!(resource)
18
19
  end
19
20
 
@@ -1,3 +1,3 @@
1
1
  module DeviseAuthProxy
2
- VERSION = "0.1.18"
2
+ VERSION = "0.2.1"
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,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.18
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-29 00:00:00.000000000 Z
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