authpwn_rails 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -4
- data/Gemfile.lock +38 -38
- data/VERSION +1 -1
- data/app/models/credentials/token.rb +20 -23
- data/app/models/tokens/email_verification.rb +8 -7
- data/authpwn_rails.gemspec +15 -14
- data/legacy/migrate_011_to_012.rb +34 -0
- data/lib/authpwn_rails/credential_model.rb +4 -4
- data/lib/authpwn_rails/generators/templates/003_create_credentials.rb +7 -3
- data/lib/authpwn_rails/generators/templates/credentials.yml +1 -1
- data/lib/authpwn_rails/generators/templates/session/password_change.html.erb +10 -2
- data/lib/authpwn_rails/generators/templates/session_controller_test.rb +18 -16
- metadata +12 -11
data/Gemfile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
3
|
gem 'fbgraph_rails', '>= 0.2.2'
|
4
|
-
gem 'rails', '>= 3.2.
|
4
|
+
gem 'rails', '>= 3.2.8'
|
5
5
|
|
6
6
|
group :development do
|
7
|
-
gem 'bundler', '>= 1.1
|
8
|
-
gem 'flexmock', '>= 0.
|
7
|
+
gem 'bundler', '>= 1.2.1'
|
8
|
+
gem 'flexmock', '>= 1.0.3'
|
9
9
|
gem 'jeweler', '>= 1.8.4'
|
10
10
|
gem 'rcov', '>= 0', :platform => :mri_18
|
11
11
|
gem 'simplecov', '>= 0', :platform => :mri_19
|
12
12
|
gem 'mysql2', '>= 0.3.11'
|
13
|
-
gem 'pg', '>= 0.14.
|
13
|
+
gem 'pg', '>= 0.14.1'
|
14
14
|
gem 'sqlite3', '>= 1.3.6'
|
15
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,37 +1,37 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (3.2.
|
5
|
-
actionpack (= 3.2.
|
4
|
+
actionmailer (3.2.8)
|
5
|
+
actionpack (= 3.2.8)
|
6
6
|
mail (~> 2.4.4)
|
7
|
-
actionpack (3.2.
|
8
|
-
activemodel (= 3.2.
|
9
|
-
activesupport (= 3.2.
|
7
|
+
actionpack (3.2.8)
|
8
|
+
activemodel (= 3.2.8)
|
9
|
+
activesupport (= 3.2.8)
|
10
10
|
builder (~> 3.0.0)
|
11
11
|
erubis (~> 2.7.0)
|
12
|
-
journey (~> 1.0.
|
12
|
+
journey (~> 1.0.4)
|
13
13
|
rack (~> 1.4.0)
|
14
14
|
rack-cache (~> 1.2)
|
15
15
|
rack-test (~> 0.6.1)
|
16
16
|
sprockets (~> 2.1.3)
|
17
|
-
activemodel (3.2.
|
18
|
-
activesupport (= 3.2.
|
17
|
+
activemodel (3.2.8)
|
18
|
+
activesupport (= 3.2.8)
|
19
19
|
builder (~> 3.0.0)
|
20
|
-
activerecord (3.2.
|
21
|
-
activemodel (= 3.2.
|
22
|
-
activesupport (= 3.2.
|
20
|
+
activerecord (3.2.8)
|
21
|
+
activemodel (= 3.2.8)
|
22
|
+
activesupport (= 3.2.8)
|
23
23
|
arel (~> 3.0.2)
|
24
24
|
tzinfo (~> 0.3.29)
|
25
|
-
activeresource (3.2.
|
26
|
-
activemodel (= 3.2.
|
27
|
-
activesupport (= 3.2.
|
28
|
-
activesupport (3.2.
|
25
|
+
activeresource (3.2.8)
|
26
|
+
activemodel (= 3.2.8)
|
27
|
+
activesupport (= 3.2.8)
|
28
|
+
activesupport (3.2.8)
|
29
29
|
i18n (~> 0.6)
|
30
30
|
multi_json (~> 1.0)
|
31
31
|
arel (3.0.2)
|
32
|
-
builder (3.0.
|
32
|
+
builder (3.0.3)
|
33
33
|
erubis (2.7.0)
|
34
|
-
faraday (0.8.
|
34
|
+
faraday (0.8.4)
|
35
35
|
multipart-post (~> 1.1)
|
36
36
|
fbgraph (1.10.0)
|
37
37
|
activesupport
|
@@ -47,21 +47,21 @@ GEM
|
|
47
47
|
json (>= 1.6.1)
|
48
48
|
oauth2 (>= 0.5.0)
|
49
49
|
rails (>= 3.1.0)
|
50
|
-
flexmock (0.
|
50
|
+
flexmock (1.0.3)
|
51
51
|
git (1.2.5)
|
52
52
|
hashie (1.2.0)
|
53
53
|
hike (1.2.1)
|
54
54
|
httpauth (0.1)
|
55
|
-
i18n (0.6.
|
55
|
+
i18n (0.6.1)
|
56
56
|
jeweler (1.8.4)
|
57
57
|
bundler (~> 1.0)
|
58
58
|
git (>= 1.2.5)
|
59
59
|
rake
|
60
60
|
rdoc
|
61
61
|
journey (1.0.4)
|
62
|
-
json (1.7.
|
63
|
-
jwt (0.1.
|
64
|
-
|
62
|
+
json (1.7.5)
|
63
|
+
jwt (0.1.5)
|
64
|
+
multi_json (>= 1.0)
|
65
65
|
mail (2.4.4)
|
66
66
|
i18n (>= 0.4.0)
|
67
67
|
mime-types (~> 1.16)
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
jwt (~> 0.1.4)
|
77
77
|
multi_json (~> 1.0)
|
78
78
|
rack (~> 1.2)
|
79
|
-
pg (0.14.
|
79
|
+
pg (0.14.1)
|
80
80
|
polyglot (0.3.3)
|
81
81
|
rack (1.4.1)
|
82
82
|
rack-cache (1.2)
|
@@ -85,17 +85,17 @@ GEM
|
|
85
85
|
rack
|
86
86
|
rack-test (0.6.1)
|
87
87
|
rack (>= 1.0)
|
88
|
-
rails (3.2.
|
89
|
-
actionmailer (= 3.2.
|
90
|
-
actionpack (= 3.2.
|
91
|
-
activerecord (= 3.2.
|
92
|
-
activeresource (= 3.2.
|
93
|
-
activesupport (= 3.2.
|
88
|
+
rails (3.2.8)
|
89
|
+
actionmailer (= 3.2.8)
|
90
|
+
actionpack (= 3.2.8)
|
91
|
+
activerecord (= 3.2.8)
|
92
|
+
activeresource (= 3.2.8)
|
93
|
+
activesupport (= 3.2.8)
|
94
94
|
bundler (~> 1.0)
|
95
|
-
railties (= 3.2.
|
96
|
-
railties (3.2.
|
97
|
-
actionpack (= 3.2.
|
98
|
-
activesupport (= 3.2.
|
95
|
+
railties (= 3.2.8)
|
96
|
+
railties (3.2.8)
|
97
|
+
actionpack (= 3.2.8)
|
98
|
+
activesupport (= 3.2.8)
|
99
99
|
rack-ssl (~> 1.3.2)
|
100
100
|
rake (>= 0.8.7)
|
101
101
|
rdoc (~> 3.4)
|
@@ -115,7 +115,7 @@ GEM
|
|
115
115
|
rack (~> 1.0)
|
116
116
|
tilt (~> 1.1, != 1.3.0)
|
117
117
|
sqlite3 (1.3.6)
|
118
|
-
thor (0.
|
118
|
+
thor (0.16.0)
|
119
119
|
tilt (1.3.3)
|
120
120
|
treetop (1.4.10)
|
121
121
|
polyglot
|
@@ -126,13 +126,13 @@ PLATFORMS
|
|
126
126
|
ruby
|
127
127
|
|
128
128
|
DEPENDENCIES
|
129
|
-
bundler (>= 1.1
|
129
|
+
bundler (>= 1.2.1)
|
130
130
|
fbgraph_rails (>= 0.2.2)
|
131
|
-
flexmock (>= 0.
|
131
|
+
flexmock (>= 1.0.3)
|
132
132
|
jeweler (>= 1.8.4)
|
133
133
|
mysql2 (>= 0.3.11)
|
134
|
-
pg (>= 0.14.
|
135
|
-
rails (>= 3.2.
|
134
|
+
pg (>= 0.14.1)
|
135
|
+
rails (>= 3.2.8)
|
136
136
|
rcov
|
137
137
|
simplecov
|
138
138
|
sqlite3 (>= 1.3.6)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.12.0
|
@@ -16,18 +16,18 @@ end
|
|
16
16
|
|
17
17
|
# :namespace
|
18
18
|
module Credentials
|
19
|
-
|
19
|
+
|
20
20
|
# Associates a secret token code with the account.
|
21
21
|
#
|
22
22
|
# Subclasses of this class are in the tokens namespace.
|
23
23
|
class Token < ::Credential
|
24
24
|
# The secret token code.
|
25
25
|
alias_attribute :code, :name
|
26
|
-
# Token names are random, so we can expect they'll be unique across the
|
27
|
-
# namespace. We need this check to enforce name uniqueness across
|
28
|
-
# token types.
|
26
|
+
# Token names are random, so we can expect they'll be unique across the
|
27
|
+
# entire namespace. We need this check to enforce name uniqueness across
|
28
|
+
# different token types.
|
29
29
|
validates :name, :format => /^[A-Za-z0-9\_\-]+$/, :presence => true,
|
30
|
-
:uniqueness => true
|
30
|
+
:uniqueness => true
|
31
31
|
|
32
32
|
# Authenticates a user using a secret token code.
|
33
33
|
#
|
@@ -40,7 +40,7 @@ class Token < ::Credential
|
|
40
40
|
credential = self.with_code code
|
41
41
|
credential ? credential.authenticate : :invalid
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
# The token matching a secret code.
|
45
45
|
def self.with_code(code)
|
46
46
|
# NOTE 1: The where query must be performed off the root type, otherwise
|
@@ -51,14 +51,14 @@ class Token < ::Credential
|
|
51
51
|
# pre-fetch them.
|
52
52
|
credential = Credential.where(:name => code).
|
53
53
|
includes(:user => :credentials).first
|
54
|
-
|
54
|
+
|
55
55
|
if credential.is_a? Credentials::Token
|
56
56
|
credential
|
57
57
|
else
|
58
58
|
nil
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
# Authenticates a user using this token.
|
63
63
|
#
|
64
64
|
# The token will be spent on successful authentication. One-time tokens are
|
@@ -73,7 +73,7 @@ class Token < ::Credential
|
|
73
73
|
spend
|
74
74
|
user
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# Updates the token's state to reflect that it was used for authentication.
|
78
78
|
#
|
79
79
|
# Tokens may become invalid after they are spent.
|
@@ -85,12 +85,12 @@ class Token < ::Credential
|
|
85
85
|
|
86
86
|
# Creates a new random token for a user.
|
87
87
|
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
88
|
+
# @param [User] user the user who will be authenticated by the token
|
89
|
+
# @param [String] key data associated with the token
|
90
|
+
# @param [Class] klass the ActiveRecord class that will be instantiated;
|
91
|
+
# it should be a subclass of Token
|
92
|
+
# @return [Credentials::Token] a newly created and saved token with a random
|
93
|
+
# code
|
94
94
|
def self.random_for(user, key = nil, klass = nil)
|
95
95
|
klass ||= self
|
96
96
|
if key.nil?
|
@@ -102,15 +102,12 @@ class Token < ::Credential
|
|
102
102
|
token.save!
|
103
103
|
token
|
104
104
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
SecureRandom.urlsafe_base64(32)
|
110
|
-
end
|
111
|
-
else
|
105
|
+
|
106
|
+
# Generates a random token code.
|
107
|
+
def self.random_code
|
108
|
+
SecureRandom.urlsafe_base64(32)
|
112
109
|
end
|
113
|
-
|
110
|
+
|
114
111
|
# Use codes instead of exposing ActiveRecord IDs.
|
115
112
|
def to_param
|
116
113
|
code
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# :namespace
|
2
2
|
module Tokens
|
3
|
-
|
3
|
+
|
4
4
|
# A token that verifies the user's ownership of their e-mail address.
|
5
5
|
class EmailVerification < OneTime
|
6
6
|
# The e-mail address verified by this token.
|
@@ -8,15 +8,15 @@ class EmailVerification < OneTime
|
|
8
8
|
# Note that it's useful to keep track of the exact e-mail address that the
|
9
9
|
# token vouches for, even if an application only allows a single e-mail per
|
10
10
|
# user. Otherwise, a user might be able to change their e-mail address and
|
11
|
-
# then use the token to verify the ownership of the wrong address.
|
11
|
+
# then use the token to verify the ownership of the wrong address.
|
12
12
|
alias_attribute :email, :key
|
13
13
|
validates :email, :presence => true
|
14
|
-
|
14
|
+
|
15
15
|
# Creates a token with a random code that verifies the given e-mail address.
|
16
16
|
def self.random_for(email_credential)
|
17
17
|
super email_credential.user, email_credential.email, self
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
# Marks the e-mail associated with the token as verified.
|
21
21
|
#
|
22
22
|
# Returns the token instance.
|
@@ -29,11 +29,12 @@ class EmailVerification < OneTime
|
|
29
29
|
super
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
# The credential whose ownership is verified by this token.
|
34
34
|
#
|
35
|
-
#
|
36
|
-
# condition and changes her e-mail address
|
35
|
+
# @return [Credentials::Email, nil] might return nil if a user is trying to
|
36
|
+
# take advantage of a race condition and changes her e-mail address
|
37
|
+
# before using the token.
|
37
38
|
def email_credential
|
38
39
|
user.credentials.find { |c| c.name == email }
|
39
40
|
end
|
data/authpwn_rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "authpwn_rails"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.12.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Victor Costan"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-09-24"
|
13
13
|
s.description = "Works with Facebook."
|
14
14
|
s.email = "victor@costan.us"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"app/models/tokens/one_time.rb",
|
36
36
|
"app/models/tokens/password_reset.rb",
|
37
37
|
"authpwn_rails.gemspec",
|
38
|
+
"legacy/migrate_011_to_012.rb",
|
38
39
|
"legacy/migrate_09_to_010.rb",
|
39
40
|
"lib/authpwn_rails.rb",
|
40
41
|
"lib/authpwn_rails/credential_model.rb",
|
@@ -113,37 +114,37 @@ Gem::Specification.new do |s|
|
|
113
114
|
|
114
115
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
115
116
|
s.add_runtime_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
|
116
|
-
s.add_runtime_dependency(%q<rails>, [">= 3.2.
|
117
|
-
s.add_development_dependency(%q<bundler>, [">= 1.1
|
118
|
-
s.add_development_dependency(%q<flexmock>, [">= 0.
|
117
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.2.8"])
|
118
|
+
s.add_development_dependency(%q<bundler>, [">= 1.2.1"])
|
119
|
+
s.add_development_dependency(%q<flexmock>, [">= 1.0.3"])
|
119
120
|
s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
|
120
121
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
121
122
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
122
123
|
s.add_development_dependency(%q<mysql2>, [">= 0.3.11"])
|
123
|
-
s.add_development_dependency(%q<pg>, [">= 0.14.
|
124
|
+
s.add_development_dependency(%q<pg>, [">= 0.14.1"])
|
124
125
|
s.add_development_dependency(%q<sqlite3>, [">= 1.3.6"])
|
125
126
|
else
|
126
127
|
s.add_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
|
127
|
-
s.add_dependency(%q<rails>, [">= 3.2.
|
128
|
-
s.add_dependency(%q<bundler>, [">= 1.1
|
129
|
-
s.add_dependency(%q<flexmock>, [">= 0.
|
128
|
+
s.add_dependency(%q<rails>, [">= 3.2.8"])
|
129
|
+
s.add_dependency(%q<bundler>, [">= 1.2.1"])
|
130
|
+
s.add_dependency(%q<flexmock>, [">= 1.0.3"])
|
130
131
|
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
131
132
|
s.add_dependency(%q<rcov>, [">= 0"])
|
132
133
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
133
134
|
s.add_dependency(%q<mysql2>, [">= 0.3.11"])
|
134
|
-
s.add_dependency(%q<pg>, [">= 0.14.
|
135
|
+
s.add_dependency(%q<pg>, [">= 0.14.1"])
|
135
136
|
s.add_dependency(%q<sqlite3>, [">= 1.3.6"])
|
136
137
|
end
|
137
138
|
else
|
138
139
|
s.add_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
|
139
|
-
s.add_dependency(%q<rails>, [">= 3.2.
|
140
|
-
s.add_dependency(%q<bundler>, [">= 1.1
|
141
|
-
s.add_dependency(%q<flexmock>, [">= 0.
|
140
|
+
s.add_dependency(%q<rails>, [">= 3.2.8"])
|
141
|
+
s.add_dependency(%q<bundler>, [">= 1.2.1"])
|
142
|
+
s.add_dependency(%q<flexmock>, [">= 1.0.3"])
|
142
143
|
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
143
144
|
s.add_dependency(%q<rcov>, [">= 0"])
|
144
145
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
145
146
|
s.add_dependency(%q<mysql2>, [">= 0.3.11"])
|
146
|
-
s.add_dependency(%q<pg>, [">= 0.14.
|
147
|
+
s.add_dependency(%q<pg>, [">= 0.14.1"])
|
147
148
|
s.add_dependency(%q<sqlite3>, [">= 1.3.6"])
|
148
149
|
end
|
149
150
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This script migrates an authpwn 0.10-0.11 database to the new 0.12 layout.
|
2
|
+
# It should be run in a rails console.
|
3
|
+
|
4
|
+
|
5
|
+
# Add updated_at to credentials.
|
6
|
+
class UpgradeCredentials < ActiveRecord::Migration
|
7
|
+
def change
|
8
|
+
change_table :credentials do |t|
|
9
|
+
t.timestamp :updated_at
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
UpgradeCredentials.migrate :up
|
14
|
+
|
15
|
+
# Populate updated_at for all credentials.
|
16
|
+
reload!
|
17
|
+
Credential.all.each do |c|
|
18
|
+
c.touch
|
19
|
+
end
|
20
|
+
|
21
|
+
# Tighten the updated_at definition, add indexing.
|
22
|
+
class FinishUpgradingCredentials < ActiveRecord::Migration
|
23
|
+
def up
|
24
|
+
change_column :credentials, :updated_at, :timestamp, :null => false
|
25
|
+
|
26
|
+
add_index :credentials, [:type, :updated_at], :unique => false,
|
27
|
+
:null => false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
FinishUpgradingCredentials.migrate :up
|
31
|
+
|
32
|
+
# Re-generate scaffolds.
|
33
|
+
Kernel.system 'rails g authpwn:all'
|
34
|
+
|
@@ -3,7 +3,7 @@ require 'active_support'
|
|
3
3
|
# :nodoc: namespace
|
4
4
|
module Authpwn
|
5
5
|
|
6
|
-
# Included by the model class that
|
6
|
+
# Included by the model class that roots various credentials.
|
7
7
|
#
|
8
8
|
# Parts of the codebase assume the model will be named Credential.
|
9
9
|
module CredentialModel
|
@@ -13,18 +13,18 @@ module CredentialModel
|
|
13
13
|
# The user whose token this is.
|
14
14
|
belongs_to :user, :inverse_of => :credentials
|
15
15
|
validates :user, :presence => true
|
16
|
-
|
16
|
+
|
17
17
|
# Name that can be used to find the token.
|
18
18
|
validates :name, :length => { :in => 1..128, :allow_nil => true },
|
19
19
|
:uniqueness => { :scope => [:type], :allow_nil => true }
|
20
|
-
|
20
|
+
|
21
21
|
# Secret information associated with the token.
|
22
22
|
validates :key, :length => { :in => 1..2.kilobytes, :allow_nil => true }
|
23
23
|
end
|
24
24
|
|
25
25
|
# Included in the metaclass of models that call pwnauth_facebook_token_model.
|
26
26
|
module ClassMethods
|
27
|
-
|
27
|
+
|
28
28
|
end # module Authpwn::FacebookTokenModel::ClassMethods
|
29
29
|
|
30
30
|
end # namespace Authpwn::FacebookTokenModel
|
@@ -4,16 +4,20 @@ class CreateCredentials < ActiveRecord::Migration
|
|
4
4
|
t.references :user, :null => false
|
5
5
|
t.string :type, :limit => 32, :null => false
|
6
6
|
t.string :name, :limit => 128, :null => true
|
7
|
-
|
7
|
+
|
8
8
|
t.boolean :verified, :null => false, :default => false
|
9
|
-
|
9
|
+
t.timestamp :updated_at, :null => false
|
10
|
+
|
10
11
|
t.binary :key, :limit => 2.kilobytes, :null => true
|
11
12
|
end
|
12
|
-
|
13
|
+
|
13
14
|
# All the credentials (maybe of a specific type) belonging to a user.
|
14
15
|
add_index :credentials, [:user_id, :type], :unique => false,
|
15
16
|
:null => false
|
16
17
|
# A specific credential, to find out what user it belongs to.
|
17
18
|
add_index :credentials, [:type, :name], :unique => true, :null => true
|
19
|
+
# Expired credentials (particularly useful for tokens).
|
20
|
+
add_index :credentials, [:type, :updated_at], :unique => false,
|
21
|
+
:null => false
|
18
22
|
end
|
19
23
|
end
|
@@ -7,6 +7,14 @@
|
|
7
7
|
<p class="alert"><%= flash[:alert] %></p>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
+
<% if @credential.updated_at %>
|
11
|
+
<p class="password_age_notice">
|
12
|
+
Your have been using the same password for
|
13
|
+
<span class="password_age">
|
14
|
+
<%= time_ago_in_words @credential.updated_at, true %>.
|
15
|
+
</span>
|
16
|
+
</p>
|
17
|
+
<% end %>
|
10
18
|
|
11
19
|
<%= form_for @credential, :url => change_password_session_path,
|
12
20
|
:as => :credential, :method => :post do |f| %>
|
@@ -19,7 +27,7 @@
|
|
19
27
|
</span>
|
20
28
|
</div>
|
21
29
|
<% end %>
|
22
|
-
|
30
|
+
|
23
31
|
<div class="field">
|
24
32
|
<%= f.label :password, 'New Password' %><br />
|
25
33
|
<span class="value">
|
@@ -34,7 +42,7 @@
|
|
34
42
|
</span>
|
35
43
|
</div>
|
36
44
|
</section>
|
37
|
-
|
45
|
+
|
38
46
|
<div class="actions">
|
39
47
|
<%= f.submit 'Change Password' %>
|
40
48
|
</div>
|
@@ -7,26 +7,26 @@ class SessionControllerTest < ActionController::TestCase
|
|
7
7
|
@password_credential = credentials(:john_password)
|
8
8
|
@token_credential = credentials(:john_email_token)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
test "user home page" do
|
12
12
|
set_session_current_user @user
|
13
13
|
get :show
|
14
|
-
|
14
|
+
|
15
15
|
assert_equal @user, assigns(:user)
|
16
16
|
assert_select 'a[href="/session"][data-method="delete"]', 'Log out'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
test "user logged in JSON request" do
|
20
20
|
set_session_current_user @user
|
21
21
|
get :show, :format => 'json'
|
22
|
-
|
22
|
+
|
23
23
|
assert_equal @user.exuid,
|
24
24
|
ActiveSupport::JSON.decode(response.body)['user']['exuid']
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
test "application welcome page" do
|
28
28
|
get :show
|
29
|
-
|
29
|
+
|
30
30
|
assert_equal User.count, assigns(:user_count)
|
31
31
|
assert_select 'a', 'Log in'
|
32
32
|
end
|
@@ -36,11 +36,11 @@ class SessionControllerTest < ActionController::TestCase
|
|
36
36
|
|
37
37
|
assert_equal({}, ActiveSupport::JSON.decode(response.body))
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
test "user signup page" do
|
41
41
|
get :new
|
42
42
|
assert_template :new
|
43
|
-
|
43
|
+
|
44
44
|
assert_select 'form[action=?]', session_path do
|
45
45
|
assert_select 'input[name="email"]'
|
46
46
|
assert_select 'input[name="password"]'
|
@@ -48,13 +48,13 @@ class SessionControllerTest < ActionController::TestCase
|
|
48
48
|
assert_select 'button[name="reset_password"]'
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
test "e-mail verification link" do
|
53
53
|
get :token, :code => @token_credential.code
|
54
54
|
assert_redirected_to session_url
|
55
55
|
assert @email_credential.reload.verified?, 'Email not verified'
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
test "password reset link" do
|
59
59
|
password_credential = credentials(:jane_password)
|
60
60
|
get :token, :code => credentials(:jane_password_token).code
|
@@ -62,12 +62,13 @@ class SessionControllerTest < ActionController::TestCase
|
|
62
62
|
assert_nil Credential.where(:id => password_credential.id).first,
|
63
63
|
'Password not cleared'
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
|
67
67
|
test "password change form" do
|
68
68
|
set_session_current_user @user
|
69
69
|
get :password_change
|
70
|
-
|
70
|
+
|
71
|
+
assert_select 'span[class="password_age"]'
|
71
72
|
assert_select 'form[action=?][method="post"]',
|
72
73
|
change_password_session_path do
|
73
74
|
assert_select 'input[name="old_password"]'
|
@@ -81,7 +82,8 @@ class SessionControllerTest < ActionController::TestCase
|
|
81
82
|
set_session_current_user @user
|
82
83
|
@password_credential.destroy
|
83
84
|
get :password_change
|
84
|
-
|
85
|
+
|
86
|
+
assert_select 'span[class="password_age"]', :count => 0
|
85
87
|
assert_select 'form[action=?][method="post"]',
|
86
88
|
change_password_session_path do
|
87
89
|
assert_select 'input[name="old_password"]', :count => 0
|
@@ -90,18 +92,18 @@ class SessionControllerTest < ActionController::TestCase
|
|
90
92
|
assert_select 'input[type=submit]'
|
91
93
|
end
|
92
94
|
end
|
93
|
-
|
95
|
+
|
94
96
|
test "password reset request" do
|
95
97
|
ActionMailer::Base.deliveries = []
|
96
98
|
|
97
99
|
assert_difference 'Credential.count', 1 do
|
98
100
|
post :reset_password, :email => @email_credential.email
|
99
101
|
end
|
100
|
-
|
102
|
+
|
101
103
|
assert !ActionMailer::Base.deliveries.empty?, 'email generated'
|
102
104
|
email = ActionMailer::Base.deliveries.last
|
103
105
|
assert_equal [@email_credential.email], email.to
|
104
|
-
|
106
|
+
|
105
107
|
assert_redirected_to new_session_url
|
106
108
|
end
|
107
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authpwn_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fbgraph_rails
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 3.2.
|
37
|
+
version: 3.2.8
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.2.
|
45
|
+
version: 3.2.8
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bundler
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.1
|
53
|
+
version: 1.2.1
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.1
|
61
|
+
version: 1.2.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: flexmock
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
69
|
+
version: 1.0.3
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 1.0.3
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: jeweler
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ! '>='
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.14.
|
149
|
+
version: 0.14.1
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.14.
|
157
|
+
version: 0.14.1
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: sqlite3
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- app/models/tokens/one_time.rb
|
198
198
|
- app/models/tokens/password_reset.rb
|
199
199
|
- authpwn_rails.gemspec
|
200
|
+
- legacy/migrate_011_to_012.rb
|
200
201
|
- legacy/migrate_09_to_010.rb
|
201
202
|
- lib/authpwn_rails.rb
|
202
203
|
- lib/authpwn_rails/credential_model.rb
|
@@ -278,7 +279,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
279
|
version: '0'
|
279
280
|
segments:
|
280
281
|
- 0
|
281
|
-
hash:
|
282
|
+
hash: 2906740583924378223
|
282
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
284
|
none: false
|
284
285
|
requirements:
|