devise_ichain_authenticatable 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Y2RmMzFkMDdkZjIyMjYzZmQ5MjNjNzgxOTliNTk0NjhlM2U0Y2FmNA==
5
- data.tar.gz: !binary |-
6
- MDI2MjhhZTBkMTBjMTcwMGQwM2RkODU4NzIyOTViZjQ5ZmNjMWM4Yg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MzA1YTE4MDA5NTBhNDJmNmRmNGUzNzZhMTNiODJmMGI3MGIxMDIzZmZkMzVj
10
- YTJkYTBmMTg1YjcyZGNhYjRjMWJmYWFkZmEwZjk1N2MxNWRlZjY4ZmJlM2I4
11
- MWZlNTJlYTc1MGZjODY1YjdhYjNiOThkZjU3NzMzNDBjNTM5ODM=
12
- data.tar.gz: !binary |-
13
- NmIwZjg1ZTNhZjUwODlkMDgwZDNhMTM0N2M4NTRkZjA0MTU4OTEyOTA1YmYy
14
- Mzk4YmE0NWUwZjg2ZGQwYzVjYjFlZDI3Njc1NGI4ZmRhMDc4ZjE2YjU2NjBi
15
- NTQ2ZTM2MTdmOGM0NzQzMmNjZTc1OTMwM2VmMjVmYzYzZThjM2U=
2
+ SHA1:
3
+ metadata.gz: 5c464140caabf7bc6a25efdc813300f15633122e
4
+ data.tar.gz: ba7d54cf541b68092ed802e76a639a740c0c2f8e
5
+ SHA512:
6
+ metadata.gz: 81b07af69ed0fd985790d1210c2002d0d639c6815f4665efdc6b062337fb3a068145c4b715d141b5e96d33d7d215604baabed1a399b7d49e64c3209ff8252b32
7
+ data.tar.gz: 56759efd6146ded0216362b3ccaca0d1a047b2d8208db839c5b6375572c96c10865ef085fa65026e80b09dda0f81ba55fe06cadcd204c94bfabc308f65850878
data/README.md CHANGED
@@ -11,12 +11,12 @@ desired.
11
11
  Requirements
12
12
  ------------
13
13
 
14
- The plugin should be compatible with Ruby 1.8.7, 1.9.3 and 2.0, but have only be
15
- tested in production with Ruby 1.9.3.
14
+ The plugin should be compatible with Ruby 1.8.7, 1.9 and 2.0 (tested with
15
+ 1.9.3 and 2.0.0).
16
16
 
17
17
  In the same way, it should work with any version of Devise equal or greater than 2.2
18
- and with any version of Rails equal or greater than 3.2, but have only be tested
19
- with Rails 3.2 and Devise 2.2.
18
+ and with any version of Rails equal or greater than 3.2 (tested with Devise 2.2
19
+ on Rails 3.2 and with Devise 3.1 on Rails 4).
20
20
 
21
21
  Reporting of success stories with other setups would be highly appreciated.
22
22
 
@@ -39,7 +39,11 @@ class User < ActiveRecord::Base
39
39
  devise :ichain_authenticatable, :ichain_registerable
40
40
 
41
41
  def self.for_ichain_username(username, attributes)
42
- find_or_create_by_login(username)
42
+ if user = find_by(login: username)
43
+ user.update_column(email: attributes[:email]) if user.email != attributes[:email]
44
+ else
45
+ user = create(login: username, email: attributes[:email])
46
+ end
43
47
  end
44
48
  end
