janus 0.8.1 → 0.9.0

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
  SHA1:
3
- metadata.gz: cfd15bc79e41899bc65c3eddc3042f11524e4616
4
- data.tar.gz: f836a95402bb7371fe25d1af49cd5841b74bb6b3
3
+ metadata.gz: fea9943c78cce6d222a79c9038f4cfed503eb2f2
4
+ data.tar.gz: 7a40e9798588323ba8318b845395a4384d77f59d
5
5
  SHA512:
6
- metadata.gz: 15d3598d95a4e264a6087fea6244fe4937849c759dca34ffd0377a0764ef1b5a633bb98004e083e7a15136999d8535d71674e1944a9d913799af69ccb9601720
7
- data.tar.gz: ee62d38fd4070283177a52176ac77525ad0994e991aaa0f579b2e9f559ad4ba38ae0a86c679c42f449825f2979c14cac43cb10b1410387d254a4309699e7983a
6
+ metadata.gz: a13b710c833af906688fc9bc8dce633c9cc4d54f7c31563fdf25d8828ece45c490b8fe550f84c0f0e4f21bc42c8570fa211a5112f7db13eb97c8ea18bd4e661a
7
+ data.tar.gz: 8aecfa6247cc1acc5e8ad016106ef596b6e6676458be3d3f95bf883775f120a0dc0bc1e70cb5946113aa0b15c6eb347dc8019d23a467fa254829a173fd7747a8
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.rdoc CHANGED
@@ -47,6 +47,24 @@ Run the <tt>janus:install</tt> generator to setup janus in your app:
47
47
 
48
48
  $ rails generate janus:install
49
49
 
50
+ If you are running Rails 4.1+ you must add a `secret_pepper` to your
51
+ `config/secrets.yml` file after generating a secure token with `rake secret`:
52
+
53
+ # config/secrets.yml
54
+ development:
55
+ secret_key_base: "..."
56
+ secret_pepper: "..."
57
+ test:
58
+ secret_key_base: "..."
59
+ secret_pepper: "..."
60
+ production:
61
+ secret_key_base: ENV["SECRET_KEY_BASE"]
62
+ secret_pepper: ENV["SECRET_PEPPER"]
63
+
64
+ If you are running a previous version of Rails, then you should edit
65
+ `config/initializers/janus.rb` to use an environment variable instead of the
66
+ generated token.
67
+
50
68
  Then create your first authenticatable resource, let's say +User+:
51
69
 
52
70
  $ rails generate janus:resource user
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.9.0
@@ -1,3 +1,15 @@
1
1
  class <%= class_name.pluralize %>::ConfirmationsController < Janus::ConfirmationsController
2
2
  respond_to :html
3
+
4
+ # def deliver_confirmation_instructions(<%= singular_name %>)
5
+ # <%= class_name %>Mailer.confirmation_instructions(<%= singular_name %>).deliver
6
+ # end
7
+
8
+ # def after_resending_confirmation_instructions_url(<%= singular_name %>)
9
+ # root_url
10
+ # end
11
+
12
+ # def after_confirmation_url(<%= singular_name %>)
13
+ # root_url
14
+ # end
3
15
  end
@@ -7,7 +7,11 @@ Janus.config do |config|
7
7
  # bcrypt:
8
8
  config.encryptor = :bcrypt
9
9
  config.stretches = Rails.env.test? ? 1 : 10
10
- config.pepper = <%= SecureRandom.hex(64).inspect %>
10
+ config.pepper = <%= if Rails.application.respond_to?(:secrets)
11
+ "Rails.application.secrets[:secret_pepper]"
12
+ else
13
+ SecureRandom.hex(64).inspect
14
+ end %>
11
15
 
12
16
  # scrypt:
13
17
  # config.encryptor = :scrypt
@@ -1,3 +1,15 @@
1
1
  class <%= class_name.pluralize %>::PasswordsController < Janus::PasswordsController
2
2
  respond_to :html
