minimalist_authentication 0.6.4 → 0.6.5
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/.gitignore +1 -0
- data/Gemfile +2 -0
- data/{test/rails_root/Gemfile.lock → Gemfile.lock} +10 -4
- data/README.md +55 -0
- data/Rakefile +2 -2
- data/lib/minimalist/authentication.rb +22 -20
- data/lib/minimalist/version.rb +1 -1
- data/minimalist_authentication.gemspec +6 -2
- data/test/authentication_test.rb +22 -18
- data/test/authorization_test.rb +18 -18
- data/test/factories.rb +4 -2
- data/test/jenkins.bash +9 -0
- data/test/rails_root/app/models/user.rb +1 -0
- data/test/rails_root/test/performance/browsing_test.rb +5 -5
- data/test/test_helper.rb +2 -1
- metadata +58 -10
- data/README +0 -45
- data/init.rb +0 -2
- data/test/rails_root/Gemfile +0 -33
data/.gitignore
CHANGED
data/Gemfile
ADDED
@@ -1,3 +1,9 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
minimalist_authentication (0.6.4)
|
5
|
+
bcrypt-ruby (~> 3.1.1)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: http://rubygems.org/
|
3
9
|
specs:
|
@@ -29,6 +35,7 @@ GEM
|
|
29
35
|
activesupport (= 3.0.5)
|
30
36
|
activesupport (3.0.5)
|
31
37
|
arel (2.0.10)
|
38
|
+
bcrypt-ruby (3.1.1)
|
32
39
|
builder (2.1.2)
|
33
40
|
erubis (2.6.6)
|
34
41
|
abstract (>= 1.0.0)
|
@@ -62,18 +69,17 @@ GEM
|
|
62
69
|
thor (~> 0.14.4)
|
63
70
|
rake (0.9.2.2)
|
64
71
|
sqlite3 (1.3.5)
|
65
|
-
sqlite3-ruby (1.3.3)
|
66
|
-
sqlite3 (>= 1.3.3)
|
67
72
|
thor (0.14.6)
|
68
73
|
treetop (1.4.10)
|
69
74
|
polyglot
|
70
75
|
polyglot (>= 0.3.1)
|
71
|
-
tzinfo (0.3.
|
76
|
+
tzinfo (0.3.32)
|
72
77
|
|
73
78
|
PLATFORMS
|
74
79
|
ruby
|
75
80
|
|
76
81
|
DEPENDENCIES
|
77
82
|
factory_girl
|
83
|
+
minimalist_authentication!
|
78
84
|
rails (= 3.0.5)
|
79
|
-
sqlite3
|
85
|
+
sqlite3
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
[](https://codeclimate.com/github/wwidea/minimalist_authentication)
|
2
|
+
|
3
|
+
MinimalistAuthentication
|
4
|
+
========================
|
5
|
+
|
6
|
+
A Rails authentication gem that takes a minimalist approach. It is designed to be simple to understand, use, and modify for your application.
|
7
|
+
|
8
|
+
This gem was largely inspired by the restful-authentication plugin (http://github.com/technoweenie/restful-authentication/tree/master). I selected the essential methods for password based authentication, reorganized them, trimmed them down when possible, added a couple of features, and resisted the urge to start adding more.
|
9
|
+
|
10
|
+
|
11
|
+
Installation
|
12
|
+
============
|
13
|
+
1) Add to your Gemfile:
|
14
|
+
|
15
|
+
gem 'minimalist_authentication'
|
16
|
+
|
17
|
+
2) Create a user model:
|
18
|
+
|
19
|
+
ruby script/rails generate model user active:boolean email:string crypted_password:string salt:string using_digest_version:integer last_logged_in_at:datetime
|
20
|
+
|
21
|
+
|
22
|
+
Example
|
23
|
+
=======
|
24
|
+
|
25
|
+
1) app/models/user.rb
|
26
|
+
|
27
|
+
class User < ActiveRecord::Base
|
28
|
+
include Minimalist::Authentication
|
29
|
+
end
|
30
|
+
|
31
|
+
2) app/controllers/application.rb
|
32
|
+
|
33
|
+
class ApplicationController < ActionController::Base
|
34
|
+
include Minimalist::Authorization
|
35
|
+
|
36
|
+
# Lock down everything by default
|
37
|
+
# use skip_before_filter to open up sepecific actions
|
38
|
+
prepend_before_filter :authorization_required
|
39
|
+
end
|
40
|
+
|
41
|
+
3) app/controllers/sessions_controller.rb
|
42
|
+
|
43
|
+
class SessionsController < ApplicationController
|
44
|
+
include Minimalist::Sessions
|
45
|
+
skip_before_filter :authorization_required, :only => [:new, :create]
|
46
|
+
end
|
47
|
+
|
48
|
+
4) test/test_helper.rb
|
49
|
+
|
50
|
+
class Test::Unit::TestCase
|
51
|
+
include Minimalist::TestHelper
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
Copyright (c) 2009 Aaron Baldwin, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require '
|
3
|
+
require 'rdoc/task'
|
4
4
|
|
5
5
|
desc 'Default: run unit tests.'
|
6
6
|
task :default => :test
|
@@ -28,7 +28,7 @@ task :rcov do
|
|
28
28
|
rcov = "rcov --rails --text-summary -Ilib --exclude /gems/,/app/,/Library/"
|
29
29
|
system("#{rcov} --html #{Dir.glob('test/**/*_test.rb').join(' ')}")
|
30
30
|
if PLATFORM['darwin'] #Mac
|
31
|
-
system("open coverage/index.html")
|
31
|
+
system("open coverage/index.html")
|
32
32
|
elsif PLATFORM[/linux/] #Ubuntu, etc.
|
33
33
|
system("/etc/alternatives/x-www-browser coverage/index.html")
|
34
34
|
end
|
@@ -15,21 +15,23 @@ module Minimalist
|
|
15
15
|
base.extend(ClassMethods)
|
16
16
|
base.class_eval do
|
17
17
|
include InstanceMethods
|
18
|
-
|
18
|
+
|
19
19
|
attr_accessor :password
|
20
20
|
before_save :encrypt_password
|
21
|
-
|
21
|
+
|
22
22
|
validates_presence_of :email, :if => :validate_email_presence?
|
23
23
|
validates_uniqueness_of :email, :if => :validate_email_uniqueness?
|
24
24
|
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :if => :validate_email_format?
|
25
25
|
validates_presence_of :password, :if => :password_required?
|
26
26
|
validates_confirmation_of :password, :if => :password_required?
|
27
27
|
validates_length_of :password, :within => 6..40, :if => :password_required?
|
28
|
-
|
28
|
+
|
29
29
|
scope :active, :conditions => {:active => true}
|
30
|
+
|
31
|
+
|
30
32
|
end
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
module ClassMethods
|
34
36
|
def authenticate(email, password)
|
35
37
|
return if email.blank? || password.blank?
|
@@ -37,7 +39,7 @@ module Minimalist
|
|
37
39
|
return unless user && user.authenticated?(password)
|
38
40
|
return user
|
39
41
|
end
|
40
|
-
|
42
|
+
|
41
43
|
def secure_digest(string, salt, version = 1)
|
42
44
|
case version
|
43
45
|
when 0 then Digest::MD5.hexdigest(string.to_s)
|
@@ -50,20 +52,20 @@ module Minimalist
|
|
50
52
|
def make_token
|
51
53
|
BCrypt::Engine.generate_salt(CALIBRATED_BCRYPT_COST)
|
52
54
|
end
|
53
|
-
|
55
|
+
|
54
56
|
def guest
|
55
57
|
new.tap do |user|
|
56
58
|
user.email = GUEST_USER_EMAIL
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
60
|
-
|
62
|
+
|
61
63
|
module InstanceMethods
|
62
|
-
|
64
|
+
|
63
65
|
def active?
|
64
66
|
active
|
65
67
|
end
|
66
|
-
|
68
|
+
|
67
69
|
def authenticated?(password)
|
68
70
|
if crypted_password == encrypt(password)
|
69
71
|
if self.respond_to?(:using_digest_version) and (using_digest_version != PREFERRED_DIGEST_VERSION or salt_cost < CALIBRATED_BCRYPT_COST)
|
@@ -77,38 +79,38 @@ module Minimalist
|
|
77
79
|
return false
|
78
80
|
end
|
79
81
|
end
|
80
|
-
|
82
|
+
|
81
83
|
def logged_in
|
82
84
|
self.class.update_all("last_logged_in_at='#{Time.now.to_s(:db)}'", "id=#{self.id}") # use update_all to avoid updated_on trigger
|
83
85
|
end
|
84
|
-
|
86
|
+
|
85
87
|
def is_guest?
|
86
88
|
email == GUEST_USER_EMAIL
|
87
89
|
end
|
88
|
-
|
90
|
+
|
89
91
|
#######
|
90
92
|
private
|
91
93
|
#######
|
92
|
-
|
94
|
+
|
93
95
|
def password_required?
|
94
96
|
active? && (crypted_password.blank? || !password.blank?)
|
95
97
|
end
|
96
|
-
|
98
|
+
|
97
99
|
def encrypt(password)
|
98
100
|
self.class.secure_digest(password, salt, digest_version)
|
99
101
|
end
|
100
|
-
|
102
|
+
|
101
103
|
def encrypt_password
|
102
104
|
return if password.blank?
|
103
105
|
self.salt = self.class.make_token
|
104
106
|
self.crypted_password = self.class.secure_digest(password, salt, (self.respond_to?(:using_digest_version) ? PREFERRED_DIGEST_VERSION : 1))
|
105
107
|
self.using_digest_version = PREFERRED_DIGEST_VERSION if self.respond_to?(:using_digest_version)
|
106
108
|
end
|
107
|
-
|
109
|
+
|
108
110
|
def digest_version
|
109
111
|
self.respond_to?(:using_digest_version) ? (using_digest_version || 1) : 1
|
110
112
|
end
|
111
|
-
|
113
|
+
|
112
114
|
def salt_cost
|
113
115
|
BCrypt::Engine.valid_salt?(salt) ? salt.match(/\$[^\$]+\$([0-9]+)\$/)[1].to_i : 0
|
114
116
|
end
|
@@ -118,15 +120,15 @@ module Minimalist
|
|
118
120
|
# allows applications to turn off email validation
|
119
121
|
true
|
120
122
|
end
|
121
|
-
|
123
|
+
|
122
124
|
def validate_email_presence?
|
123
125
|
validate_email? && active?
|
124
126
|
end
|
125
|
-
|
127
|
+
|
126
128
|
def validate_email_format?
|
127
129
|
validate_email? && active?
|
128
130
|
end
|
129
|
-
|
131
|
+
|
130
132
|
def validate_email_uniqueness?
|
131
133
|
validate_email? && active?
|
132
134
|
end
|
data/lib/minimalist/version.rb
CHANGED
@@ -9,8 +9,12 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.homepage = "https://github.com/wwidea/minimalist_authentication"
|
10
10
|
s.summary = %q{A Rails authentication plugin that takes a minimalist approach.}
|
11
11
|
s.description = %q{A Rails authentication plugin that takes a minimalist approach. It is designed to be simple to understand, use, and modify for your application.}
|
12
|
-
|
13
|
-
s.add_dependency('bcrypt-ruby', '~> 3.
|
12
|
+
|
13
|
+
s.add_dependency('bcrypt-ruby', '~> 3.1.1')
|
14
|
+
|
15
|
+
s.add_development_dependency('rails','3.0.5')
|
16
|
+
s.add_development_dependency('sqlite3')
|
17
|
+
s.add_development_dependency('factory_girl')
|
14
18
|
|
15
19
|
s.files = `git ls-files`.split("\n")
|
16
20
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
data/test/authentication_test.rb
CHANGED
@@ -1,44 +1,48 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class AuthenticationTest < ActiveSupport::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
test "should not be able to set crypted_password through mass assignment" do
|
6
6
|
user = Factory(:user)
|
7
7
|
old_crypted_password = user.crypted_password
|
8
|
+
old_digest_version = user.using_digest_version
|
9
|
+
old_salt = user.salt
|
8
10
|
user.update_attributes(:crypted_password => 'should not work')
|
11
|
+
assert_equal(old_digest_version, user.using_digest_version)
|
12
|
+
assert_equal(old_salt, user.salt)
|
9
13
|
assert_equal(old_crypted_password, user.crypted_password)
|
10
14
|
end
|
11
|
-
|
15
|
+
|
12
16
|
test "should return active user" do
|
13
17
|
user = Factory(:user)
|
14
18
|
assert_equal([user], User.active)
|
15
19
|
end
|
16
|
-
|
20
|
+
|
17
21
|
test "should authenticate user" do
|
18
22
|
user = Factory(:user)
|
19
23
|
assert_equal(user, User.authenticate(user.email, 'password'))
|
20
24
|
end
|
21
|
-
|
25
|
+
|
22
26
|
test "should fail to authenticate when email is blank" do
|
23
27
|
user = Factory(:user)
|
24
28
|
assert_nil(User.authenticate('', 'password'))
|
25
29
|
end
|
26
|
-
|
30
|
+
|
27
31
|
test "should fail to authenticate when password is blank" do
|
28
32
|
user = Factory(:user)
|
29
33
|
assert_nil(User.authenticate(user.email, ''))
|
30
|
-
end
|
31
|
-
|
34
|
+
end
|
35
|
+
|
32
36
|
test "should fail to authenticate when user is not active" do
|
33
37
|
user = Factory(:user, :active => false)
|
34
38
|
assert_nil(User.authenticate(user.email, 'password'))
|
35
39
|
end
|
36
|
-
|
40
|
+
|
37
41
|
test "should fail to authenticate for incorrect password" do
|
38
42
|
user = Factory(:user)
|
39
43
|
assert_nil(User.authenticate(user.email, 'incorrect_password'))
|
40
44
|
end
|
41
|
-
|
45
|
+
|
42
46
|
test "should create salt and encrypted_password for new user" do
|
43
47
|
user = User.new(:email => 'test@testing.com', :password => 'testing')
|
44
48
|
assert(user.save)
|
@@ -46,38 +50,38 @@ class AuthenticationTest < ActiveSupport::TestCase
|
|
46
50
|
assert_not_nil(user.crypted_password)
|
47
51
|
assert(user.authenticated?('testing'))
|
48
52
|
end
|
49
|
-
|
53
|
+
|
50
54
|
test "should update last_logged_in_at without updating updated_at timestamp" do
|
51
55
|
user = Factory(:user, :updated_at => 1.day.ago)
|
52
56
|
updated_at = user.updated_at
|
53
57
|
user.logged_in
|
54
58
|
assert(user.updated_at == updated_at)
|
55
59
|
end
|
56
|
-
|
60
|
+
|
57
61
|
test "guest should be guest" do
|
58
62
|
assert(User.guest.is_guest?)
|
59
63
|
end
|
60
|
-
|
64
|
+
|
61
65
|
test "should allow inactive user to pass validation without an email or password" do
|
62
66
|
assert(User.new.valid?)
|
63
67
|
end
|
64
|
-
|
68
|
+
|
65
69
|
test "should fail validation for active user without email" do
|
66
70
|
user = User.new(:active => true)
|
67
71
|
assert_equal(false, user.valid?)
|
68
72
|
assert(user.errors[:email])
|
69
73
|
end
|
70
|
-
|
74
|
+
|
71
75
|
test "should fail validation for active user without password" do
|
72
76
|
user = User.new(:active => true)
|
73
77
|
assert_equal(false, user.valid?)
|
74
78
|
assert(user.errors[:password])
|
75
79
|
end
|
76
|
-
|
80
|
+
|
77
81
|
test "should use latest digest version for new users" do
|
78
82
|
assert_equal(User::PREFERRED_DIGEST_VERSION,Factory(:user).using_digest_version)
|
79
83
|
end
|
80
|
-
|
84
|
+
|
81
85
|
test "should migrate legacy users to new digest version" do
|
82
86
|
#Setup a user using the old digest version.
|
83
87
|
#This wouldn't be necessary with fixtures.
|
@@ -89,11 +93,11 @@ class AuthenticationTest < ActiveSupport::TestCase
|
|
89
93
|
assert(legacy_user.save)
|
90
94
|
assert_equal(nil, legacy_user.reload.using_digest_version)
|
91
95
|
assert_equal('86f156baf9e4868e6dcf910b65775efdeaa347d8',legacy_user.crypted_password)
|
92
|
-
|
96
|
+
|
93
97
|
# Ok, now we can finally do the test.
|
94
98
|
legacy_crypted_password = legacy_user.crypted_password
|
95
99
|
assert(legacy_user.authenticated?('my_password'))
|
96
|
-
assert_equal(
|
100
|
+
assert_equal(Minimalist::Authentication::PREFERRED_DIGEST_VERSION,legacy_user.reload.using_digest_version)
|
97
101
|
assert_not_equal(legacy_crypted_password,legacy_user.crypted_password)
|
98
102
|
end
|
99
103
|
end
|
data/test/authorization_test.rb
CHANGED
@@ -3,73 +3,73 @@ require 'test_helper'
|
|
3
3
|
class AuthorizationTest < ActiveSupport::TestCase
|
4
4
|
def AuthorizationTest.helper_method(*args); end
|
5
5
|
include Minimalist::Authorization
|
6
|
-
|
6
|
+
|
7
7
|
test "should return guest for current_user" do
|
8
8
|
assert_equal('guest', current_user.email)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
test "should return logged_in user for current_user" do
|
12
12
|
user = Factory(:user)
|
13
13
|
session[:user_id] = user.id
|
14
14
|
assert_equal(user, current_user)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
test "should pass authorization" do
|
18
18
|
user = Factory(:user)
|
19
19
|
session[:user_id] = user.id
|
20
20
|
assert(authorization_required)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
test "should fail authorization" do
|
24
24
|
assert_equal(new_session_path, authorization_required)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
test "should store location" do
|
28
28
|
store_location
|
29
|
-
assert_equal(request.
|
29
|
+
assert_equal(request.fullpath, session['return_to'])
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
test "should redirect to stored location" do
|
33
33
|
store_location
|
34
34
|
redirect_back_or_default('/')
|
35
|
-
assert_equal(request.
|
35
|
+
assert_equal(request.fullpath, redirect_to)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
test "should redirect to stored location only once" do
|
39
39
|
store_location
|
40
40
|
redirect_back_or_default('/')
|
41
|
-
assert_equal(request.
|
41
|
+
assert_equal(request.fullpath, redirect_to)
|
42
42
|
redirect_back_or_default('/')
|
43
43
|
assert_equal('/', redirect_to)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
test "should redirect to default" do
|
47
47
|
redirect_back_or_default('/')
|
48
48
|
assert_equal('/', redirect_to)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
#######
|
52
52
|
private
|
53
53
|
#######
|
54
|
-
|
54
|
+
|
55
55
|
def redirect_to(path = nil)
|
56
56
|
@redirect_to = path if path
|
57
57
|
return @redirect_to
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def session; @session ||= Hash.new; end
|
61
|
-
|
61
|
+
|
62
62
|
def action_name; nil; end
|
63
63
|
def controller_name; nil; end
|
64
64
|
def new_session_path; '/session/new'; end
|
65
|
-
|
65
|
+
|
66
66
|
def request
|
67
67
|
(Class.new do
|
68
68
|
def method
|
69
69
|
:get
|
70
70
|
end
|
71
|
-
|
72
|
-
def
|
71
|
+
|
72
|
+
def fullpath
|
73
73
|
'http://www.example.com'
|
74
74
|
end
|
75
75
|
end).new
|
data/test/factories.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module Factories
|
2
|
+
salt = User.make_token
|
2
3
|
Factory.define :user do |u|
|
3
4
|
u.active true
|
4
5
|
u.email 'test@testing.com'
|
5
|
-
u.
|
6
|
-
u.
|
6
|
+
u.salt salt
|
7
|
+
u.crypted_password User.secure_digest('password',salt,Minimalist::Authentication::PREFERRED_DIGEST_VERSION)
|
8
|
+
u.using_digest_version Minimalist::Authentication::PREFERRED_DIGEST_VERSION
|
7
9
|
end
|
8
10
|
end
|
data/test/jenkins.bash
ADDED
@@ -2,8 +2,8 @@ require 'test_helper'
|
|
2
2
|
require 'rails/performance_test_help'
|
3
3
|
|
4
4
|
# Profiling results for each test method are written to tmp/performance.
|
5
|
-
class BrowsingTest < ActionDispatch::PerformanceTest
|
6
|
-
def test_homepage
|
7
|
-
get '/'
|
8
|
-
end
|
9
|
-
end
|
5
|
+
#class BrowsingTest < ActionDispatch::PerformanceTest
|
6
|
+
# def test_homepage
|
7
|
+
# get '/'
|
8
|
+
# end
|
9
|
+
#end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimalist_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bcrypt-ruby
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 3.
|
23
|
+
version: 3.1.1
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -28,7 +28,55 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ~>
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: 3.
|
31
|
+
version: 3.1.1
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rails
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - '='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.0.5
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.5
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: sqlite3
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: factory_girl
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
32
80
|
description: A Rails authentication plugin that takes a minimalist approach. It is
|
33
81
|
designed to be simple to understand, use, and modify for your application.
|
34
82
|
email:
|
@@ -38,10 +86,11 @@ extensions: []
|
|
38
86
|
extra_rdoc_files: []
|
39
87
|
files:
|
40
88
|
- .gitignore
|
89
|
+
- Gemfile
|
90
|
+
- Gemfile.lock
|
41
91
|
- MIT-LICENSE
|
42
|
-
- README
|
92
|
+
- README.md
|
43
93
|
- Rakefile
|
44
|
-
- init.rb
|
45
94
|
- lib/app/views/sessions/_form.html.erb
|
46
95
|
- lib/app/views/sessions/new.html.erb
|
47
96
|
- lib/minimalist/authentication.rb
|
@@ -56,8 +105,7 @@ files:
|
|
56
105
|
- test/authentication_test.rb
|
57
106
|
- test/authorization_test.rb
|
58
107
|
- test/factories.rb
|
59
|
-
- test/
|
60
|
-
- test/rails_root/Gemfile.lock
|
108
|
+
- test/jenkins.bash
|
61
109
|
- test/rails_root/README
|
62
110
|
- test/rails_root/Rakefile
|
63
111
|
- test/rails_root/app/controllers/application_controller.rb
|
@@ -120,8 +168,7 @@ test_files:
|
|
120
168
|
- test/authentication_test.rb
|
121
169
|
- test/authorization_test.rb
|
122
170
|
- test/factories.rb
|
123
|
-
- test/
|
124
|
-
- test/rails_root/Gemfile.lock
|
171
|
+
- test/jenkins.bash
|
125
172
|
- test/rails_root/README
|
126
173
|
- test/rails_root/Rakefile
|
127
174
|
- test/rails_root/app/controllers/application_controller.rb
|
@@ -156,3 +203,4 @@ test_files:
|
|
156
203
|
- test/rails_root/test/test_helper.rb
|
157
204
|
- test/sessions_test.rb
|
158
205
|
- test/test_helper.rb
|
206
|
+
has_rdoc:
|
data/README
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
MinimalistAuthentication
|
2
|
-
========================
|
3
|
-
|
4
|
-
A Rails authentication plugin that takes a minimalist approach. It is designed to be simple to understand, use, and modify for your application.
|
5
|
-
|
6
|
-
This plugin was largely inspired by the restful-authentication plugin (http://github.com/technoweenie/restful-authentication/tree/master). I selected the essential methods for password based authentication, reorganized them, trimmed them down when possible, added a couple of features, and resisted the urge to start adding more.
|
7
|
-
|
8
|
-
|
9
|
-
Installation
|
10
|
-
============
|
11
|
-
script/plugin install git://github.com/aaron/minimalist_authentication.git
|
12
|
-
|
13
|
-
ruby script/generate scaffold user active:boolean email:string crypted_password:string salt:string using_digest_version:integer last_logged_in_at:datetime
|
14
|
-
|
15
|
-
|
16
|
-
Example
|
17
|
-
=======
|
18
|
-
|
19
|
-
app/models/user.rb
|
20
|
-
class User < ActiveRecord::Base
|
21
|
-
include Minimalist::Authentication
|
22
|
-
end
|
23
|
-
|
24
|
-
app/controllers/application.rb
|
25
|
-
class ApplicationController < ActionController::Base
|
26
|
-
include Minimalist::Authorization
|
27
|
-
|
28
|
-
# Lock down everything by default
|
29
|
-
# use skip_before_filter to open up sepecific actions
|
30
|
-
prepend_before_filter :authorization_required
|
31
|
-
end
|
32
|
-
|
33
|
-
app/controllers/sessions_controller.rb
|
34
|
-
class SessionsController < ApplicationController
|
35
|
-
include Minimalist::Sessions
|
36
|
-
skip_before_filter :authorization_required, :only => [:new, :create]
|
37
|
-
end
|
38
|
-
|
39
|
-
test/test_helper.rb
|
40
|
-
class Test::Unit::TestCase
|
41
|
-
include Minimalist::TestHelper
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
Copyright (c) 2009 Aaron Baldwin, released under the MIT license
|
data/init.rb
DELETED
data/test/rails_root/Gemfile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
gem 'rails', '3.0.5'
|
4
|
-
|
5
|
-
# Bundle edge Rails instead:
|
6
|
-
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
-
|
8
|
-
gem 'sqlite3-ruby', :require => 'sqlite3'
|
9
|
-
|
10
|
-
# Use unicorn as the web server
|
11
|
-
# gem 'unicorn'
|
12
|
-
|
13
|
-
# Deploy with Capistrano
|
14
|
-
# gem 'capistrano'
|
15
|
-
|
16
|
-
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
17
|
-
# gem 'ruby-debug'
|
18
|
-
# gem 'ruby-debug19'
|
19
|
-
|
20
|
-
# Bundle the extra gems:
|
21
|
-
# gem 'bj'
|
22
|
-
# gem 'nokogiri'
|
23
|
-
# gem 'sqlite3-ruby', :require => 'sqlite3'
|
24
|
-
# gem 'aws-s3', :require => 'aws/s3'
|
25
|
-
|
26
|
-
gem 'factory_girl'
|
27
|
-
|
28
|
-
# Bundle gems for the local environment. Make sure to
|
29
|
-
# put test-only gems in this group so their generators
|
30
|
-
# and rake tasks are available in development mode:
|
31
|
-
# group :development, :test do
|
32
|
-
# gem 'webrat'
|
33
|
-
# end
|