authpwn_rails 0.13.2 → 0.13.3

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.
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
1
  source :rubygems
2
2
 
3
3
  gem 'fbgraph_rails', '>= 0.2.2'
4
- gem 'rails', '>= 3.2.8'
4
+ gem 'rails', '>= 3.2.9'
5
5
 
6
6
  group :development do
7
- gem 'bundler', '>= 1.2.1'
8
- gem 'flexmock', '>= 1.0.3'
7
+ gem 'bundler', '>= 1.2.3'
8
+ gem 'flexmock', '>= 1.2.0'
9
9
  gem 'jeweler', '>= 1.8.4'
10
10
  gem 'rcov', '>= 0', :platform => :mri_18
11
11
  gem 'simplecov', '>= 0', :platform => :mri_19
data/Gemfile.lock CHANGED
@@ -1,31 +1,31 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.2.8)
5
- actionpack (= 3.2.8)
4
+ actionmailer (3.2.9)
5
+ actionpack (= 3.2.9)
6
6
  mail (~> 2.4.4)
7
- actionpack (3.2.8)
8
- activemodel (= 3.2.8)
9
- activesupport (= 3.2.8)
7
+ actionpack (3.2.9)
8
+ activemodel (= 3.2.9)
9
+ activesupport (= 3.2.9)
10
10
  builder (~> 3.0.0)
11
11
  erubis (~> 2.7.0)
12
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
- sprockets (~> 2.1.3)
17
- activemodel (3.2.8)
18
- activesupport (= 3.2.8)
16
+ sprockets (~> 2.2.1)
17
+ activemodel (3.2.9)
18
+ activesupport (= 3.2.9)
19
19
  builder (~> 3.0.0)
20
- activerecord (3.2.8)
21
- activemodel (= 3.2.8)
22
- activesupport (= 3.2.8)
20
+ activerecord (3.2.9)
21
+ activemodel (= 3.2.9)
22
+ activesupport (= 3.2.9)
23
23
  arel (~> 3.0.2)
24
24
  tzinfo (~> 0.3.29)
25
- activeresource (3.2.8)
26
- activemodel (= 3.2.8)
27
- activesupport (= 3.2.8)
28
- activesupport (3.2.8)
25
+ activeresource (3.2.9)
26
+ activemodel (= 3.2.9)
27
+ activesupport (= 3.2.9)
28
+ activesupport (3.2.9)
29
29
  i18n (~> 0.6)
30
30
  multi_json (~> 1.0)
31
31
  arel (3.0.2)
@@ -47,7 +47,7 @@ GEM
47
47
  json (>= 1.6.1)
48
48
  oauth2 (>= 0.5.0)
49
49
  rails (>= 3.1.0)
50
- flexmock (1.0.4)
50
+ flexmock (1.2.0)
51
51
  git (1.2.5)
52
52
  hashie (1.2.0)
53
53
  hike (1.2.1)
@@ -67,7 +67,7 @@ GEM
67
67
  mime-types (~> 1.16)
68
68
  treetop (~> 1.4.8)
69
69
  mime-types (1.19)
70
- multi_json (1.3.6)
70
+ multi_json (1.5.0)
71
71
  multipart-post (1.1.5)
72
72
  mysql2 (0.3.11)
73
73
  oauth2 (0.8.0)
@@ -85,22 +85,22 @@ GEM
85
85
  rack
86
86
  rack-test (0.6.2)
87
87
  rack (>= 1.0)
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)
88
+ rails (3.2.9)
89
+ actionmailer (= 3.2.9)
90
+ actionpack (= 3.2.9)
91
+ activerecord (= 3.2.9)
92
+ activeresource (= 3.2.9)
93
+ activesupport (= 3.2.9)
94
94
  bundler (~> 1.0)
95
- railties (= 3.2.8)
96
- railties (3.2.8)
97
- actionpack (= 3.2.8)
98
- activesupport (= 3.2.8)
95
+ railties (= 3.2.9)
96
+ railties (3.2.9)
97
+ actionpack (= 3.2.9)
98
+ activesupport (= 3.2.9)
99
99
  rack-ssl (~> 1.3.2)
100
100
  rake (>= 0.8.7)
101
101
  rdoc (~> 3.4)
102
102
  thor (>= 0.14.6, < 2.0)
103
- rake (0.9.2.2)
103
+ rake (10.0.3)
104
104
  rcov (1.0.0)
105
105
  rdoc (3.12)
106
106
  json (~> 1.4)
@@ -110,29 +110,30 @@ GEM
110
110
  multi_json (~> 1.0)
111
111
  simplecov-html (~> 0.7.1)
112
112
  simplecov-html (0.7.1)
113
- sprockets (2.1.3)
113
+ sprockets (2.2.2)
114
114
  hike (~> 1.2)
115
+ multi_json (~> 1.0)
115
116
  rack (~> 1.0)
116
117
  tilt (~> 1.1, != 1.3.0)
117
118
  sqlite3 (1.3.6)
118
119
  thor (0.16.0)
119
120
  tilt (1.3.3)
120
- treetop (1.4.11)
121
+ treetop (1.4.12)
121
122
  polyglot
122
123
  polyglot (>= 0.3.1)
123
- tzinfo (0.3.33)
124
+ tzinfo (0.3.35)
124
125
 
125
126
  PLATFORMS
126
127
  ruby
127
128
 
128
129
  DEPENDENCIES
129
- bundler (>= 1.2.1)
130
+ bundler (>= 1.2.3)
130
131
  fbgraph_rails (>= 0.2.2)
131
- flexmock (>= 1.0.3)
132
+ flexmock (>= 1.2.0)
132
133
  jeweler (>= 1.8.4)
133
134
  mysql2 (>= 0.3.11)
134
135
  pg (>= 0.14.1)
135
- rails (>= 3.2.8)
136
+ rails (>= 3.2.9)
136
137
  rcov
137
138
  simplecov
138
139
  sqlite3 (>= 1.3.6)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.2
1
+ 0.13.3
@@ -1,6 +1,6 @@
1
1
  # :namespace
2
2
  module Credentials
3
-
3
+
4
4
  # Associates a Facebook account and OAuth2 token with an account.
5
5
  class Facebook < ::Credential
6
6
  # The Graph API object ID of the Facebook account.
@@ -20,7 +20,7 @@ class Facebook < ::Credential
20
20
  # FBGraph client loaded with this access token.
21
21
  def facebook_client
22
22
  @client ||= FBGraphRails.fbclient(access_token)
23
- end
23
+ end
24
24
 
25
25
  # Finds or creates the model containing a token.
26
26
  #
@@ -44,7 +44,7 @@ class Facebook < ::Credential
44
44
  end
45
45
  credential
46
46
  end
47
-
47
+
48
48
  # Extracts the Facebook user ID from a OAuth2 token.
49
49
  #
50
50
  # This used to be a hack that pulled the UID out of an OAuth2 token. The new
@@ -53,9 +53,9 @@ class Facebook < ::Credential
53
53
  def self.uid_from_token(access_token)
54
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.
58
58
  attr_accessible
59
- end # class Credentials::Facebook
59
+ end # class Credentials::Facebook
60
60
 
61
61
  end # namespace Credentials
@@ -19,7 +19,7 @@ class Password < ::Credential
19
19
  # Passwords don't expire by default, because it is non-trivial to get e-mail
20
20
  # delivery working in Rails, which is necessary for recovering from expired
21
21
  # passwords.
22
- self.expires_after = nil
22
+ self.expires_after = Authpwn::Engine.config.authpwn.password_expiration
23
23
 
24
24
  # Compares a plain-text password against the password hash in this credential.
25
25
  #
@@ -12,8 +12,9 @@ class EmailVerification < Tokens::OneTime
12
12
  alias_attribute :email, :key
13
13
  validates :email, :presence => true
14
14
 
15
- # Decent compromise between convenience and security.
16
- self.expires_after = 3.days
15
+ # Verification tokens only work this much time after they have been issued.
16
+ self.expires_after =
17
+ Authpwn::Engine.config.authpwn.email_verification_expiration
17
18
 
18
19
  # Creates a token with a random code that verifies the given e-mail address.
19
20
  def self.random_for(email_credential)
@@ -3,8 +3,8 @@ module Tokens
3
3
 
4
4
  # Lets the user to change their password without knowing the old one.
5
5
  class PasswordReset < Tokens::OneTime
6
- # Decent compromise between convenience and security.
7
- self.expires_after = 3.days
6
+ # Password reset tokens only work this much time after they've been issued.
7
+ self.expires_after = Authpwn::Engine.config.authpwn.password_reset_expiration
8
8
 
9
9
  # Blanks the user's old password, so the new password form won't ask for it.
10
10
  #
@@ -14,8 +14,8 @@ class SessionUid < Tokens::Base
14
14
  # The IP of the computer that received this suid.
15
15
  validates :browser_ip, :presence => true
16
16
 
17
- # Decent compromise between convenience and security.
18
- self.expires_after = 14.days
17
+ # Browser users are logged out if they don't hit the app in this much time.
18
+ self.expires_after = Authpwn::Engine.config.authpwn.session_expiration
19
19
 
20
20
  # Creates a new session UID token for a user.
21
21
  #
@@ -34,7 +34,7 @@ class SessionUid < Tokens::Base
34
34
  # When a session UID is used to authenticate a user, its updated_at time is
35
35
  # refreshed if it differs from the current time by this much.
36
36
  class_attribute :updates_after, :instance_writer => false
37
- self.updates_after = 1.hour
37
+ self.updates_after = Authpwn::Engine.config.authpwn.session_precision
38
38
 
39
39
  # Updates the time associated with the session.
40
40
  def spend
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "authpwn_rails"
8
- s.version = "0.13.2"
8
+ s.version = "0.13.3"
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-10-19"
12
+ s.date = "2012-12-19"
13
13
  s.description = "Works with Facebook."
14
14
  s.email = "victor@costan.us"
15
15
  s.extra_rdoc_files = [
@@ -95,6 +95,8 @@ Gem::Specification.new do |s|
95
95
  "test/helpers/autoload_path.rb",
96
96
  "test/helpers/db_setup.rb",
97
97
  "test/helpers/fbgraph.rb",
98
+ "test/helpers/rails.rb",
99
+ "test/helpers/rails_undo.rb",
98
100
  "test/helpers/routes.rb",
99
101
  "test/helpers/view_helpers.rb",
100
102
  "test/http_basic_controller_test.rb",
@@ -120,9 +122,9 @@ Gem::Specification.new do |s|
120
122
 
121
123
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
122
124
  s.add_runtime_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
123
- s.add_runtime_dependency(%q<rails>, [">= 3.2.8"])
124
- s.add_development_dependency(%q<bundler>, [">= 1.2.1"])
125
- s.add_development_dependency(%q<flexmock>, [">= 1.0.3"])
125
+ s.add_runtime_dependency(%q<rails>, [">= 3.2.9"])
126
+ s.add_development_dependency(%q<bundler>, [">= 1.2.3"])
127
+ s.add_development_dependency(%q<flexmock>, [">= 1.2.0"])
126
128
  s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
127
129
  s.add_development_dependency(%q<rcov>, [">= 0"])
128
130
  s.add_development_dependency(%q<simplecov>, [">= 0"])
@@ -131,9 +133,9 @@ Gem::Specification.new do |s|
131
133
  s.add_development_dependency(%q<sqlite3>, [">= 1.3.6"])
132
134
  else
133
135
  s.add_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
134
- s.add_dependency(%q<rails>, [">= 3.2.8"])
135
- s.add_dependency(%q<bundler>, [">= 1.2.1"])
136
- s.add_dependency(%q<flexmock>, [">= 1.0.3"])
136
+ s.add_dependency(%q<rails>, [">= 3.2.9"])
137
+ s.add_dependency(%q<bundler>, [">= 1.2.3"])
138
+ s.add_dependency(%q<flexmock>, [">= 1.2.0"])
137
139
  s.add_dependency(%q<jeweler>, [">= 1.8.4"])
138
140
  s.add_dependency(%q<rcov>, [">= 0"])
139
141
  s.add_dependency(%q<simplecov>, [">= 0"])
@@ -143,9 +145,9 @@ Gem::Specification.new do |s|
143
145
  end
144
146
  else
145
147
  s.add_dependency(%q<fbgraph_rails>, [">= 0.2.2"])
146
- s.add_dependency(%q<rails>, [">= 3.2.8"])
147
- s.add_dependency(%q<bundler>, [">= 1.2.1"])
148
- s.add_dependency(%q<flexmock>, [">= 1.0.3"])
148
+ s.add_dependency(%q<rails>, [">= 3.2.9"])
149
+ s.add_dependency(%q<bundler>, [">= 1.2.3"])
150
+ s.add_dependency(%q<flexmock>, [">= 1.2.0"])
149
151
  s.add_dependency(%q<jeweler>, [">= 1.8.4"])
150
152
  s.add_dependency(%q<rcov>, [">= 0"])
151
153
  s.add_dependency(%q<simplecov>, [">= 0"])
@@ -1,10 +1,25 @@
1
1
  require 'authpwn_rails'
2
+
3
+ require 'active_support/core_ext/numeric/time.rb'
2
4
  require 'rails'
3
5
 
4
6
  # :nodoc: namespace
5
7
  module Authpwn
6
8
 
7
9
  class Engine < Rails::Engine
10
+ config.authpwn = ActiveSupport::OrderedOptions.new
11
+
12
+ # Credentials::Password.expires_after
13
+ config.authpwn.password_expiration = nil
14
+ # Tokens::EmailVerification.expires_after
15
+ config.authpwn.email_verification_expiration = 3.days
16
+ # Tokens::PasswordReset.expires_after
17
+ config.authpwn.password_reset_expiration = 3.days
18
+ # Tokens::SessionUid.expires_after
19
+ config.authpwn.session_expiration = 14.days
20
+ # Tokens::SessionUid.updates_after
21
+ config.authpwn.session_precision = 14.days
22
+
8
23
  generators do
9
24
  require 'authpwn_rails/generators/all_generator.rb'
10
25
  end
@@ -5,14 +5,14 @@
5
5
  # flow, which relies on e-mail delivery. If your application doesn't implement
6
6
  # password reset, or doesn't have working e-mail delivery, disable password
7
7
  # expiration.
8
- Credentials::Password.expires_after = 1.year
8
+ Rails.application.config.authpwn.password_expiration = 1.year
9
9
 
10
10
  # These codes are sent in plaintext in e-mails, be somewhat aggressive.
11
- Tokens::EmailVerification.expires_after = 3.days
12
- Tokens::PasswordReset.expires_after = 3.days
11
+ Rails.application.config.authpwn.email_verification_expiration = 3.days
12
+ Rails.application.config.authpwn.password_reset_expiration = 3.days
13
13
 
14
14
  # Users are identified by cookies whose codes are looked up in the database.
15
- Tokens::SessionUid.expires_after = 14.days
15
+ Rails.application.config.authpwn.session_expiration = 14.days
16
16
  # This knob is a compromise between accurate session expiration and write
17
17
  # workload on the database. Keep it below 1% of expires_after.
18
- Tokens::SessionUid.updates_after = 1.hour
18
+ Rails.application.config.authpwn.session_precision = 1.hour
@@ -0,0 +1,24 @@
1
+ # Fake application.
2
+ module AuthpwnApp
3
+ class Application
4
+ def config
5
+ @_config ||= Authpwn::Engine.config
6
+ end
7
+ end
8
+ end
9
+
10
+ # Mock Rails.application.
11
+ module Rails
12
+ class <<self
13
+ # Used by the initializer.
14
+ alias_method :_real_application, :application
15
+ def application
16
+ @_app ||= AuthpwnApp::Application.new
17
+ end
18
+
19
+ # Used by fbgraph.
20
+ def root
21
+ File.expand_path '../..', File.dirname(__FILE__)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module Rails
2
+ class <<self
3
+ remove_method :application
4
+ alias_method :application, :_real_application
5
+ remove_method :_real_application
6
+ end
7
+ end
data/test/test_helper.rb CHANGED
@@ -2,9 +2,8 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
 
4
4
  require 'action_mailer'
5
- require 'action_pack'
6
5
  require 'active_record'
7
- require 'active_support'
6
+ require 'rails'
8
7
 
9
8
  require 'fbgraph_rails'
10
9
  require 'fbgraph_rails/controller'
@@ -20,7 +19,11 @@ require 'helpers/action_mailer.rb'
20
19
  require 'helpers/autoload_path.rb'
21
20
  require 'helpers/db_setup.rb'
22
21
  require 'helpers/fbgraph.rb'
22
+ require 'helpers/rails.rb'
23
23
  require 'helpers/routes.rb'
24
24
 
25
25
  # Simulate Rails' initializer loading.
26
26
  require 'authpwn_rails/generators/templates/initializer.rb'
27
+
28
+ # Rails stubbing is only needed by the initializer, and breaks tests.
29
+ require 'helpers/rails_undo.rb'
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.13.2
4
+ version: 0.13.3
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-10-19 00:00:00.000000000 Z
12
+ date: 2012-12-19 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.8
37
+ version: 3.2.9
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.8
45
+ version: 3.2.9
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.2.1
53
+ version: 1.2.3
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.2.1
61
+ version: 1.2.3
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: 1.0.3
69
+ version: 1.2.0
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: 1.0.3
77
+ version: 1.2.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: jeweler
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -257,6 +257,8 @@ files:
257
257
  - test/helpers/autoload_path.rb
258
258
  - test/helpers/db_setup.rb
259
259
  - test/helpers/fbgraph.rb
260
+ - test/helpers/rails.rb
261
+ - test/helpers/rails_undo.rb
260
262
  - test/helpers/routes.rb
261
263
  - test/helpers/view_helpers.rb
262
264
  - test/http_basic_controller_test.rb
@@ -285,7 +287,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
285
287
  version: '0'
286
288
  segments:
287
289
  - 0
288
- hash: -724367736535056714
290
+ hash: 2295447293099975132
289
291
  required_rubygems_version: !ruby/object:Gem::Requirement
290
292
  none: false
291
293
  requirements: