authpwn_rails 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/VERSION +1 -1
- data/authpwn_rails.gemspec +3 -2
- data/legacy/migrate_09_to_010.rb +61 -0
- data/lib/authpwn_rails/credentials/email.rb +6 -0
- data/lib/authpwn_rails/credentials.rb +9 -3
- data/lib/authpwn_rails/generators/all_generator.rb +2 -2
- data/lib/authpwn_rails/generators/templates/{002_create_credentials.rb → 003_create_credentials.rb} +0 -0
- data/lib/authpwn_rails/generators/templates/credential.rb +0 -3
- data/lib/authpwn_rails/generators/templates/session/new.html.erb +1 -1
- data/lib/authpwn_rails.rb +1 -0
- data/test/email_credential_test.rb +6 -0
- data/test/helpers/db_setup.rb +1 -1
- data/test/session_controller_api_test.rb +1 -1
- metadata +18 -17
data/README.rdoc
CHANGED
@@ -15,6 +15,11 @@ Note: the code inside the models and controllers is tucked away in the plug-in.
|
|
15
15
|
The scaffold models and controllers are there as extension points. You will be
|
16
16
|
able to update the plug-in without regenerating the scaffolds.
|
17
17
|
|
18
|
+
== Migrating from authpwn 0.9 or older?
|
19
|
+
|
20
|
+
See legacy/migrate_09_to_010.rb for a semi-automated way of migrating your
|
21
|
+
database.
|
22
|
+
|
18
23
|
== Note on Patches/Pull Requests
|
19
24
|
|
20
25
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.1
|
data/authpwn_rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
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.1"
|
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"]
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"VERSION",
|
29
29
|
"app/helpers/session_helper.rb",
|
30
30
|
"authpwn_rails.gemspec",
|
31
|
+
"legacy/migrate_09_to_010.rb",
|
31
32
|
"lib/authpwn_rails.rb",
|
32
33
|
"lib/authpwn_rails/credential_model.rb",
|
33
34
|
"lib/authpwn_rails/credentials.rb",
|
@@ -38,7 +39,7 @@ Gem::Specification.new do |s|
|
|
38
39
|
"lib/authpwn_rails/facebook_session.rb",
|
39
40
|
"lib/authpwn_rails/generators/all_generator.rb",
|
40
41
|
"lib/authpwn_rails/generators/templates/001_create_users.rb",
|
41
|
-
"lib/authpwn_rails/generators/templates/
|
42
|
+
"lib/authpwn_rails/generators/templates/003_create_credentials.rb",
|
42
43
|
"lib/authpwn_rails/generators/templates/credential.rb",
|
43
44
|
"lib/authpwn_rails/generators/templates/credentials.yml",
|
44
45
|
"lib/authpwn_rails/generators/templates/session/forbidden.html.erb",
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# This script migrates an authpwn <= 0.9 database to the new 0.10 layout.
|
2
|
+
# It should be run in a rails console.
|
3
|
+
|
4
|
+
|
5
|
+
# Remove obsolete Facebook token files.
|
6
|
+
[
|
7
|
+
'app/models/facebook_token.rb',
|
8
|
+
'db/migrate/20100725000002_create_facebook_tokens.rb',
|
9
|
+
'test/fixtures/facebook_tokens.yml'
|
10
|
+
].each do |f|
|
11
|
+
File.unlink f if File.exist?(f)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Re-generate scaffolds.
|
15
|
+
Kernel.system 'rails g authpwn:all'
|
16
|
+
|
17
|
+
# Get the credentials table.
|
18
|
+
Kernel.system "rake db:migrate:up VERSION=20100725000003 RAILS_ENV=#{Rails.env}"
|
19
|
+
|
20
|
+
# Build up credentials.
|
21
|
+
reload!
|
22
|
+
User.all.each do |user|
|
23
|
+
Credentials::Email.create! :user => user, :email => user.attributes['email']
|
24
|
+
|
25
|
+
pwd = Credentials::Password.new :user => user
|
26
|
+
pwd.password = pwd.password_confirmation = '_'
|
27
|
+
pwd.key = user.password_salt + '|' + user.password_hash
|
28
|
+
pwd.save!
|
29
|
+
end
|
30
|
+
|
31
|
+
# Update the columns in the User model.
|
32
|
+
class UpgradeUserModel < ActiveRecord::Migration
|
33
|
+
def change
|
34
|
+
remove_column :users, :email
|
35
|
+
remove_column :users, :email_hash
|
36
|
+
remove_column :users, :password_salt
|
37
|
+
remove_column :users, :password_hash
|
38
|
+
|
39
|
+
add_column :users, :exuid, :string, :length => 32, :null => true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
UpgradeUserModel.migrate :up
|
43
|
+
reload!
|
44
|
+
|
45
|
+
# Assign unique IDs to all users.
|
46
|
+
User.all.each do |user|
|
47
|
+
user.set_default_exuid
|
48
|
+
sleep 0.01
|
49
|
+
user.save!
|
50
|
+
end
|
51
|
+
|
52
|
+
# Finish the upgrade of the User model.
|
53
|
+
class FinishUpgradingUserModel < ActiveRecord::Migration
|
54
|
+
def change
|
55
|
+
change_column :users, :exuid, :string, :length => 32, :null => false
|
56
|
+
add_index :users, :exuid, :unique => true, :null => false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
FinishUpgradingUserModel.migrate :up
|
60
|
+
reload!
|
61
|
+
|
@@ -27,4 +27,10 @@ module Authpwn::UserModel::InstanceMethods
|
|
27
27
|
def email_credential
|
28
28
|
credentials.find { |c| c.instance_of?(Credentials::Email) }
|
29
29
|
end
|
30
|
+
|
31
|
+
# The e-mail from the user's Email credential, or nil no credential exists.
|
32
|
+
def email
|
33
|
+
credential = self.email_credential
|
34
|
+
credential && credential.email
|
35
|
+
end
|
30
36
|
end # module Authpwn::UserModel::InstanceMethods
|
@@ -5,6 +5,12 @@
|
|
5
5
|
# means that we have to load the classes that inherit from Credential after it's
|
6
6
|
# defined, which is long after the authpwn_rails engine is loaded.
|
7
7
|
|
8
|
-
require '
|
9
|
-
|
10
|
-
|
8
|
+
require 'active_support'
|
9
|
+
|
10
|
+
module Credentials
|
11
|
+
extend ActiveSupport::Autoload
|
12
|
+
|
13
|
+
autoload :Email, 'authpwn_rails/credentials/email.rb'
|
14
|
+
autoload :Facebook, 'authpwn_rails/credentials/facebook.rb'
|
15
|
+
autoload :Password, 'authpwn_rails/credentials/password.rb'
|
16
|
+
end
|
@@ -14,8 +14,8 @@ class AllGenerator < Rails::Generators::Base
|
|
14
14
|
|
15
15
|
def create_credential_model
|
16
16
|
copy_file 'credential.rb', File.join('app', 'models', 'credential.rb')
|
17
|
-
copy_file '
|
18
|
-
File.join('db', 'migrate', '
|
17
|
+
copy_file '003_create_credentials.rb',
|
18
|
+
File.join('db', 'migrate', '20100725000003_create_credentials.rb')
|
19
19
|
copy_file 'credentials.yml',
|
20
20
|
File.join('test', 'fixtures', 'credentials.yml')
|
21
21
|
end
|
data/lib/authpwn_rails/generators/templates/{002_create_credentials.rb → 003_create_credentials.rb}
RENAMED
File without changes
|
@@ -5,9 +5,6 @@ class Credential < ActiveRecord::Base
|
|
5
5
|
# Add your extensions to the Credential class here.
|
6
6
|
end
|
7
7
|
|
8
|
-
# Load built-in credential types, such as Email and Password.
|
9
|
-
require 'authpwn_rails/credentials.rb'
|
10
|
-
|
11
8
|
# namespace for all Credential subclasses
|
12
9
|
module Credentials
|
13
10
|
|
data/lib/authpwn_rails.rb
CHANGED
@@ -47,4 +47,10 @@ class EmailCredentialTest < ActiveSupport::TestCase
|
|
47
47
|
assert_equal credentials(:jane_email), users(:jane).email_credential
|
48
48
|
assert_nil users(:bill).email_credential
|
49
49
|
end
|
50
|
+
|
51
|
+
test 'User#email' do
|
52
|
+
assert_equal credentials(:john_email).email, users(:john).email
|
53
|
+
assert_equal credentials(:jane_email).email, users(:jane).email
|
54
|
+
assert_nil users(:bill).email
|
55
|
+
end
|
50
56
|
end
|
data/test/helpers/db_setup.rb
CHANGED
@@ -5,7 +5,7 @@ ActiveRecord::Base.configurations = true
|
|
5
5
|
ActiveRecord::Migration.verbose = false
|
6
6
|
require 'authpwn_rails/generators/templates/001_create_users.rb'
|
7
7
|
CreateUsers.migrate :up
|
8
|
-
require 'authpwn_rails/generators/templates/
|
8
|
+
require 'authpwn_rails/generators/templates/003_create_credentials.rb'
|
9
9
|
CreateCredentials.migrate :up
|
10
10
|
|
11
11
|
require 'authpwn_rails/generators/templates/user.rb'
|
@@ -59,7 +59,7 @@ class SessionControllerApiTest < ActionController::TestCase
|
|
59
59
|
assert_template :new
|
60
60
|
assert_nil assigns(:current_user), 'current_user should not be set'
|
61
61
|
|
62
|
-
assert_select 'form' do
|
62
|
+
assert_select 'form[action="/session"]' do
|
63
63
|
assert_select 'input#email'
|
64
64
|
assert_select 'input#password'
|
65
65
|
assert_select 'input[type=submit]'
|
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.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-21 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fbgraph_rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &10153440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10153440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &10152600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.1.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10152600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &10151940 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10151940
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: flexmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &10151200 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10151200
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &10150220 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10150220
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &10149480 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *10149480
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: sqlite3
|
82
|
-
requirement: &
|
82
|
+
requirement: &10148440 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 1.3.3
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *10148440
|
91
91
|
description: Works with Facebook.
|
92
92
|
email: victor@costan.us
|
93
93
|
executables: []
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- VERSION
|
108
108
|
- app/helpers/session_helper.rb
|
109
109
|
- authpwn_rails.gemspec
|
110
|
+
- legacy/migrate_09_to_010.rb
|
110
111
|
- lib/authpwn_rails.rb
|
111
112
|
- lib/authpwn_rails/credential_model.rb
|
112
113
|
- lib/authpwn_rails/credentials.rb
|
@@ -117,7 +118,7 @@ files:
|
|
117
118
|
- lib/authpwn_rails/facebook_session.rb
|
118
119
|
- lib/authpwn_rails/generators/all_generator.rb
|
119
120
|
- lib/authpwn_rails/generators/templates/001_create_users.rb
|
120
|
-
- lib/authpwn_rails/generators/templates/
|
121
|
+
- lib/authpwn_rails/generators/templates/003_create_credentials.rb
|
121
122
|
- lib/authpwn_rails/generators/templates/credential.rb
|
122
123
|
- lib/authpwn_rails/generators/templates/credentials.yml
|
123
124
|
- lib/authpwn_rails/generators/templates/session/forbidden.html.erb
|
@@ -160,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
161
|
version: '0'
|
161
162
|
segments:
|
162
163
|
- 0
|
163
|
-
hash:
|
164
|
+
hash: 2383073164549657310
|
164
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
166
|
none: false
|
166
167
|
requirements:
|