3
+
4
+ # def deliver_reset_password_instructions(<%= singular_name %>)
5
+ # <%= class_name %>Mailer.reset_password_instructions(<%= singular_name %>).deliver
6
+ # end
7
+
8
+ # def after_password_change_url(<%= singular_name %>)
9
+ # root_url
10
+ # end
11
+
12
+ # def after_sending_reset_password_instructions_url(<%= singular_name %>)
13
+ # root_url
14
+ # end
3
15
  end
@@ -1,10 +1,18 @@
1
1
  class <%= class_name.pluralize %>::RegistrationsController < Janus::RegistrationsController
2
2
  respond_to :html
3
3
 
4
+ # def deliver_confirmation_instructions(<%= singular_name %>)
5
+ # <%= class_name %>Mailer.confirmation_instructions(<%= singular_name %>).deliver
6
+ # end
7
+
4
8
  # def after_sign_up_url(<%= singular_name %>)
5
9
  # profile_url(<%= singular_name %>)
6
10
  # end
7
11
 
12
+ # def after_destroy_url(<%= singular_name %>)
13
+ # root_url
14
+ # end
15
+
8
16
  def <%= singular_name %>_params
9
17
  if params.respond_to?(:permit)
10
18
  # Rails 4 (or Rails 3 + strong_parameters)
@@ -5,6 +5,10 @@ class <%= class_name.pluralize %>::SessionsController < Janus::SessionsControlle
5
5
  # profile_url(<%= singular_name %>)
6
6
  # end
7
7
 
8
+ # def after_sign_out_url(<%= singular_name %>)
9
+ # profile_url(<%= singular_name %>)
10
+ # end
11
+
8
12
  # def valid_remote_host?(host)
9
13
  # ['www.example.com', 'test.host'].include?(host)
10
14
  # end
@@ -12,8 +12,12 @@ class Janus::ConfirmationsController < ApplicationController
12
12
  resource.confirm!
13
13
 
14
14
  respond_to do |format|
15
- format.html { redirect_to root_url, :notice => t('flash.janus.confirmations.edit.confirmed') }
16
- format.any { head :ok }
15
+ format.html do
16
+ redirect_to after_confirmation_url(resource),
17
+ :notice => t('flash.janus.confirmations.edit.confirmed')
18
+ end
19
+
20
+ format.any { head :ok }
17
21
  end
18
22
  else
19
23
  respond_to do |format|
@@ -37,10 +41,14 @@ class Janus::ConfirmationsController < ApplicationController
37
41
  self.resource = resource_class.find_for_database_authentication(params[resource_name])
38
42
 
39
43
  if resource
40
- deliver_confirmation_instructions
44
+ deliver_confirmation_instructions(resource)
41
45
 
42
46
  respond_to do |format|
43
- format.html { redirect_to root_url, :notice => t('flash.janus.confirmations.create.email_sent') }
47
+ format.html do
48
+ redirect_to after_resending_confirmation_instructions_url(resource),
49
+ :notice => t('flash.janus.confirmations.create.email_sent')
50
+ end
51
+
44
52
  format.any { head :ok }
45
53
  end
46
54
  else
@@ -58,7 +66,17 @@ class Janus::ConfirmationsController < ApplicationController
58
66
 
59
67
  # Simple wrapper for Mailer#confirmation_instructions.deliver to
60
68
  # allow customization of the email (eg: to pass additional data).
61
- def deliver_confirmation_instructions
69
+ def deliver_confirmation_instructions(resource)
62
70
  mailer_class.confirmation_instructions(resource).deliver
63
71
  end
72
+
73
+ # Where to redirect after the instructions have been sent.
74
+ def after_resending_confirmation_instructions_url(resource)
75
+ root_url
76
+ end
77
+
78
+ # Where to redirect when the user has confirmed her account.
79
+ def after_confirmation_url(resource)
80
+ root_url
81
+ end
64
82
  end
@@ -15,10 +15,13 @@ class Janus::PasswordsController < ApplicationController
15
15
 
16
16
  if resource
17
17
  resource.generate_reset_password_token!
18
- deliver_reset_password_instructions
18
+ deliver_reset_password_instructions(resource)
19
19
 
20
20
  respond_to do |format|
21
- format.html { redirect_to root_url, :notice => t('flash.janus.passwords.create.email_sent') }
21
+ format.html do
22
+ redirect_to after_sending_reset_password_instructions_url(resource),
23
+ :notice => t('flash.janus.passwords.create.email_sent')
24
+ end
22
25
  format.any { head :ok }
23
26
  end
24
27
  else
@@ -63,21 +66,27 @@ class Janus::PasswordsController < ApplicationController
63
66
 
64
67
  # Simple wrapper for Mailer#reset_password_instructions.deliver to
65
68
  # allow customization of the email (eg: to pass additional data).
66
- def deliver_reset_password_instructions
69
+ def deliver_reset_password_instructions(resource)
67
70
  mailer_class.reset_password_instructions(resource).deliver
68
71
  end
69
72
 
70
73
  # Either redirects the user to after_password_change_url or to
71
74
  # <tt>params[:return_to]</tt> if present.
72
- def redirect_after_password_change(user, options = {})
75
+ def redirect_after_password_change(resource, options = {})
73
76
  if params[:return_to].present?
74
77
  redirect_to params[:return_to], options
75
78
  else
76
- redirect_to after_password_change_url(user), options
79
+ redirect_to after_password_change_url(resource), options
77
80
  end
78
81
  end
79
82
 
80
- def after_password_change_url(user)
83
+ # Where to redirect when the password has been changed.
84
+ def after_password_change_url(resource)
85
+ root_url
86
+ end
87
+
88
+ # Where to redirect when the instructions have been sent.
89
+ def after_sending_reset_password_instructions_url(resource)
81
90
  root_url
82
91
  end
83
92
  end
@@ -21,7 +21,7 @@ class Janus::RegistrationsController < ApplicationController
21
21
 
22
22
  if resource.save
23
23
  janus.login(resource, :scope => janus_scope, :rememberable => true)
24
- mailer_class.confirmation_instructions(resource).deliver if resource.respond_to?(:confirm!)
24
+ deliver_confirmation_instructions(resource) if resource.respond_to?(:confirm!)
25
25
  else
26
26
  resource.clean_up_passwords
27
27
  end
@@ -41,14 +41,26 @@ class Janus::RegistrationsController < ApplicationController
41
41
  janus.unset_user(janus_scope) if resource.destroy
42
42
 
43
43
  respond_with(resource) do |format|
44
- format.html { redirect_to root_url }
44
+ format.html { redirect_to after_destroy_url(resource) }
45
45
  end
46
46
  end
47
47
 
48
+ # Simple wrapper for Mailer#confirmation_instructions.deliver to
49
+ # allow customization of the email (eg: to pass additional data).
50
+ def deliver_confirmation_instructions(resource)
51
+ mailer_class.confirmation_instructions(resource).deliver
52
+ end
53
+
54
+ # Where to redirect after user has registered.
48
55
  def after_sign_up_url(user)
49
56
  user
50
57
  end
51
58
 
59
+ # Where to redirect after user has unregistered.
60
+ def after_destroy_url(resource)
61
+ root_url
62
+ end
63
+
52
64
  def resource_params
53
65
  keys = %w{current_password password password_confirmation}
54
66
  send("#{janus_scope}_params").reject do |key, value|
data/lib/janus/manager.rb CHANGED
@@ -60,12 +60,12 @@ module Janus
60
60
  # authenticate process.
61
61
  def set_user(user, options = {})
62
62
  scope = options[:scope] || Janus.scope_for(user)
63
- janus_sessions[scope.to_sym] = { :user_class => user.class, :user_id => user.id }
63
+ janus_sessions[scope.to_s] = { 'user_class' => user.class.name, 'user_id' => user.id }
64
64
  end
65
65
 
66
66
  # Manually removes the user without going throught the whole logout process.