45
49
  ```
@@ -66,6 +70,11 @@ Devise.setup do |config|
66
70
  # You will always need to set this parameter.
67
71
  config.ichain_base_url = "https://my.application.org"
68
72
 
73
+ # Paths (relative to ichain_base_url) used by your proxy
74
+ # config.ichain_login_path = "ICSLogin/"
75
+ # config.ichain_registration_path = "ICSLogin/auth-up/"
76
+ # config.ichain_logout_path = "cmd/ICSLogout/"
77
+
69
78
  # The header used by your iChain proxy to pass the username.
70
79
  # config.ichain_username_header = "HTTP_X_USERNAME"
71
80
 
@@ -4,7 +4,7 @@ class Devise::IchainSessionsController < DeviseController
4
4
  # GET /resource/sign_in
5
5
  def new
6
6
  return new_test if ::Devise.ichain_test_mode
7
- self.resource = build_resource(nil, :unsafe => true)
7
+ self.resource = resource_class.new
8
8
  @back_url = base_url + after_sign_in_path_for(resource_name)
9
9
  # The slash at the end is very important
10
10
  @login_url = resource_class.ichain_login_url
@@ -40,7 +40,7 @@ class Devise::IchainSessionsController < DeviseController
40
40
  protected
41
41
 
42
42
  def new_test
43
- self.resource = build_resource(nil, :unsafe => true)
43
+ self.resource = resource_class.new
44
44
  @fields = (::Devise.ichain_attribute_headers.keys rescue [])
45
45
  @login_url = test_ichain_session_path(resource_name)
46
46
  render :new_test
@@ -9,7 +9,7 @@
9
9
  <%= text_field_tag :username, "", :autofocus => true %></div>
10
10
 
11
11
  <div><%= label_tag :Password, "Password" %><br />
12
- <%= text_field_tag :password, "" %></div>
12
+ <%= password_field_tag :password, "" %></div>
13
13
 
14
14
  <div><%= submit_tag "Sign in" %></div>
15
15
  <% end %>
@@ -15,9 +15,15 @@ module Devise
15
15
  @@ichain_proxypath = "reverse"
16
16
  @@ichain_username_header = "HTTP_X_USERNAME"
17
17
  @@ichain_attribute_headers = {:email => "HTTP_X_EMAIL"}
18
+ # The slashes at the end of the urls looks to be relevant
19
+ @@ichain_login_path = "ICSLogin/"
20
+ @@ichain_registration_path = "ICSLogin/auth-up/"
21
+ @@ichain_logout_path = "cmd/ICSLogout/"
18
22
 
19
- mattr_accessor :ichain_test_mode, :ichain_base_url, :ichain_context,
20
- :ichain_proxypath, :ichain_username_header, :ichain_attribute_headers
23
+ mattr_accessor :ichain_test_mode, :ichain_base_url,
24
+ :ichain_login_path, :ichain_registration_path, :ichain_logout_path,
25
+ :ichain_context, :ichain_proxypath,
26
+ :ichain_username_header, :ichain_attribute_headers
21
27
  end
22
28
 
23
29
  Devise.add_module :ichain_authenticatable,
@@ -6,18 +6,21 @@ module Devise
6
6
  end
7
7
 
8
8
  module ClassMethods
9
- # The slashes at the end of the urls looks to be relevant
9
+ def ichain_url_for(action)
10
+ URI::join(::Devise.ichain_base_url || "",
11
+ ::Devise.send(:"ichain_#{action}_path")).to_s
12
+ end
10
13
 
11
14
  def ichain_registration_url
12
- (::Devise.ichain_base_url || "") + "/ICSLogin/"
15
+ ichain_url_for(:registration)
13
16
  end
14
17
 
15
18
  def ichain_login_url
16
- (::Devise.ichain_base_url || "") + "/ICSLogin/auth-up/"
19
+ ichain_url_for(:login)
17
20
  end
18
21
 
19
22
  def ichain_logout_url
20
- (::Devise.ichain_base_url || "") + "/ICHAINLogout/"
23
+ ichain_url_for(:logout)
21
24
  end
22
25
  end
23
26
 
@@ -1,3 +1,3 @@
1
1
  module DeviseIchainAuthenticatable
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_ichain_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ancor González Sosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.2'
27
27
  description: Devise extension to allow authentication via iChain
@@ -58,19 +58,18 @@ require_paths:
58
58
  - lib
59
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ! '>='
61
+ - - '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.0.3
71
+ rubygems_version: 2.0.2
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Devise extension to allow authentication via iChain
75
75
  test_files: []
76
- has_rdoc: