sorcery 0.5.0 → 0.5.2
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/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/sorcery/controller/adapters/sinatra.rb +35 -28
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
- data/lib/sorcery/engine.rb +0 -7
- data/lib/sorcery/initializers/initializer.rb +4 -2
- data/lib/sorcery/model/adapters/mongoid.rb +10 -5
- data/lib/sorcery/model/submodules/reset_password.rb +5 -3
- data/lib/sorcery/model.rb +4 -5
- data/lib/sorcery/test_helpers/internal/rails.rb +1 -0
- data/lib/sorcery/test_helpers/internal/sinatra.rb +3 -3
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +74 -0
- data/lib/sorcery.rb +3 -5
- data/sorcery.gemspec +54 -2
- data/spec/Gemfile.lock +1 -4
- data/spec/rails3/Gemfile.lock +1 -4
- data/spec/rails3/spec/user_reset_password_spec.rb +1 -1
- data/spec/rails3/spec/user_spec.rb +0 -10
- data/spec/rails3_mongoid/Gemfile.lock +1 -4
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +12 -4
- data/spec/rails3_mongoid/spec/user_spec.rb +0 -10
- data/spec/sinatra/Gemfile +3 -0
- data/spec/sinatra/Gemfile.lock +17 -34
- data/spec/sinatra/Rakefile +1 -1
- data/spec/sinatra/filters.rb +20 -14
- data/spec/sinatra/modular.rb +157 -0
- data/spec/sinatra_modular/Gemfile +15 -0
- data/spec/sinatra_modular/Gemfile.lock +117 -0
- data/spec/sinatra_modular/Rakefile +11 -0
- data/spec/sinatra_modular/authentication.rb +3 -0
- data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +17 -0
- data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +17 -0
- data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +11 -0
- data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +16 -0
- data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +14 -0
- data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +15 -0
- data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +13 -0
- data/spec/sinatra_modular/filters.rb +27 -0
- data/spec/sinatra_modular/modular.rb +157 -0
- data/spec/sinatra_modular/myapp.rb +133 -0
- data/spec/sinatra_modular/sorcery_mailer.rb +25 -0
- data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +85 -0
- data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +70 -0
- data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +53 -0
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +120 -0
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +121 -0
- data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +64 -0
- data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +57 -0
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +116 -0
- data/spec/sinatra_modular/spec_modular/spec.opts +2 -0
- data/spec/sinatra_modular/spec_modular/spec_helper.rb +51 -0
- data/spec/sinatra_modular/user.rb +6 -0
- data/spec/sinatra_modular/views/test_login.erb +4 -0
- metadata +54 -2
data/README.rdoc
CHANGED
|
@@ -29,7 +29,7 @@ Example Rails 3 app using sorcery: https://github.com/NoamB/sorcery-example-app
|
|
|
29
29
|
|
|
30
30
|
Example Sinatra app using sorcery: https://github.com/NoamB/sorcery-example-app-sinatra
|
|
31
31
|
|
|
32
|
-
Documentation: http://rubydoc.info/gems/sorcery/0.5.
|
|
32
|
+
Documentation: http://rubydoc.info/gems/sorcery/0.5.2/frames
|
|
33
33
|
|
|
34
34
|
Check out the tutorials in the github wiki!
|
|
35
35
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.2
|
|
@@ -16,7 +16,7 @@ module Sorcery
|
|
|
16
16
|
process_route(*arguments) { instance_eval(&block) }
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def after_filter(filter)
|
|
21
21
|
after do
|
|
22
22
|
send(filter)
|
|
@@ -24,66 +24,73 @@ module Sorcery
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
::Sinatra::Request.class_eval do
|
|
29
29
|
def authorization
|
|
30
|
-
env['HTTP_AUTHORIZATION']
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
env['HTTP_AUTHORIZATION'] ||
|
|
31
|
+
env['X-HTTP_AUTHORIZATION'] ||
|
|
32
|
+
env['X_HTTP_AUTHORIZATION'] ||
|
|
33
|
+
env['REDIRECT_X_HTTP_AUTHORIZATION'] || nil
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
base.send(:include, SorceryHelpers)
|
|
37
38
|
base.send(:include, InstanceMethods)
|
|
38
39
|
base.extend(ClassMethods)
|
|
39
40
|
end
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
module SorceryHelpers
|
|
43
|
+
|
|
44
|
+
def request_http_basic_authentication(realm)
|
|
45
|
+
response.header['WWW-Authenticate'] = %(Basic realm="#{realm}")
|
|
46
|
+
response.status = 401
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def authenticate_with_http_basic(&blk)
|
|
50
|
+
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
|
51
|
+
yield @auth.credentials if (@auth.provided? && @auth.basic? && @auth.credentials)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
41
56
|
module InstanceMethods
|
|
42
57
|
def reset_session
|
|
43
58
|
session.clear
|
|
44
59
|
end
|
|
45
|
-
|
|
60
|
+
|
|
46
61
|
def redirect_to(*args)
|
|
47
62
|
args.pop if args.last.is_a?(Hash)
|
|
48
63
|
redirect(*args)
|
|
49
64
|
end
|
|
50
|
-
|
|
65
|
+
|
|
51
66
|
def root_path
|
|
52
67
|
'/'
|
|
53
68
|
end
|
|
54
|
-
|
|
55
|
-
helpers do
|
|
56
|
-
|
|
57
|
-
response.header['WWW-Authenticate'] = %(Basic realm="#{realm}")
|
|
58
|
-
response.status = 401
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def authenticate_with_http_basic(&blk)
|
|
62
|
-
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
|
63
|
-
yield @auth.credentials if ( @auth.provided? && @auth.basic? && @auth.credentials )
|
|
64
|
-
end
|
|
69
|
+
|
|
70
|
+
::Sinatra.helpers do
|
|
71
|
+
include SorceryHelpers
|
|
65
72
|
end
|
|
66
|
-
|
|
73
|
+
|
|
67
74
|
def cookies
|
|
68
|
-
@cookie_proxy ||= CookieProxy.new(request,response)
|
|
75
|
+
@cookie_proxy ||= CookieProxy.new(request, response)
|
|
69
76
|
end
|
|
70
77
|
end
|
|
71
|
-
|
|
78
|
+
|
|
72
79
|
class CookieProxy
|
|
73
|
-
def initialize(request,response)
|
|
80
|
+
def initialize(request, response)
|
|
74
81
|
@request = request
|
|
75
82
|
@response = response
|
|
76
83
|
end
|
|
77
|
-
|
|
84
|
+
|
|
78
85
|
def [](key)
|
|
79
86
|
@request.cookies[key.to_s]
|
|
80
87
|
end
|
|
81
|
-
|
|
88
|
+
|
|
82
89
|
def []=(key, value)
|
|
83
90
|
@response.set_cookie(key, value)
|
|
84
91
|
end
|
|
85
92
|
end
|
|
86
|
-
|
|
93
|
+
|
|
87
94
|
module ClassMethods
|
|
88
95
|
def prepend_before_filter(filter)
|
|
89
96
|
prepend_filter(:before) do
|
data/lib/sorcery/engine.rb
CHANGED
|
@@ -12,13 +12,6 @@ module Sorcery
|
|
|
12
12
|
ActionController::Base.helper_method :current_user
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
initializer "attempt to preload user model" do |app|
|
|
16
|
-
begin
|
|
17
|
-
require Rails.root + "app/models/user.rb"
|
|
18
|
-
rescue LoadError
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
15
|
rake_tasks do
|
|
23
16
|
load "sorcery/railties/tasks.rake"
|
|
24
17
|
end
|
|
@@ -9,8 +9,7 @@ Rails.application.config.sorcery.configure do |config|
|
|
|
9
9
|
# config.not_authenticated_action = :not_authenticated # what controller action to call for non-authenticated users. You can also override 'not_authenticated' instead.
|
|
10
10
|
# config.save_return_to_url = true # when a non logged in user tries to enter a page that requires login, save the URL he wanted to reach,
|
|
11
11
|
# and send him there after login, using 'redirect_back_or_to'.
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
|
|
14
13
|
# -- session timeout --
|
|
15
14
|
# config.session_timeout = 3600 # how long in seconds to keep the session alive.
|
|
16
15
|
# config.session_timeout_from_last_action = false # use the last action as the beginning of session timeout.
|
|
@@ -84,4 +83,7 @@ Rails.application.config.sorcery.configure do |config|
|
|
|
84
83
|
# user.provider_attribute_name = :provider # provider's identifier in authentications class.
|
|
85
84
|
# user.provider_uid_attribute_name = :uid # user's external unique identifier in authentications class.
|
|
86
85
|
end
|
|
86
|
+
|
|
87
|
+
# This line must come after the 'user config' block.
|
|
88
|
+
config.user_class_name = User # define which model authenticates with sorcery.
|
|
87
89
|
end
|
|
@@ -15,11 +15,12 @@ module Sorcery
|
|
|
15
15
|
|
|
16
16
|
module ClassMethods
|
|
17
17
|
def find_by_credentials(credentials)
|
|
18
|
-
where(
|
|
18
|
+
where(sorcery_config.username_attribute_name => credentials[0]).first
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def find_by_provider_and_uid(provider, uid)
|
|
22
|
-
|
|
22
|
+
user_klass = ::Sorcery::Controller::Config.user_class
|
|
23
|
+
where(user_klass.sorcery_config.provider_attribute_name => provider, user_klass.sorcery_config.provider_uid_attribute_name => uid).first
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def find_by_id(id)
|
|
@@ -27,15 +28,15 @@ module Sorcery
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def find_by_activation_token(token)
|
|
30
|
-
where(
|
|
31
|
+
where(sorcery_config.activation_token_attribute_name => token).first
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def find_by_remember_me_token(token)
|
|
34
|
-
where(
|
|
35
|
+
where(sorcery_config.remember_me_token_attribute_name => token).first
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def find_by_username(username)
|
|
38
|
-
where(
|
|
39
|
+
where(sorcery_config.username_attribute_name => username).first
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def transaction(&blk)
|
|
@@ -46,6 +47,10 @@ module Sorcery
|
|
|
46
47
|
where(token_attr_name => token).first
|
|
47
48
|
end
|
|
48
49
|
|
|
50
|
+
def find_by_email(email)
|
|
51
|
+
where(sorcery_config.email_attribute_name => email).first
|
|
52
|
+
end
|
|
53
|
+
|
|
49
54
|
def get_current_users
|
|
50
55
|
config = sorcery_config
|
|
51
56
|
where(config.last_activity_at_attribute_name.ne => nil) \
|
|
@@ -32,11 +32,12 @@ module Sorcery
|
|
|
32
32
|
|
|
33
33
|
reset!
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
base.extend(ClassMethods)
|
|
37
|
+
|
|
36
38
|
base.sorcery_config.after_config << :validate_mailer_defined
|
|
37
39
|
base.sorcery_config.after_config << :define_reset_password_mongoid_fields if defined?(Mongoid) and base.ancestors.include?(Mongoid::Document)
|
|
38
40
|
|
|
39
|
-
base.extend(ClassMethods)
|
|
40
41
|
base.send(:include, TemporaryToken)
|
|
41
42
|
base.send(:include, InstanceMethods)
|
|
42
43
|
|
|
@@ -84,7 +85,8 @@ module Sorcery
|
|
|
84
85
|
# Clears token and tries to update the new password for the user.
|
|
85
86
|
def change_password!(new_password)
|
|
86
87
|
clear_reset_password_token
|
|
87
|
-
|
|
88
|
+
self.send(:"#{sorcery_config.password_attribute_name}=", new_password)
|
|
89
|
+
save
|
|
88
90
|
end
|
|
89
91
|
|
|
90
92
|
protected
|
data/lib/sorcery/model.rb
CHANGED
|
@@ -14,9 +14,7 @@ module Sorcery
|
|
|
14
14
|
self.class_eval do
|
|
15
15
|
extend ClassMethods # included here, before submodules, so they can be overriden by them.
|
|
16
16
|
include InstanceMethods
|
|
17
|
-
|
|
18
|
-
# set the user_class for the controller methods which call it
|
|
19
|
-
::Sorcery::Controller::Config.user_class = self
|
|
17
|
+
|
|
20
18
|
@sorcery_config.submodules = ::Sorcery::Controller::Config.submodules
|
|
21
19
|
@sorcery_config.submodules.each do |mod|
|
|
22
20
|
begin
|
|
@@ -30,9 +28,10 @@ module Sorcery
|
|
|
30
28
|
# This runs the options block set in the initializer on the model class.
|
|
31
29
|
::Sorcery::Controller::Config.user_config.tap{|blk| blk.call(@sorcery_config) if blk}
|
|
32
30
|
|
|
31
|
+
# Mongoid support
|
|
33
32
|
self.class_eval do
|
|
34
33
|
field sorcery_config.username_attribute_name, type: String
|
|
35
|
-
field sorcery_config.password_attribute_name, type: String
|
|
34
|
+
#field sorcery_config.password_attribute_name, type: String
|
|
36
35
|
field sorcery_config.email_attribute_name, type: String unless sorcery_config.username_attribute_name == sorcery_config.email_attribute_name
|
|
37
36
|
field sorcery_config.crypted_password_attribute_name, type: String
|
|
38
37
|
field sorcery_config.salt_attribute_name, type: String
|
|
@@ -122,7 +121,7 @@ module Sorcery
|
|
|
122
121
|
# encrypts password with salt and saves it.
|
|
123
122
|
def encrypt_password
|
|
124
123
|
config = sorcery_config
|
|
125
|
-
|
|
124
|
+
self.send(:"#{config.salt_attribute_name}=", new_salt = generate_random_token) if !config.salt_attribute_name.nil?
|
|
126
125
|
self.send(:"#{config.crypted_password_attribute_name}=", self.class.encrypt(self.send(config.password_attribute_name),new_salt))
|
|
127
126
|
end
|
|
128
127
|
|
|
@@ -22,6 +22,7 @@ module Sorcery
|
|
|
22
22
|
::Sorcery::Controller::Config.submodules = submodules
|
|
23
23
|
::Sorcery::Controller::Config.user_class = nil
|
|
24
24
|
ActionController::Base.send(:include,::Sorcery::Controller)
|
|
25
|
+
::Sorcery::Controller::Config.user_class = User
|
|
25
26
|
|
|
26
27
|
::Sorcery::Controller::Config.user_config do |user|
|
|
27
28
|
options.each do |property,value|
|
|
@@ -43,15 +43,15 @@ module Sorcery
|
|
|
43
43
|
|
|
44
44
|
# clear all filters
|
|
45
45
|
::Sinatra::Application.instance_variable_set(:@filters, {:before => [], :after => []})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
end
|
|
46
|
+
load File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec', 'sinatra', 'filters.rb')
|
|
47
|
+
::Sinatra::Application.send(:include, ::Filters)
|
|
49
48
|
|
|
50
49
|
# configure
|
|
51
50
|
::Sorcery::Controller::Config.submodules = submodules
|
|
52
51
|
::Sorcery::Controller::Config.user_class = nil
|
|
53
52
|
::Sinatra::Application.send(:include, Sorcery::Controller::Adapters::Sinatra)
|
|
54
53
|
::Sinatra::Application.send(:include, Sorcery::Controller)
|
|
54
|
+
::Sorcery::Controller::Config.user_class = User
|
|
55
55
|
|
|
56
56
|
::Sorcery::Controller::Config.user_config do |user|
|
|
57
57
|
options.each do |property, value|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module TestHelpers
|
|
3
|
+
module Internal
|
|
4
|
+
module SinatraModular
|
|
5
|
+
include ::Sorcery::TestHelpers::Sinatra::CookieSessionMethods
|
|
6
|
+
include ::Sorcery::TestHelpers::Sinatra::InstanceMethods
|
|
7
|
+
|
|
8
|
+
class ::Modular
|
|
9
|
+
class << self
|
|
10
|
+
attr_accessor :sorcery_vars
|
|
11
|
+
end
|
|
12
|
+
@sorcery_vars = {}
|
|
13
|
+
|
|
14
|
+
# NOTE: see before and after test filters in filters.rb
|
|
15
|
+
|
|
16
|
+
def save_instance_vars
|
|
17
|
+
instance_variables.each do |var|
|
|
18
|
+
self.class.sorcery_vars[:"#{var.to_s.delete("@")}"] = instance_variable_get(var)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
::RSpec::Matchers.define :redirect_to do |expected|
|
|
24
|
+
match do |actual|
|
|
25
|
+
actual.status == 302 && actual.location == expected
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def clear_user_without_logout
|
|
30
|
+
get_sinatra_app(subject).instance_variable_set(:@current_user, nil)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def assigns
|
|
34
|
+
::Modular.sorcery_vars
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def sorcery_reload!(submodules = [], options = {})
|
|
38
|
+
reload_user_class
|
|
39
|
+
|
|
40
|
+
# return to no-module configuration
|
|
41
|
+
::Sorcery::Controller::Config.init!
|
|
42
|
+
::Sorcery::Controller::Config.reset!
|
|
43
|
+
|
|
44
|
+
# clear all filters
|
|
45
|
+
::Sinatra::Base.instance_variable_set(:@filters, {:before => [], :after => []})
|
|
46
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec', 'sinatra', 'filters')
|
|
47
|
+
::Sinatra::Base.send(:include, ::Filters)
|
|
48
|
+
|
|
49
|
+
# configure
|
|
50
|
+
::Sorcery::Controller::Config.submodules = submodules
|
|
51
|
+
::Sorcery::Controller::Config.user_class = nil
|
|
52
|
+
::Sinatra::Base.send(:include, Sorcery::Controller::Adapters::Sinatra)
|
|
53
|
+
::Sinatra::Base.send(:include, Sorcery::Controller)
|
|
54
|
+
::Sorcery::Controller::Config.user_class = User
|
|
55
|
+
|
|
56
|
+
::Sorcery::Controller::Config.user_config do |user|
|
|
57
|
+
options.each do |property, value|
|
|
58
|
+
user.send(:"#{property}=", value)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
User.authenticates_with_sorcery!
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def sorcery_controller_property_set(property, value)
|
|
65
|
+
::Sorcery::Controller::Config.send(:"#{property}=", value)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def sorcery_controller_external_property_set(provider, property, value)
|
|
69
|
+
::Sorcery::Controller::Config.send(provider).send(:"#{property}=", value)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/lib/sorcery.rb
CHANGED
|
@@ -56,28 +56,26 @@ module Sorcery
|
|
|
56
56
|
module Internal
|
|
57
57
|
autoload :Rails, 'sorcery/test_helpers/internal/rails'
|
|
58
58
|
autoload :Sinatra, 'sorcery/test_helpers/internal/sinatra'
|
|
59
|
+
autoload :SinatraModular, 'sorcery/test_helpers/internal/sinatra_modular'
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
if defined?(ActiveRecord)
|
|
64
65
|
ActiveRecord::Base.send(:include, Sorcery::Model)
|
|
65
|
-
ActiveRecord::Base.send(:include,
|
|
66
|
+
ActiveRecord::Base.send(:include, Sorcery::Model::Adapters::ActiveRecord)
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
if defined?(Mongoid)
|
|
69
70
|
Mongoid::Document.module_eval do
|
|
70
71
|
included do
|
|
71
72
|
attr_reader :new_record
|
|
72
|
-
include Sorcery::Model::Adapters::Mongoid
|
|
73
73
|
include Sorcery::Model
|
|
74
|
+
include Sorcery::Model::Adapters::Mongoid
|
|
74
75
|
end
|
|
75
76
|
end
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
require 'sorcery/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
|
79
80
|
require 'sorcery/sinatra' if defined?(Sinatra)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
81
|
end
|
data/sorcery.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{sorcery}
|
|
8
|
-
s.version = "0.5.
|
|
8
|
+
s.version = "0.5.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Noam Ben Ari"]
|
|
12
|
-
s.date = %q{2011-05-
|
|
12
|
+
s.date = %q{2011-05-19}
|
|
13
13
|
s.description = %q{Provides common authentication needs such as signing in/out, activating by email and resetting password.}
|
|
14
14
|
s.email = %q{nbenari@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -71,6 +71,7 @@ Gem::Specification.new do |s|
|
|
|
71
71
|
"lib/sorcery/test_helpers/internal.rb",
|
|
72
72
|
"lib/sorcery/test_helpers/internal/rails.rb",
|
|
73
73
|
"lib/sorcery/test_helpers/internal/sinatra.rb",
|
|
74
|
+
"lib/sorcery/test_helpers/internal/sinatra_modular.rb",
|
|
74
75
|
"lib/sorcery/test_helpers/rails.rb",
|
|
75
76
|
"lib/sorcery/test_helpers/sinatra.rb",
|
|
76
77
|
"sorcery.gemspec",
|
|
@@ -229,6 +230,7 @@ Gem::Specification.new do |s|
|
|
|
229
230
|
"spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
230
231
|
"spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
231
232
|
"spec/sinatra/filters.rb",
|
|
233
|
+
"spec/sinatra/modular.rb",
|
|
232
234
|
"spec/sinatra/myapp.rb",
|
|
233
235
|
"spec/sinatra/sorcery_mailer.rb",
|
|
234
236
|
"spec/sinatra/spec/controller_activity_logging_spec.rb",
|
|
@@ -243,6 +245,33 @@ Gem::Specification.new do |s|
|
|
|
243
245
|
"spec/sinatra/spec/spec_helper.rb",
|
|
244
246
|
"spec/sinatra/user.rb",
|
|
245
247
|
"spec/sinatra/views/test_login.erb",
|
|
248
|
+
"spec/sinatra_modular/Gemfile",
|
|
249
|
+
"spec/sinatra_modular/Gemfile.lock",
|
|
250
|
+
"spec/sinatra_modular/Rakefile",
|
|
251
|
+
"spec/sinatra_modular/authentication.rb",
|
|
252
|
+
"spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
253
|
+
"spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
254
|
+
"spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
255
|
+
"spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb",
|
|
256
|
+
"spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb",
|
|
257
|
+
"spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
258
|
+
"spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
259
|
+
"spec/sinatra_modular/filters.rb",
|
|
260
|
+
"spec/sinatra_modular/modular.rb",
|
|
261
|
+
"spec/sinatra_modular/myapp.rb",
|
|
262
|
+
"spec/sinatra_modular/sorcery_mailer.rb",
|
|
263
|
+
"spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb",
|
|
264
|
+
"spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb",
|
|
265
|
+
"spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb",
|
|
266
|
+
"spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb",
|
|
267
|
+
"spec/sinatra_modular/spec_modular/controller_oauth_spec.rb",
|
|
268
|
+
"spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb",
|
|
269
|
+
"spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb",
|
|
270
|
+
"spec/sinatra_modular/spec_modular/controller_spec.rb",
|
|
271
|
+
"spec/sinatra_modular/spec_modular/spec.opts",
|
|
272
|
+
"spec/sinatra_modular/spec_modular/spec_helper.rb",
|
|
273
|
+
"spec/sinatra_modular/user.rb",
|
|
274
|
+
"spec/sinatra_modular/views/test_login.erb",
|
|
246
275
|
"spec/sorcery_crypto_providers_spec.rb",
|
|
247
276
|
"spec/spec.opts",
|
|
248
277
|
"spec/spec_helper.rb"
|
|
@@ -335,6 +364,7 @@ Gem::Specification.new do |s|
|
|
|
335
364
|
"spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
336
365
|
"spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
337
366
|
"spec/sinatra/filters.rb",
|
|
367
|
+
"spec/sinatra/modular.rb",
|
|
338
368
|
"spec/sinatra/myapp.rb",
|
|
339
369
|
"spec/sinatra/sorcery_mailer.rb",
|
|
340
370
|
"spec/sinatra/spec/controller_activity_logging_spec.rb",
|
|
@@ -347,6 +377,28 @@ Gem::Specification.new do |s|
|
|
|
347
377
|
"spec/sinatra/spec/controller_spec.rb",
|
|
348
378
|
"spec/sinatra/spec/spec_helper.rb",
|
|
349
379
|
"spec/sinatra/user.rb",
|
|
380
|
+
"spec/sinatra_modular/authentication.rb",
|
|
381
|
+
"spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
382
|
+
"spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
383
|
+
"spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
|
|
384
|
+
"spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb",
|
|
385
|
+
"spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb",
|
|
386
|
+
"spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
|
|
387
|
+
"spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
|
|
388
|
+
"spec/sinatra_modular/filters.rb",
|
|
389
|
+
"spec/sinatra_modular/modular.rb",
|
|
390
|
+
"spec/sinatra_modular/myapp.rb",
|
|
391
|
+
"spec/sinatra_modular/sorcery_mailer.rb",
|
|
392
|
+
"spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb",
|
|
393
|
+
"spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb",
|
|
394
|
+
"spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb",
|
|
395
|
+
"spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb",
|
|
396
|
+
"spec/sinatra_modular/spec_modular/controller_oauth_spec.rb",
|
|
397
|
+
"spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb",
|
|
398
|
+
"spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb",
|
|
399
|
+
"spec/sinatra_modular/spec_modular/controller_spec.rb",
|
|
400
|
+
"spec/sinatra_modular/spec_modular/spec_helper.rb",
|
|
401
|
+
"spec/sinatra_modular/user.rb",
|
|
350
402
|
"spec/sorcery_crypto_providers_spec.rb",
|
|
351
403
|
"spec/spec_helper.rb"
|
|
352
404
|
]
|
data/spec/Gemfile.lock
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
sorcery (0.5.
|
|
4
|
+
sorcery (0.5.2)
|
|
5
5
|
bcrypt-ruby (~> 2.1.4)
|
|
6
|
-
json (>= 1.5.1)
|
|
7
6
|
oauth (>= 0.4.4)
|
|
8
7
|
oauth (>= 0.4.4)
|
|
9
8
|
oauth2 (>= 0.1.1)
|
|
10
9
|
oauth2 (>= 0.1.1)
|
|
11
|
-
rails (>= 3.0.0)
|
|
12
10
|
|
|
13
11
|
GEM
|
|
14
12
|
remote: http://rubygems.org/
|
|
@@ -54,7 +52,6 @@ GEM
|
|
|
54
52
|
multipart-post (~> 1.1.0)
|
|
55
53
|
rack (< 2, >= 1.1.0)
|
|
56
54
|
i18n (0.5.0)
|
|
57
|
-
json (1.5.1)
|
|
58
55
|
linecache19 (0.5.11)
|
|
59
56
|
ruby_core_source (>= 0.1.4)
|
|
60
57
|
mail (2.2.13)
|
data/spec/rails3/Gemfile.lock
CHANGED
|
@@ -2,14 +2,12 @@ PATH
|
|
|
2
2
|
remote: ../../../
|
|
3
3
|
specs:
|
|
4
4
|
oauth (0.4.4)
|
|
5
|
-
sorcery (0.5.
|
|
5
|
+
sorcery (0.5.2)
|
|
6
6
|
bcrypt-ruby (~> 2.1.4)
|
|
7
|
-
json (>= 1.5.1)
|
|
8
7
|
oauth (>= 0.4.4)
|
|
9
8
|
oauth (>= 0.4.4)
|
|
10
9
|
oauth2 (>= 0.1.1)
|
|
11
10
|
oauth2 (>= 0.1.1)
|
|
12
|
-
rails (>= 3.0.0)
|
|
13
11
|
|
|
14
12
|
GEM
|
|
15
13
|
remote: http://rubygems.org/
|
|
@@ -55,7 +53,6 @@ GEM
|
|
|
55
53
|
multipart-post (~> 1.1.0)
|
|
56
54
|
rack (< 2, >= 1.1.0)
|
|
57
55
|
i18n (0.5.0)
|
|
58
|
-
json (1.5.1)
|
|
59
56
|
linecache19 (0.5.11)
|
|
60
57
|
ruby_core_source (>= 0.1.4)
|
|
61
58
|
mail (2.2.13)
|
|
@@ -142,7 +142,7 @@ describe "User with reset_password submodule" do
|
|
|
142
142
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
it "when
|
|
145
|
+
it "when change_password! is called, should delete reset_password_token" do
|
|
146
146
|
create_new_user
|
|
147
147
|
@user.deliver_reset_password_instructions!
|
|
148
148
|
@user.reset_password_token.should_not be_nil
|
|
@@ -15,16 +15,6 @@ describe "User with no submodules (core)" do
|
|
|
15
15
|
User.should respond_to(:authenticates_with_sorcery!)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
|
|
19
|
-
# ----------------- PLUGIN ACTIVATION -----------------------
|
|
20
|
-
describe TestUser, "Testing activated class self-registration" do
|
|
21
|
-
it "should register itself as user_class if activated" do
|
|
22
|
-
TestUser.class_eval do
|
|
23
|
-
authenticates_with_sorcery!
|
|
24
|
-
end
|
|
25
|
-
::Sorcery::Controller::Config.user_class.should == TestUser
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
18
|
|
|
29
19
|
# ----------------- PLUGIN CONFIGURATION -----------------------
|
|
30
20
|
describe User, "loaded plugin configuration" do
|
|
@@ -2,14 +2,12 @@ PATH
|
|
|
2
2
|
remote: ../../../
|
|
3
3
|
specs:
|
|
4
4
|
oauth (0.4.4)
|
|
5
|
-
sorcery (0.5.
|
|
5
|
+
sorcery (0.5.2)
|
|
6
6
|
bcrypt-ruby (~> 2.1.4)
|
|
7
|
-
json (>= 1.5.1)
|
|
8
7
|
oauth (>= 0.4.4)
|
|
9
8
|
oauth (>= 0.4.4)
|
|
10
9
|
oauth2 (>= 0.1.1)
|
|
11
10
|
oauth2 (>= 0.1.1)
|
|
12
|
-
rails (>= 3.0.0)
|
|
13
11
|
|
|
14
12
|
GEM
|
|
15
13
|
remote: http://rubygems.org/
|
|
@@ -57,7 +55,6 @@ GEM
|
|
|
57
55
|
multipart-post (~> 1.1.0)
|
|
58
56
|
rack (< 2, >= 1.1.0)
|
|
59
57
|
i18n (0.5.0)
|
|
60
|
-
json (1.5.1)
|
|
61
58
|
linecache19 (0.5.11)
|
|
62
59
|
ruby_core_source (>= 0.1.4)
|
|
63
60
|
mail (2.2.13)
|
|
@@ -20,7 +20,7 @@ describe "User with reset_password submodule" do
|
|
|
20
20
|
|
|
21
21
|
specify { @user.should respond_to(:deliver_reset_password_instructions!) }
|
|
22
22
|
|
|
23
|
-
specify { @user.should respond_to(:
|
|
23
|
+
specify { @user.should respond_to(:change_password!) }
|
|
24
24
|
|
|
25
25
|
it "should respond to .load_from_reset_password_token" do
|
|
26
26
|
User.should respond_to(:load_from_reset_password_token)
|
|
@@ -135,7 +135,7 @@ describe "User with reset_password submodule" do
|
|
|
135
135
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
it "when
|
|
138
|
+
it "when change_password! is called, should delete reset_password_token" do
|
|
139
139
|
create_new_user
|
|
140
140
|
@user.deliver_reset_password_instructions!
|
|
141
141
|
@user.reset_password_token.should_not be_nil
|
|
@@ -164,11 +164,19 @@ describe "User with reset_password submodule" do
|
|
|
164
164
|
@user.deliver_reset_password_instructions!
|
|
165
165
|
ActionMailer::Base.deliveries.size.should == old_size + 2
|
|
166
166
|
end
|
|
167
|
-
|
|
167
|
+
|
|
168
|
+
it "should encrypt properly on reset" do
|
|
169
|
+
create_new_user
|
|
170
|
+
@user.deliver_reset_password_instructions!
|
|
171
|
+
@user.change_password!("blagu")
|
|
172
|
+
Sorcery::CryptoProviders::BCrypt.matches?(@user.crypted_password,"blagu",@user.salt).should be_true
|
|
173
|
+
end
|
|
174
|
+
|
|
168
175
|
it "if mailer is nil on activation, throw exception!" do
|
|
169
176
|
expect{sorcery_reload!([:reset_password])}.to raise_error(ArgumentError)
|
|
170
177
|
end
|
|
171
|
-
|
|
178
|
+
|
|
179
|
+
|
|
172
180
|
end
|
|
173
181
|
|
|
174
182
|
end
|
|
@@ -11,16 +11,6 @@ describe "User with no submodules (core)" do
|
|
|
11
11
|
User.should respond_to(:authenticates_with_sorcery!)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
-
|
|
15
|
-
# ----------------- PLUGIN ACTIVATION -----------------------
|
|
16
|
-
describe TestUser, "Testing activated class self-registration" do
|
|
17
|
-
it "should register itself as user_class if activated" do
|
|
18
|
-
TestUser.class_eval do
|
|
19
|
-
authenticates_with_sorcery!
|
|
20
|
-
end
|
|
21
|
-
::Sorcery::Controller::Config.user_class.should == TestUser
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
14
|
|
|
25
15
|
# ----------------- PLUGIN CONFIGURATION -----------------------
|
|
26
16
|
describe User, "loaded plugin configuration" do
|