67
67
  def unset_user(scope)
68
- janus_sessions.delete(scope.to_sym)
68
+ janus_sessions.delete(scope.to_s)
69
69
  @users.delete(scope.to_sym) unless @users.nil?
70
70
  end
71
71
 
@@ -77,7 +77,7 @@ module Janus
77
77
  if authenticated?(scope)
78
78
  if @users[scope].nil?
79
79
  begin
80
- @users[scope] = session(scope)[:user_class].find(session(scope)[:user_id])
80
+ @users[scope] = user_class(scope).find(session(scope)['user_id'])
81
81
  rescue ActiveRecord::RecordNotFound
82
82
  unset_user(scope)
83
83
  else
@@ -91,12 +91,16 @@ module Janus
91
91
 
92
92
  # Returns the current session for user.
93
93
  def session(scope)
94
- janus_sessions[scope.to_sym]
94
+ janus_sessions[scope.to_s]
95
95
  end
96
96
 
97
97
  private
98
98
  def janus_sessions
99
99
  request.session['janus'] ||= {}
100
100
  end
101
+
102
+ def user_class(scope)
103
+ session(scope)['user_class'].constantize
104
+ end
101
105
  end
102
106
  end
@@ -1,3 +1,5 @@
1
+ require 'janus'
2
+
1
3
  Janus.config do |config|
2
4
  config.contact_email = "contact@some-example-domain.com"
3
5
 
@@ -5,7 +7,13 @@ Janus.config do |config|
5
7
  config.authentication_keys = [:email]
6
8
  config.encryptor = :bcrypt
7
9
  config.stretches = 10
8
- config.pepper = "db5ef161873f4b4cd966ff042c448282e8243a0a4e090347370360796ecc769f384d898badda1881bc7ed4483f20f6809b39a54f6671cc35cda18bfe554cd8e0"
10
+
11
+ if Rails.application.respond_to?(:secrets)
12
+ config.pepper = Rails.application.secrets[:secret_pepper]
13
+ else
14
+ config.pepper = "db5ef161873f4b4cd966ff042c448282e8243a0a4e090347370360796ecc769f384d898badda1881bc7ed4483f20f6809b39a54f6671cc35cda18bfe554cd8e0"
15
+ end
16
+
9
17
  # config.scrypt_options = { :max_time => 0.25 }
10
18
 
11
19
  # Confirmable
@@ -1,8 +1,7 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- RailsApp::Application.config.secret_key_base = 'c6a67697877c66be70cdcc4680f37593045a721cf757de4110f9749877cb32f94fe4ddaa5e816af4555d91c4f6142a401972474d50fe620d41ede300d3143d4a'
8
- RailsApp::Application.config.secret_token = 'c6a67697877c66be70cdcc4680f37593045a721cf757de4110f9749877cb32f94fe4ddaa5e816af4555d91c4f6142a401972474d50fe620d41ede300d3143d4a'
1
+ if RailsApp::Application.config.respond_to?(:secret_key_base)
2
+ if Rails.version < '4.1.0'
3
+ RailsApp::Application.config.secret_key_base = 'c6a67697877c66be70cdcc4680f37593045a721cf757de4110f9749877cb32f94fe4ddaa5e816af4555d91c4f6142a401972474d50fe620d41ede300d3143d4a'
4
+ end
5
+ else
6
+ RailsApp::Application.config.secret_token = 'c6a67697877c66be70cdcc4680f37593045a721cf757de4110f9749877cb32f94fe4ddaa5e816af4555d91c4f6142a401972474d50fe620d41ede300d3143d4a'
7
+ end
@@ -1,8 +1 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
1
  RailsApp::Application.config.session_store :cookie_store, :key => '_rails_app_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # RailsApp::Application.config.session_store :active_record_store
@@ -0,0 +1,12 @@
1
+ development:
2
+ secret_key_base: 306a71f354ac073a1fc1383922098a3f5d406d56df8512e9bf159f4d1cec5bfb51b396a16a4d421c105a879f81caf35e6f49781d3bf0c06e9355d8eff111b7ff
3
+ secret_pepper: db5ef161873f4b4cd966ff042c448282e8243a0a4e090347370360796ecc769f384d898badda1881bc7ed4483f20f6809b39a54f6671cc35cda18bfe554cd8e0
4
+
5
+ test:
6
+ secret_key_base: 3229572c7449e158994a35b38fc5acf0ac8136245be074657394f913cc025284f7adee7ca75deaf637ae3e54c8c50d8cdfcd2ea1ef40c53afcd25e5c27fa11f7
7
+ secret_pepper: db5ef161873f4b4cd966ff042c448282e8243a0a4e090347370360796ecc769f384d898badda1881bc7ed4483f20f6809b39a54f6671cc35cda18bfe554cd8e0
8
+
9
+ production:
10
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
11
+ secret_pepper: <%= ENV["SECRET_PEPPER"] %>
12
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Portalier
@@ -30,104 +30,104 @@ cert_chain:
30
30
  KVqCN//9bevjMk5OiMi9X3Wu/GtVWDwC6OTWFWKd54KgbuWlakO8LC1SMmStnCIF
31
31
  W4qpyMWMZMcB4ZN/0mUVzY5xwrislBtsmQVUSw==
32
32
  -----END CERTIFICATE-----
33
- date: 2014-02-07 00:00:00.000000000 Z
33
+ date: 2014-04-22 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: addressable
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rails
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 3.0.0
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 3.0.0
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: sqlite3
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: bcrypt-ruby
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: scrypt
93
93
  requirement: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  type: :development
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: minitest
107
107
  requirement: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  type: :development
113
113
  prerelease: false
114
114
  version_requirements: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: capybara
121
121
  requirement: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  type: :development
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  description: Authentication engine for Ruby on Rails
@@ -137,8 +137,8 @@ executables: []
137
137
  extensions: []
138
138
  extra_rdoc_files: []
139
139
  files:
140
- - .gitignore
141
- - .travis.yml
140
+ - ".gitignore"
141
+ - ".travis.yml"
142
142
  - LICENSE
143
143
  - README.rdoc
144
144
  - Rakefile
@@ -262,6 +262,7 @@ files:
262
262
  - test/rails_app/config/initializers/session_store.rb
263
263
  - test/rails_app/config/locales/janus.en.yml
264
264
  - test/rails_app/config/routes.rb
265
+ - test/rails_app/config/secrets.yml
265
266
  - test/rails_app/db/migrate/20110323153820_create_users.rb
266
267
  - test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb
267
268
  - test/rails_app/db/migrate/20130412104138_create_admins.rb
@@ -292,17 +293,17 @@ require_paths:
292
293
  - lib
293
294
  required_ruby_version: !ruby/object:Gem::Requirement
294
295
  requirements:
295
- - - '>='
296
+ - - ">="
296
297
  - !ruby/object:Gem::Version
297
298
  version: '0'
298
299
  required_rubygems_version: !ruby/object:Gem::Requirement
299
300
  requirements:
300
- - - '>='
301
+ - - ">="
301
302
  - !ruby/object:Gem::Version
302
303
  version: '0'
303
304
  requirements: []
304
305
  rubyforge_project:
305
- rubygems_version: 2.0.14
306
+ rubygems_version: 2.2.2
306
307
  signing_key:
307
308
  specification_version: 4
308
309
  summary: Authentication engine for Ruby on Rails
@@ -369,6 +370,7 @@ test_files:
369
370
  - test/rails_app/config/initializers/session_store.rb
370
371
  - test/rails_app/config/locales/janus.en.yml
371
372
  - test/rails_app/config/routes.rb
373
+ - test/rails_app/config/secrets.yml
372
374
  - test/rails_app/db/migrate/20110323153820_create_users.rb
373
375
  - test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb
374
376
  - test/rails_app/db/migrate/20130412104138_create_admins.rb
metadata.gz.sig CHANGED
Binary file