challah 1.5.0 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +32 -0
- data/README.md +6 -39
- data/VERSION +1 -1
- data/app/controllers/sessions_controller.rb +11 -10
- data/app/models/authorization.rb +2 -0
- data/lib/challah/audit.rb +38 -36
- data/lib/challah/authenticators/api_key.rb +4 -2
- data/lib/challah/authenticators/password.rb +3 -1
- data/lib/challah/authenticators.rb +5 -3
- data/lib/challah/concerns/authorizeable.rb +4 -0
- data/lib/challah/concerns/user/attributeable.rb +37 -29
- data/lib/challah/concerns/user/authenticateable.rb +4 -2
- data/lib/challah/concerns/user/authorizable.rb +16 -12
- data/lib/challah/concerns/user/findable.rb +13 -10
- data/lib/challah/concerns/user/passwordable.rb +5 -3
- data/lib/challah/concerns/user/provideable.rb +22 -20
- data/lib/challah/concerns/user/statusable.rb +3 -21
- data/lib/challah/concerns/user/validateable.rb +3 -1
- data/lib/challah/concerns/userable.rb +1 -3
- data/lib/challah/controller.rb +69 -65
- data/lib/challah/cookie_store.rb +7 -5
- data/lib/challah/encrypter.rb +4 -2
- data/lib/challah/engine.rb +5 -18
- data/lib/challah/providers/password_provider.rb +9 -7
- data/lib/challah/providers.rb +3 -1
- data/lib/challah/random.rb +6 -4
- data/lib/challah/routes.rb +6 -6
- data/lib/challah/session.rb +27 -25
- data/lib/challah/signup.rb +5 -3
- data/lib/challah/simple_cookie_store.rb +82 -80
- data/lib/challah/techniques/api_key_technique.rb +2 -2
- data/lib/challah/techniques/password_technique.rb +2 -1
- data/lib/challah/techniques/token_technique.rb +3 -1
- data/lib/challah/techniques.rb +2 -0
- data/lib/challah/test.rb +6 -0
- data/lib/challah/validators/email_validator.rb +2 -0
- data/lib/challah/validators/password_validator.rb +5 -3
- data/lib/challah/version.rb +3 -1
- data/lib/challah.rb +2 -5
- data/lib/generators/challah_generator.rb +17 -0
- data/lib/generators/templates/migration.erb +39 -0
- data/lib/tasks/setup.rake +7 -3
- metadata +63 -26
- data/db/migrate/20120127150433_create_users.rb +0 -29
- data/db/migrate/20121116210759_create_authorizations.rb +0 -22
- data/lib/challah/plugins.rb +0 -54
@@ -1,29 +0,0 @@
|
|
1
|
-
class CreateUsers < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def change
|
4
|
-
create_table :users do |t|
|
5
|
-
t.string :first_name
|
6
|
-
t.string :last_name
|
7
|
-
t.string :email
|
8
|
-
t.string :email_hash
|
9
|
-
t.string :persistence_token
|
10
|
-
t.string :api_key
|
11
|
-
t.datetime :last_session_at
|
12
|
-
t.string :last_session_ip
|
13
|
-
t.integer :session_count, default: 0
|
14
|
-
t.integer :failed_auth_count, default: 0
|
15
|
-
t.integer :created_by, default: 0
|
16
|
-
t.integer :updated_by, default: 0
|
17
|
-
t.datetime :created_at
|
18
|
-
t.datetime :updated_at
|
19
|
-
t.integer :status, default: 0 # defaults to :active
|
20
|
-
t.timestamps null: true
|
21
|
-
end
|
22
|
-
|
23
|
-
add_index :users, :first_name
|
24
|
-
add_index :users, :last_name
|
25
|
-
add_index :users, :email
|
26
|
-
add_index :users, :api_key
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class CreateAuthorizations < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def change
|
4
|
-
create_table :authorizations do |t|
|
5
|
-
t.integer :user_id
|
6
|
-
t.string :provider, limit: 50
|
7
|
-
t.string :uid
|
8
|
-
t.string :token, limit: 500
|
9
|
-
t.datetime :expires_at
|
10
|
-
t.datetime :last_session_at
|
11
|
-
t.string :last_session_ip
|
12
|
-
t.integer :session_count, default: 0
|
13
|
-
t.timestamps null: true
|
14
|
-
end
|
15
|
-
|
16
|
-
add_index :authorizations, :user_id
|
17
|
-
add_index :authorizations, [ :user_id, :provider ]
|
18
|
-
add_index :authorizations, :uid
|
19
|
-
add_index :authorizations, :token
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/lib/challah/plugins.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module Challah
|
2
|
-
# Plugins are used to extend the functionality of Challah.
|
3
|
-
module Plugins
|
4
|
-
# A simple DSL for registering a plugin
|
5
|
-
class Plugin
|
6
|
-
attr_reader :active_record, :action_controller, :user_extensions, :user_init_methods
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@active_record ||= []
|
10
|
-
@action_controller ||= []
|
11
|
-
@user_extensions ||= []
|
12
|
-
@user_init_methods ||= []
|
13
|
-
end
|
14
|
-
|
15
|
-
# When active_record or action_controller is loaded, run the given block
|
16
|
-
def on_load(framework, &block)
|
17
|
-
return unless [ :active_record, :action_controller ].include?(framework)
|
18
|
-
instance_variable_get("@#{framework}") << block
|
19
|
-
end
|
20
|
-
|
21
|
-
# Pass a module name to include it in the base User model after challah_user
|
22
|
-
# is run
|
23
|
-
def extend_user(module_name, init_method = nil)
|
24
|
-
@user_extensions << module_name
|
25
|
-
@user_init_methods << init_method unless init_method.nil?
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Register a new plugin.
|
30
|
-
def register_plugin(name, &block)
|
31
|
-
plugin = Plugin.new
|
32
|
-
plugin.instance_eval(&block)
|
33
|
-
@plugins[name] = plugin
|
34
|
-
end
|
35
|
-
|
36
|
-
# Get the list of all plugins
|
37
|
-
def plugins
|
38
|
-
@plugins
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Loop through all registered plugins and extend User functionality.
|
43
|
-
def self.include_user_plugins!
|
44
|
-
Challah.plugins.values.each do |plugin|
|
45
|
-
plugin.user_extensions.each do |mod|
|
46
|
-
Challah.user.send(:extend, mod)
|
47
|
-
end
|
48
|
-
|
49
|
-
plugin.user_init_methods.each do |method_name|
|
50
|
-
Challah.user.send(method_name)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|