authpwn_rails 0.10.7 → 0.10.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -6
- data/Gemfile.lock +48 -42
- data/VERSION +1 -1
- data/app/models/credentials/facebook.rb +1 -1
- data/app/models/credentials/token.rb +21 -4
- data/authpwn_rails.gemspec +17 -14
- data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.html.erb +4 -2
- data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.text.erb +1 -1
- data/lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.html.erb +4 -2
- data/lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.text.erb +1 -1
- data/lib/authpwn_rails/generators/templates/session_mailer.rb +4 -4
- data/lib/authpwn_rails/generators/templates/session_mailer_test.rb +6 -6
- data/lib/authpwn_rails/session.rb +1 -1
- data/lib/authpwn_rails/session_controller.rb +3 -3
- data/lib/authpwn_rails/session_mailer.rb +21 -17
- data/test/session_mailer_api_test.rb +6 -4
- metadata +33 -22
data/Gemfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
source
|
1
|
+
source :rubygems
|
2
|
+
|
2
3
|
gem 'fbgraph_rails', '>= 0.2.2'
|
3
|
-
gem 'rails', '>= 3.2.0
|
4
|
+
gem 'rails', '>= 3.2.0'
|
4
5
|
|
5
6
|
group :development do
|
6
|
-
gem 'bundler', '
|
7
|
-
gem 'flexmock', '
|
8
|
-
gem 'jeweler', '
|
9
|
-
gem 'rcov', '>= 0', :platform => :
|
7
|
+
gem 'bundler', '>= 1.0.0'
|
8
|
+
gem 'flexmock', '>= 0.9.0'
|
9
|
+
gem 'jeweler', '>= 1.8.0'
|
10
|
+
gem 'rcov', '>= 0', :platform => :mri_18
|
11
|
+
gem 'simplecov', '>= 0', :platform => :mri_19
|
10
12
|
gem 'sqlite3', '>= 1.3.5'
|
11
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (3.2.
|
5
|
-
actionpack (= 3.2.
|
6
|
-
mail (~> 2.
|
7
|
-
actionpack (3.2.
|
8
|
-
activemodel (= 3.2.
|
9
|
-
activesupport (= 3.2.
|
4
|
+
actionmailer (3.2.1)
|
5
|
+
actionpack (= 3.2.1)
|
6
|
+
mail (~> 2.4.0)
|
7
|
+
actionpack (3.2.1)
|
8
|
+
activemodel (= 3.2.1)
|
9
|
+
activesupport (= 3.2.1)
|
10
10
|
builder (~> 3.0.0)
|
11
11
|
erubis (~> 2.7.0)
|
12
|
-
journey (~> 1.0.
|
12
|
+
journey (~> 1.0.1)
|
13
13
|
rack (~> 1.4.0)
|
14
14
|
rack-cache (~> 1.1)
|
15
15
|
rack-test (~> 0.6.1)
|
16
16
|
sprockets (~> 2.1.2)
|
17
|
-
activemodel (3.2.
|
18
|
-
activesupport (= 3.2.
|
17
|
+
activemodel (3.2.1)
|
18
|
+
activesupport (= 3.2.1)
|
19
19
|
builder (~> 3.0.0)
|
20
|
-
activerecord (3.2.
|
21
|
-
activemodel (= 3.2.
|
22
|
-
activesupport (= 3.2.
|
23
|
-
arel (~> 3.0.0
|
20
|
+
activerecord (3.2.1)
|
21
|
+
activemodel (= 3.2.1)
|
22
|
+
activesupport (= 3.2.1)
|
23
|
+
arel (~> 3.0.0)
|
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.1)
|
26
|
+
activemodel (= 3.2.1)
|
27
|
+
activesupport (= 3.2.1)
|
28
|
+
activesupport (3.2.1)
|
29
29
|
i18n (~> 0.6)
|
30
30
|
multi_json (~> 1.0)
|
31
31
|
addressable (2.2.6)
|
32
|
-
arel (3.0.0
|
32
|
+
arel (3.0.0)
|
33
33
|
builder (3.0.0)
|
34
34
|
erubis (2.7.0)
|
35
|
-
faraday (0.7.
|
36
|
-
addressable (~> 2.2
|
37
|
-
multipart-post (~> 1.1
|
38
|
-
rack (
|
35
|
+
faraday (0.7.6)
|
36
|
+
addressable (~> 2.2)
|
37
|
+
multipart-post (~> 1.1)
|
38
|
+
rack (~> 1.1)
|
39
39
|
fbgraph (1.9.0)
|
40
40
|
activesupport
|
41
41
|
faraday (>= 0.7.5)
|
@@ -55,13 +55,14 @@ GEM
|
|
55
55
|
hashie (1.2.0)
|
56
56
|
hike (1.2.1)
|
57
57
|
i18n (0.6.0)
|
58
|
-
jeweler (1.
|
58
|
+
jeweler (1.8.3)
|
59
59
|
bundler (~> 1.0)
|
60
60
|
git (>= 1.2.5)
|
61
61
|
rake
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
rdoc
|
63
|
+
journey (1.0.1)
|
64
|
+
json (1.6.5)
|
65
|
+
mail (2.4.1)
|
65
66
|
i18n (>= 0.4.0)
|
66
67
|
mime-types (~> 1.16)
|
67
68
|
treetop (~> 1.4.8)
|
@@ -72,34 +73,38 @@ GEM
|
|
72
73
|
faraday (~> 0.7)
|
73
74
|
multi_json (~> 1.0)
|
74
75
|
polyglot (0.3.3)
|
75
|
-
rack (1.4.
|
76
|
+
rack (1.4.1)
|
76
77
|
rack-cache (1.1)
|
77
78
|
rack (>= 0.4)
|
78
79
|
rack-ssl (1.3.2)
|
79
80
|
rack
|
80
81
|
rack-test (0.6.1)
|
81
82
|
rack (>= 1.0)
|
82
|
-
rails (3.2.
|
83
|
-
actionmailer (= 3.2.
|
84
|
-
actionpack (= 3.2.
|
85
|
-
activerecord (= 3.2.
|
86
|
-
activeresource (= 3.2.
|
87
|
-
activesupport (= 3.2.
|
83
|
+
rails (3.2.1)
|
84
|
+
actionmailer (= 3.2.1)
|
85
|
+
actionpack (= 3.2.1)
|
86
|
+
activerecord (= 3.2.1)
|
87
|
+
activeresource (= 3.2.1)
|
88
|
+
activesupport (= 3.2.1)
|
88
89
|
bundler (~> 1.0)
|
89
|
-
railties (= 3.2.
|
90
|
-
railties (3.2.
|
91
|
-
actionpack (= 3.2.
|
92
|
-
activesupport (= 3.2.
|
90
|
+
railties (= 3.2.1)
|
91
|
+
railties (3.2.1)
|
92
|
+
actionpack (= 3.2.1)
|
93
|
+
activesupport (= 3.2.1)
|
93
94
|
rack-ssl (~> 1.3.2)
|
94
95
|
rake (>= 0.8.7)
|
95
96
|
rdoc (~> 3.4)
|
96
97
|
thor (~> 0.14.6)
|
97
98
|
rake (0.9.2.2)
|
98
|
-
rcov (0.
|
99
|
+
rcov (1.0.0)
|
99
100
|
rdoc (3.12)
|
100
101
|
json (~> 1.4)
|
101
102
|
rest-client (1.6.7)
|
102
103
|
mime-types (>= 1.16)
|
104
|
+
simplecov (0.5.4)
|
105
|
+
multi_json (~> 1.0.3)
|
106
|
+
simplecov-html (~> 0.5.3)
|
107
|
+
simplecov-html (0.5.3)
|
103
108
|
sprockets (2.1.2)
|
104
109
|
hike (~> 1.2)
|
105
110
|
rack (~> 1.0)
|
@@ -116,10 +121,11 @@ PLATFORMS
|
|
116
121
|
ruby
|
117
122
|
|
118
123
|
DEPENDENCIES
|
119
|
-
bundler (
|
124
|
+
bundler (>= 1.0.0)
|
120
125
|
fbgraph_rails (>= 0.2.2)
|
121
|
-
flexmock (
|
122
|
-
jeweler (
|
123
|
-
rails (>= 3.2.0
|
126
|
+
flexmock (>= 0.9.0)
|
127
|
+
jeweler (>= 1.8.0)
|
128
|
+
rails (>= 3.2.0)
|
124
129
|
rcov
|
130
|
+
simplecov
|
125
131
|
sqlite3 (>= 1.3.5)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.8
|
@@ -51,7 +51,7 @@ class Facebook < ::Credential
|
|
51
51
|
# encrypted OAuth2 tokens don't have UIDs anymore, so this method is an
|
52
52
|
# interim hack for old code that still depends on it.
|
53
53
|
def self.uid_from_token(access_token)
|
54
|
-
FBGraphRails.fbclient(access_token).selection.me.info
|
54
|
+
FBGraphRails.fbclient(access_token).selection.me.info![:id].to_s
|
55
55
|
end
|
56
56
|
|
57
57
|
# Forms should not be able to touch any attribute.
|
@@ -1,5 +1,19 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
|
3
|
+
# :nodoc: Backport urlsafe_base64 to 1.8.7.
|
4
|
+
unless SecureRandom.respond_to? :urlsafe_base64
|
5
|
+
SecureRandom.class_eval do
|
6
|
+
# :nodoc: lifted from 1.9.3 securerandom.rb, line 190
|
7
|
+
def self.urlsafe_base64(n=nil, padding=false)
|
8
|
+
s = [random_bytes(n)].pack("m*")
|
9
|
+
s.delete!("\n")
|
10
|
+
s.tr!("+/", "-_")
|
11
|
+
s.delete!("=") if !padding
|
12
|
+
s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
# :namespace
|
4
18
|
module Credentials
|
5
19
|
|
@@ -88,10 +102,13 @@ class Token < ::Credential
|
|
88
102
|
token.save!
|
89
103
|
token
|
90
104
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
105
|
+
|
106
|
+
if SecureRandom.respond_to? :urlsafe_base64
|
107
|
+
# Generates a random token code.
|
108
|
+
def self.random_code
|
109
|
+
SecureRandom.urlsafe_base64(32)
|
110
|
+
end
|
111
|
+
else
|
95
112
|
end
|
96
113
|
|
97
114
|
# Use codes instead of exposing ActiveRecord IDs.
|
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.10.
|
8
|
+
s.version = "0.10.8"
|
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-02-07"
|
13
13
|
s.description = "Works with Facebook."
|
14
14
|
s.email = "victor@costan.us"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -110,28 +110,31 @@ Gem::Specification.new do |s|
|
|
110
110
|
|
111
111
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
112
112
|
s.add_runtime_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
|
113
|
-
s.add_runtime_dependency(%q<rails>, [">= 3.2.0
|
114
|
-
s.add_development_dependency(%q<bundler>, ["
|
115
|
-
s.add_development_dependency(%q<flexmock>, ["
|
116
|
-
s.add_development_dependency(%q<jeweler>, ["
|
113
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.2.0"])
|
114
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
115
|
+
s.add_development_dependency(%q<flexmock>, [">= 0.9.0"])
|
116
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.8.0"])
|
117
117
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
118
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
118
119
|
s.add_development_dependency(%q<sqlite3>, [">= 1.3.5"])
|
119
120
|
else
|
120
121
|
s.add_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
|
121
|
-
s.add_dependency(%q<rails>, [">= 3.2.0
|
122
|
-
s.add_dependency(%q<bundler>, ["
|
123
|
-
s.add_dependency(%q<flexmock>, ["
|
124
|
-
s.add_dependency(%q<jeweler>, ["
|
122
|
+
s.add_dependency(%q<rails>, [">= 3.2.0"])
|
123
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
124
|
+
s.add_dependency(%q<flexmock>, [">= 0.9.0"])
|
125
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.0"])
|
125
126
|
s.add_dependency(%q<rcov>, [">= 0"])
|
127
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
126
128
|
s.add_dependency(%q<sqlite3>, [">= 1.3.5"])
|
127
129
|
end
|
128
130
|
else
|
129
131
|
s.add_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
|
130
|
-
s.add_dependency(%q<rails>, [">= 3.2.0
|
131
|
-
s.add_dependency(%q<bundler>, ["
|
132
|
-
s.add_dependency(%q<flexmock>, ["
|
133
|
-
s.add_dependency(%q<jeweler>, ["
|
132
|
+
s.add_dependency(%q<rails>, [">= 3.2.0"])
|
133
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
134
|
+
s.add_dependency(%q<flexmock>, [">= 0.9.0"])
|
135
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.0"])
|
134
136
|
s.add_dependency(%q<rcov>, [">= 0"])
|
137
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
135
138
|
s.add_dependency(%q<sqlite3>, [">= 1.3.5"])
|
136
139
|
end
|
137
140
|
end
|
data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.html.erb
CHANGED
@@ -5,13 +5,15 @@
|
|
5
5
|
|
6
6
|
<p>
|
7
7
|
You are receiving this e-mail because someone (hopefully you) registered
|
8
|
-
an account at
|
8
|
+
an account at
|
9
|
+
<%= link_to @host, root_url(:host => @host, :protocol => @protocol) %>
|
9
10
|
using your e-mail address.
|
10
11
|
</p>
|
11
12
|
|
12
13
|
<p>
|
13
14
|
Please go
|
14
|
-
<%= link_to 'here', token_session_url(@token, :host => @host
|
15
|
+
<%= link_to 'here', token_session_url(@token, :host => @host,
|
16
|
+
:protocol => @protocol) %>
|
15
17
|
to confirm your e-mail address.
|
16
18
|
</p>
|
17
19
|
|
data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.text.erb
CHANGED
@@ -5,7 +5,7 @@ You are receiving this e-mail because someone (hopefully you) registered an
|
|
5
5
|
account at <%= @host %> using your e-mail address.
|
6
6
|
|
7
7
|
Please go to the address below to confirm your e-mail address.
|
8
|
-
<%=
|
8
|
+
<%= token_session_url @token, :host => @host, :protocol => @protocol %>
|
9
9
|
|
10
10
|
If you haven't registered an account, please ignore this e-mail. Someone most
|
11
11
|
likely mistyped their e-mail.
|
@@ -5,13 +5,15 @@
|
|
5
5
|
|
6
6
|
<p>
|
7
7
|
You are receiving this e-mail because someone (hopefully you) requested a
|
8
|
-
password reset for your
|
8
|
+
password reset for your
|
9
|
+
<%= link_to @host, root_url(:host => @host, :protocol => @protocol) %>
|
9
10
|
account.
|
10
11
|
</p>
|
11
12
|
|
12
13
|
<p>
|
13
14
|
Please go
|
14
|
-
<%= link_to 'here', token_session_url(@token, :host => @host
|
15
|
+
<%= link_to 'here', token_session_url(@token, :host => @host,
|
16
|
+
:protocol => @protocol) %>
|
15
17
|
to reset your password.
|
16
18
|
</p>
|
17
19
|
|
@@ -5,7 +5,7 @@ You are receiving this e-mail because someone (hopefully you) requested a
|
|
5
5
|
password reset for your <%= @host %> account.
|
6
6
|
|
7
7
|
Please go to the address below to reset your password.
|
8
|
-
<%= token_session_url
|
8
|
+
<%= token_session_url @token, :host => @host, :protocol => @protocol %>
|
9
9
|
|
10
10
|
If you haven't requested a password reset, please ignore this e-mail. Someone
|
11
11
|
most likely mistyped their e-mail.
|
@@ -1,22 +1,22 @@
|
|
1
1
|
class SessionMailer < ActionMailer::Base
|
2
2
|
include Authpwn::SessionMailer
|
3
3
|
|
4
|
-
def email_verification_subject(token, server_hostname)
|
4
|
+
def email_verification_subject(token, server_hostname, protocol)
|
5
5
|
# Consider replacing the hostname with a user-friendly application name.
|
6
6
|
"#{server_hostname} e-mail verification"
|
7
7
|
end
|
8
8
|
|
9
|
-
def email_verification_from(token, server_hostname)
|
9
|
+
def email_verification_from(token, server_hostname, protocol)
|
10
10
|
# You most likely need to replace the e-mail address below.
|
11
11
|
%Q|"#{server_hostname} staff" <admin@#{server_hostname}>|
|
12
12
|
end
|
13
13
|
|
14
|
-
def reset_password_subject(token, server_hostname)
|
14
|
+
def reset_password_subject(token, server_hostname, protocol)
|
15
15
|
# Consider replacing the hostname with a user-friendly application name.
|
16
16
|
"#{server_hostname} password reset"
|
17
17
|
end
|
18
18
|
|
19
|
-
def reset_password_from(token, server_hostname)
|
19
|
+
def reset_password_from(token, server_hostname, protocol)
|
20
20
|
# You most likely need to replace the e-mail address below.
|
21
21
|
%Q|"#{server_hostname} staff" <admin@#{server_hostname}>|
|
22
22
|
end
|
@@ -6,12 +6,12 @@ class SessionMailerTest < ActionMailer::TestCase
|
|
6
6
|
@reset_token = credentials(:jane_password_token)
|
7
7
|
@verification_token = credentials(:john_email_token)
|
8
8
|
@verification_email = credentials(:john_email).email
|
9
|
-
@
|
9
|
+
@root_url = 'hxxp://test.host/'
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'email verification email' do
|
13
|
-
email = SessionMailer.email_verification_email(@verification_token,
|
14
|
-
|
13
|
+
email = SessionMailer.email_verification_email(@verification_token,
|
14
|
+
@root_url).deliver
|
15
15
|
assert !ActionMailer::Base.deliveries.empty?
|
16
16
|
|
17
17
|
assert_equal 'test.host e-mail verification', email.subject
|
@@ -19,12 +19,12 @@ class SessionMailerTest < ActionMailer::TestCase
|
|
19
19
|
assert_equal '"test.host staff" <admin@test.host>', email['from'].to_s
|
20
20
|
assert_equal [@verification_email], email.to
|
21
21
|
assert_match @verification_token.code, email.encoded
|
22
|
-
assert_match @
|
22
|
+
assert_match @root_url, email.encoded
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'password reset email' do
|
26
26
|
email = SessionMailer.reset_password_email(@reset_email, @reset_token,
|
27
|
-
@
|
27
|
+
@root_url).deliver
|
28
28
|
assert !ActionMailer::Base.deliveries.empty?
|
29
29
|
|
30
30
|
assert_equal 'test.host password reset', email.subject
|
@@ -32,6 +32,6 @@ class SessionMailerTest < ActionMailer::TestCase
|
|
32
32
|
assert_equal '"test.host staff" <admin@test.host>', email['from'].to_s
|
33
33
|
assert_equal [@reset_email], email.to
|
34
34
|
assert_match @reset_token.code, email.encoded
|
35
|
-
assert_match @
|
35
|
+
assert_match @root_url, email.encoded
|
36
36
|
end
|
37
37
|
end
|
@@ -30,7 +30,7 @@ module ControllerInstanceMethods
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def authenticate_using_session
|
33
|
-
return
|
33
|
+
return if current_user
|
34
34
|
user_param = session[:user_exuid]
|
35
35
|
user = user_param && User.find_by_param(user_param)
|
36
36
|
self.current_user = user if user
|
@@ -11,7 +11,8 @@ module SessionController
|
|
11
11
|
extend ActiveSupport::Concern
|
12
12
|
|
13
13
|
included do
|
14
|
-
|
14
|
+
skip_filter :authenticate_using_session
|
15
|
+
authenticates_using_session :except => [:create, :reset_password, :token]
|
15
16
|
end
|
16
17
|
|
17
18
|
# GET /session/new
|
@@ -87,8 +88,7 @@ module SessionController
|
|
87
88
|
|
88
89
|
if user = (credential && credential.user)
|
89
90
|
token = Tokens::PasswordReset.random_for user
|
90
|
-
::SessionMailer.reset_password_email(@email, token,
|
91
|
-
request.host_with_port).deliver
|
91
|
+
::SessionMailer.reset_password_email(@email, token, root_url).deliver
|
92
92
|
end
|
93
93
|
|
94
94
|
respond_to do |format|
|
@@ -9,28 +9,29 @@ module SessionMailer
|
|
9
9
|
#
|
10
10
|
# Params:
|
11
11
|
# token:: the e-mail confirmation token
|
12
|
-
#
|
13
|
-
def email_verification_email(token,
|
14
|
-
@token
|
15
|
-
|
16
|
-
|
12
|
+
# root_url:: the application's root URL (e.g. "https://localhost:3000/")
|
13
|
+
def email_verification_email(token, root_url)
|
14
|
+
@token = token
|
15
|
+
@protocol, @host = *root_url.split('://', 2)
|
16
|
+
@host.slice! -1 if @host[-1] == ?/
|
17
|
+
hostname = @host.split(':', 2).first # Strip out any port.
|
17
18
|
|
18
19
|
mail :to => @token.email,
|
19
|
-
:subject => email_verification_subject(token, hostname),
|
20
|
-
:from => email_verification_from(token, hostname)
|
20
|
+
:subject => email_verification_subject(token, hostname, @protocol),
|
21
|
+
:from => email_verification_from(token, hostname, @protocol)
|
21
22
|
end
|
22
23
|
|
23
24
|
# The subject line in an e-mail verification e-mail.
|
24
25
|
#
|
25
26
|
# The authpwn generator encourages applications to override this method.
|
26
|
-
def email_verification_subject(token, server_hostname)
|
27
|
+
def email_verification_subject(token, server_hostname, protocol)
|
27
28
|
"#{server_hostname} e-mail verification"
|
28
29
|
end
|
29
30
|
|
30
31
|
# The sender e-mail address for an e-mail verification e-mail.
|
31
32
|
#
|
32
33
|
# The authpwn generator encourages applications to override this method.
|
33
|
-
def email_verification_from(token, server_hostname)
|
34
|
+
def email_verification_from(token, server_hostname, protocol)
|
34
35
|
%Q|"#{server_hostname} staff" <admin@#{server_hostname}>|
|
35
36
|
end
|
36
37
|
|
@@ -39,26 +40,29 @@ module SessionMailer
|
|
39
40
|
# Params:
|
40
41
|
# email:: the email to send the token to
|
41
42
|
# token:: the password reset token
|
42
|
-
#
|
43
|
-
def reset_password_email(email, token,
|
44
|
-
@email, @token, @host = email, token
|
43
|
+
# root_url:: the application's root URL (e.g. "https://localhost:3000/")
|
44
|
+
def reset_password_email(email, token, root_url)
|
45
|
+
@email, @token, @host, @protocol = email, token
|
46
|
+
@token = token
|
47
|
+
@protocol, @host = *root_url.split('://', 2)
|
48
|
+
@host.slice! -1 if @host[-1] == ?/
|
45
49
|
|
46
|
-
hostname = host.split(':', 2).first # Strip out any port.
|
47
|
-
mail :to => email, :
|
48
|
-
:
|
50
|
+
hostname = @host.split(':', 2).first # Strip out any port.
|
51
|
+
mail :to => email, :from => reset_password_from(token, hostname, @protocol),
|
52
|
+
:subject => reset_password_subject(token, hostname, @protocol)
|
49
53
|
end
|
50
54
|
|
51
55
|
# The subject line in a password reset e-mail.
|
52
56
|
#
|
53
57
|
# The authpwn generator encourages applications to override this method.
|
54
|
-
def reset_password_subject(token, server_hostname)
|
58
|
+
def reset_password_subject(token, server_hostname, protocol)
|
55
59
|
"#{server_hostname} password reset"
|
56
60
|
end
|
57
61
|
|
58
62
|
# The sender e-mail address for a password reset e-mail.
|
59
63
|
#
|
60
64
|
# The authpwn generator encourages applications to override this method.
|
61
|
-
def reset_password_from(token, server_hostname)
|
65
|
+
def reset_password_from(token, server_hostname, protocol)
|
62
66
|
%Q|"#{server_hostname} staff" <admin@#{server_hostname}>|
|
63
67
|
end
|
64
68
|
end # namespace Authpwn::SessionMailer
|
@@ -11,7 +11,7 @@ class SessionMailerApiTest < ActionMailer::TestCase
|
|
11
11
|
@reset_token = credentials(:jane_password_token)
|
12
12
|
@verification_token = credentials(:john_email_token)
|
13
13
|
@verification_email = credentials(:john_email).email
|
14
|
-
@
|
14
|
+
@root_url = 'hxxp://test.host:8808'
|
15
15
|
|
16
16
|
# The generator template has the same return value for reset_password_from
|
17
17
|
# and email_verification_from, so we need these stubs to ensure that the
|
@@ -44,24 +44,26 @@ class SessionMailerApiTest < ActionMailer::TestCase
|
|
44
44
|
end
|
45
45
|
|
46
46
|
test 'email verification email contents' do
|
47
|
-
email = SessionMailer.email_verification_email(@verification_token,
|
48
|
-
|
47
|
+
email = SessionMailer.email_verification_email(@verification_token,
|
48
|
+
@root_url).deliver
|
49
49
|
assert !ActionMailer::Base.deliveries.empty?
|
50
50
|
|
51
51
|
assert_equal 'test.host e-mail verification', email.subject
|
52
52
|
assert_equal ['email_check@test.host'], email.from
|
53
53
|
assert_equal [@verification_email], email.to
|
54
54
|
assert_match @verification_token.code, email.encoded
|
55
|
+
assert_match 'hxxp://test.host:8808/session/token/', email.encoded
|
55
56
|
end
|
56
57
|
|
57
58
|
test 'password reset email contents' do
|
58
59
|
email = SessionMailer.reset_password_email(@reset_email, @reset_token,
|
59
|
-
@
|
60
|
+
@root_url).deliver
|
60
61
|
assert !ActionMailer::Base.deliveries.empty?
|
61
62
|
|
62
63
|
assert_equal 'test.host password reset', email.subject
|
63
64
|
assert_equal ['reset@test.host'], email.from
|
64
65
|
assert_equal [@reset_email], email.to
|
65
66
|
assert_match @reset_token.code, email.encoded
|
67
|
+
assert_match 'hxxp://test.host:8808/session/token/', email.encoded
|
66
68
|
end
|
67
69
|
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.10.
|
4
|
+
version: 0.10.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fbgraph_rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &23571660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,54 +21,65 @@ dependencies:
|
|
21
21
|
version: 0.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *23571660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &23570400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.2.0
|
32
|
+
version: 3.2.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *23570400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &23569240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *23569240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: flexmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &23568460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *23568460
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &23585100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ! '>='
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 1.
|
65
|
+
version: 1.8.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *23585100
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &23136560 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *23136560
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: simplecov
|
82
|
+
requirement: &21228600 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: '0'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *21228600
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: sqlite3
|
82
|
-
requirement: &
|
93
|
+
requirement: &20774920 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,7 +98,7 @@ dependencies:
|
|
87
98
|
version: 1.3.5
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *20774920
|
91
102
|
description: Works with Facebook.
|
92
103
|
email: victor@costan.us
|
93
104
|
executables: []
|
@@ -192,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
203
|
version: '0'
|
193
204
|
segments:
|
194
205
|
- 0
|
195
|
-
hash:
|
206
|
+
hash: 3364552790739807555
|
196
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
208
|
none: false
|
198
209
|
requirements:
|