devise_ichain_authenticatable 0.3.0 → 0.3.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
  SHA1:
3
- metadata.gz: 5c464140caabf7bc6a25efdc813300f15633122e
4
- data.tar.gz: ba7d54cf541b68092ed802e76a639a740c0c2f8e
3
+ metadata.gz: 9f527cdc5099cd67334d3d9497ae0f4584df0292
4
+ data.tar.gz: 3419f6f040a85f47d948b8c1a13e55aa23fbc803
5
5
  SHA512:
6
- metadata.gz: 81b07af69ed0fd985790d1210c2002d0d639c6815f4665efdc6b062337fb3a068145c4b715d141b5e96d33d7d215604baabed1a399b7d49e64c3209ff8252b32
7
- data.tar.gz: 56759efd6146ded0216362b3ccaca0d1a047b2d8208db839c5b6375572c96c10865ef085fa65026e80b09dda0f81ba55fe06cadcd204c94bfabc308f65850878
6
+ metadata.gz: 48911f54980f20aca91f8d656f7f0a479c743b5364b7a3baa5de73b6768ea708c9ee47329077f86cc694af9c3735d74db4f49ba3629fe05e5350ede4400e54b1
7
+ data.tar.gz: 4469b6c2bbd0fc5c87ca1913cdbd2451cdd796418be7a803dfec9a146b3e250cd237b9c206a1ecf616c8cd56fcf6355a266efec767b406c190f4fd73a9dec44c
data/README.md CHANGED
@@ -90,6 +90,13 @@ Devise.setup do |config|
90
90
  # Activate the test mode, useful when no real iChain is present, like in
91
91
  # testing and development environments
92
92
  # config.ichain_test_mode = false
93
+
94
+ # In test mode, you can skip asking for the user information by always
95
+ # forcing the following username. The user will be permanently signed in.
96
+ # config.ichain_force_test_username = "testuser"
97
+
98
+ # In test mode, force the following additional attributes
99
+ # config.ichain_force_test_attributes = {:email => "testuser@example.com"}
93
100
  end
94
101
  ```
95
102
 
@@ -104,14 +111,24 @@ the following helpers would be available: `new_user_ichain_session_path`,
104
111
  Test mode
105
112
  ---------
106
113
 
107
- If the test mode is enabled in the configuration file, anytime
114
+ This gem provides a test mode, extremely useful during the development
115
+ phase, in which an iChain proxy is not usually configured or even available.
116
+ ```ichain_registerable```will have no effect if test mode is enabled.
117
+
118
+ By default, if the test mode is enabled in the configuration file, anytime
108
119
  authentication is required, a very simple form asking for the username and the
109
120
  additional parameters will be displayed. The entered values will be completely
110
- trusted with no check. ```ichain_registerable```will have no effect if test mode
111
- is enabled.
112
-
113
- This mode is extremely useful during the development phase, in which an iChain
114
- proxy is not usually configured or even available.
121
+ trusted with no check and stored in the Rails' session.
122
+
123
+ In some situations this approach is not useful, either because the application
124
+ lacks sessions' management and/or user interface (for example, applications
125
+ based on [rails-api](https://github.com/rails-api/rails-api)), either because
126
+ you simply want to skip asking for the test user information. In those
127
+ cases, a username and/or a set of additional attributes can be forced using the
128
+ ```ichain_force_test_username``` and ```ichain_force_test_attributes```
129
+ configuration options. If ```ichain_force_test_username``` is set, the username
130
+ will be used in every single request, which means that the user will be
131
+ permanently signed in.
115
132
 
116
133
  Contact
117
134
  -------
@@ -1,19 +1,16 @@
1
1
  class Devise::IchainSessionsController < DeviseController
2
2
  prepend_before_filter :require_no_authentication, :only => [ :new, :test ]
3
3
 
4
- # GET /resource/sign_in
5
4
  def new
6
5
  return new_test if ::Devise.ichain_test_mode
7
6
  self.resource = resource_class.new
8
7
  @back_url = base_url + after_sign_in_path_for(resource_name)
9
- # The slash at the end is very important
10
8
  @login_url = resource_class.ichain_login_url
11
9
  @context = ::Devise.ichain_context
12
10
  @proxypath = ::Devise.ichain_proxypath
13
11
  respond_with resource
14
12
  end
15
13
 
16
- # DELETE /resource/sign_out
17
14
  def destroy
18
15
  redirect_url = base_url + after_sign_out_path_for(resource_name)
19
16
  if ::Devise.ichain_test_mode
@@ -23,7 +20,6 @@ class Devise::IchainSessionsController < DeviseController
23
20
  set_flash_message :notice, :signed_out if signed_out && is_navigational_format?
24
21
  redirect_to redirect_url
25
22
  else
26
- # The final slash is very important, indeed
27
23
  logout_url = resource_class.ichain_logout_url
28
24
  logout_url += "?" + {:url => redirect_url}.to_query
29
25
  redirect_to logout_url
@@ -3,9 +3,11 @@
3
3
  <%= form_tag(@login_url, :method => :post, :enctype => 'application/x-www-form-urlencoded') do %>
4
4
  <div><%= label_tag :username, "Username" %><br />
5
5
  <%= text_field_tag :username, "" %></div>
6
- <%- @fields.each do |field| %>
7
- <div><%= label_tag "attributes[#{field}]", field.to_s.humanize %><br />
8
- <%= text_field_tag "attributes[#{field}]", "" %></div>
6
+ <%- if ::Devise.ichain_force_test_attributes.blank? -%>
7
+ <%- @fields.each do |field| %>
8
+ <div><%= label_tag "attributes[#{field}]", field.to_s.humanize %><br />
9
+ <%= text_field_tag "attributes[#{field}]", "" %></div>
10
+ <%- end -%>
9
11
  <%- end -%>
10
12
 
11
13
  <div><%= submit_tag "Sign in" %></div>
@@ -9,12 +9,16 @@ module Devise
9
9
  autoload :IchainFailureApp, 'devise/ichain_failure_app'
10
10
 
11
11
  # Configuration params
12
- @@ichain_test_mode = false
13
12
  @@ichain_base_url = nil
14
13
  @@ichain_context = "default"
15
14
  @@ichain_proxypath = "reverse"
16
15
  @@ichain_username_header = "HTTP_X_USERNAME"
17
16
  @@ichain_attribute_headers = {:email => "HTTP_X_EMAIL"}
17
+
18
+ @@ichain_test_mode = false
19
+ @@ichain_force_test_username = nil
20
+ @@ichain_force_test_attributes = nil
21
+
18
22
  # The slashes at the end of the urls looks to be relevant
19
23
  @@ichain_login_path = "ICSLogin/"
20
24
  @@ichain_registration_path = "ICSLogin/auth-up/"
@@ -23,7 +27,8 @@ module Devise
23
27
  mattr_accessor :ichain_test_mode, :ichain_base_url,
24
28
  :ichain_login_path, :ichain_registration_path, :ichain_logout_path,
25
29
  :ichain_context, :ichain_proxypath,
26
- :ichain_username_header, :ichain_attribute_headers
30
+ :ichain_username_header, :ichain_attribute_headers,
31
+ :ichain_force_test_username, :ichain_force_test_attributes
27
32
  end
28
33
 
29
34
  Devise.add_module :ichain_authenticatable,
@@ -11,9 +11,16 @@ class Devise::Strategies::IchainAuthenticatable < Devise::Strategies::Authentica
11
11
  end
12
12
 
13
13
  def authenticate!
14
+ proxy_user = nil
14
15
  if ::Devise.ichain_test_mode
15
- unless session[:ichain_test_username].blank?
16
+ if ::Devise.ichain_force_test_username
17
+ proxy_user = ::Devise.ichain_force_test_username.to_s
18
+ elsif session[:ichain_test_username]
16
19
  proxy_user = session[:ichain_test_username]
20
+ end
21
+ if ::Devise.ichain_force_test_attributes
22
+ attributes = ::Devise.ichain_force_test_attributes
23
+ else
17
24
  attributes = session[:ichain_test_attributes] || {}
18
25
  end
19
26
  else
@@ -1,3 +1,3 @@
1
1
  module DeviseIchainAuthenticatable
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_ichain_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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-17 00:00:00.000000000 Z
11
+ date: 2013-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.0.2
71
+ rubygems_version: 2.0.3
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Devise extension to allow authentication via iChain