minimalist_authentication 0.6.14 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +56 -52
- data/Rakefile +27 -26
- data/{test/rails_root/lib/tasks/.gitkeep → app/assets/config/minimalist_authentication_manifest.js} +0 -0
- data/app/views/sessions/_form.html.erb +5 -0
- data/app/views/sessions/new.html.erb +1 -0
- data/config/routes.rb +2 -0
- data/lib/minimalist/authentication.rb +69 -79
- data/lib/minimalist/authorization.rb +30 -35
- data/lib/minimalist/sessions.rb +45 -49
- data/lib/minimalist/test_helper.rb +5 -5
- data/lib/minimalist_authentication.rb +3 -1
- data/lib/minimalist_authentication/engine.rb +4 -0
- data/lib/{minimalist → minimalist_authentication}/version.rb +1 -1
- metadata +24 -128
- data/.gitignore +0 -6
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -101
- data/lib/app/views/sessions/_form.html.erb +0 -12
- data/lib/app/views/sessions/new.html.erb +0 -1
- data/minimalist_authentication.gemspec +0 -23
- data/test/.gitignore +0 -1
- data/test/authentication_test.rb +0 -103
- data/test/authorization_test.rb +0 -77
- data/test/factories.rb +0 -12
- data/test/jenkins.bash +0 -9
- data/test/rails_root/README +0 -256
- data/test/rails_root/Rakefile +0 -7
- data/test/rails_root/app/controllers/application_controller.rb +0 -5
- data/test/rails_root/app/controllers/sessions_controller.rb +0 -3
- data/test/rails_root/app/helpers/application_helper.rb +0 -2
- data/test/rails_root/app/models/user.rb +0 -4
- data/test/rails_root/app/views/layouts/application.html.erb +0 -14
- data/test/rails_root/config.ru +0 -4
- data/test/rails_root/config/application.rb +0 -42
- data/test/rails_root/config/boot.rb +0 -13
- data/test/rails_root/config/database.yml +0 -22
- data/test/rails_root/config/environment.rb +0 -5
- data/test/rails_root/config/environments/development.rb +0 -26
- data/test/rails_root/config/environments/production.rb +0 -49
- data/test/rails_root/config/environments/test.rb +0 -35
- data/test/rails_root/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails_root/config/initializers/inflections.rb +0 -10
- data/test/rails_root/config/initializers/mime_types.rb +0 -5
- data/test/rails_root/config/initializers/secret_token.rb +0 -7
- data/test/rails_root/config/initializers/session_store.rb +0 -8
- data/test/rails_root/config/locales/en.yml +0 -5
- data/test/rails_root/config/routes.rb +0 -5
- data/test/rails_root/db/.gitignore +0 -2
- data/test/rails_root/db/schema.rb +0 -21
- data/test/rails_root/db/seeds.rb +0 -7
- data/test/rails_root/doc/README_FOR_APP +0 -2
- data/test/rails_root/log/.gitignore +0 -1
- data/test/rails_root/log/.gitkeep +0 -0
- data/test/rails_root/script/rails +0 -6
- data/test/rails_root/test/performance/browsing_test.rb +0 -9
- data/test/rails_root/test/test_helper.rb +0 -13
- data/test/sessions_test.rb +0 -30
- data/test/test_helper.rb +0 -12
data/lib/minimalist/sessions.rb
CHANGED
@@ -1,59 +1,55 @@
|
|
1
1
|
module Minimalist
|
2
2
|
module Sessions
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
append_view_path File.join(File.dirname(__FILE__), '..', '/app/views')
|
7
|
-
end
|
3
|
+
|
4
|
+
def show
|
5
|
+
redirect_to new_session_path
|
8
6
|
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def new
|
16
|
-
end
|
8
|
+
def new
|
9
|
+
@user = User.new
|
10
|
+
end
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
12
|
+
def create
|
13
|
+
if user = User.authenticate(user_params[:email], user_params[:password])
|
14
|
+
user.logged_in
|
15
|
+
session[:user_id] = user.id
|
16
|
+
after_authentication(user)
|
17
|
+
redirect_back_or_default(login_redirect_to(user))
|
18
|
+
return
|
19
|
+
else
|
20
|
+
after_authentication_failure
|
21
|
+
flash.now[:alert] = "Couldn't log you in as '#{user_params[:email]}'"
|
22
|
+
render action: 'new'
|
30
23
|
end
|
24
|
+
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
26
|
+
def destroy
|
27
|
+
session[:user_id] = nil
|
28
|
+
flash[:notice] = "You have been logged out."
|
29
|
+
redirect_to logout_redirect_to
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def user_params
|
36
|
+
@user_params ||= params.require(:user).permit(:email, :password)
|
37
|
+
end
|
38
|
+
|
39
|
+
def login_redirect_to(user)
|
40
|
+
'/'
|
41
|
+
end
|
42
|
+
|
43
|
+
def logout_redirect_to
|
44
|
+
'/'
|
45
|
+
end
|
46
|
+
|
47
|
+
def after_authentication(user)
|
48
|
+
# overide in application
|
49
|
+
end
|
50
|
+
|
51
|
+
def after_authentication_failure
|
52
|
+
# overide in application
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Minimalist
|
2
2
|
module TestHelper
|
3
|
-
|
4
|
-
|
5
|
-
@request.session[:user_id] = user ? users(user).id : nil
|
3
|
+
def login_as(user_fixture_name, password = 'password')
|
4
|
+
post session_path, params: { user: { email: users(user_fixture_name).email, password: password } }
|
6
5
|
end
|
7
6
|
|
7
|
+
|
8
8
|
def current_user
|
9
|
-
@current_user ||= User.find(@request.session[:user_id])
|
9
|
+
@current_user ||= (@request.session[:user_id] ? User.find(@request.session[:user_id]) : nil)
|
10
10
|
end
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,153 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimalist_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Baldwin
|
8
|
-
-
|
8
|
+
- Brightways Learning
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 3.1.3
|
20
|
+
version: '5.0'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.1.3
|
27
|
+
version: '5.0'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
36
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 3.2.14
|
41
|
-
type: :development
|
42
|
-
prerelease: false
|
43
|
-
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.2.14
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: sqlite3
|
29
|
+
name: bcrypt
|
50
30
|
requirement: !ruby/object:Gem::Requirement
|
51
31
|
requirements:
|
52
32
|
- - "~>"
|
53
33
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
34
|
+
version: '3.1'
|
55
35
|
- - ">="
|
56
36
|
- !ruby/object:Gem::Version
|
57
|
-
version: 1.3
|
58
|
-
type: :
|
37
|
+
version: 3.1.3
|
38
|
+
type: :runtime
|
59
39
|
prerelease: false
|
60
40
|
version_requirements: !ruby/object:Gem::Requirement
|
61
41
|
requirements:
|
62
42
|
- - "~>"
|
63
43
|
- !ruby/object:Gem::Version
|
64
|
-
version: '1
|
44
|
+
version: '3.1'
|
65
45
|
- - ">="
|
66
46
|
- !ruby/object:Gem::Version
|
67
|
-
version: 1.3
|
47
|
+
version: 3.1.3
|
68
48
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
49
|
+
name: sqlite3
|
70
50
|
requirement: !ruby/object:Gem::Requirement
|
71
51
|
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '4.4'
|
75
52
|
- - ">="
|
76
53
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
54
|
+
version: '0'
|
78
55
|
type: :development
|
79
56
|
prerelease: false
|
80
57
|
version_requirements: !ruby/object:Gem::Requirement
|
81
58
|
requirements:
|
82
|
-
- - "~>"
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: '4.4'
|
85
59
|
- - ">="
|
86
60
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
61
|
+
version: '0'
|
88
62
|
description: A Rails authentication plugin that takes a minimalist approach. It is
|
89
63
|
designed to be simple to understand, use, and modify for your application.
|
90
64
|
email:
|
91
|
-
-
|
65
|
+
- baldwina@brightwayslearning.org
|
92
66
|
executables: []
|
93
67
|
extensions: []
|
94
68
|
extra_rdoc_files: []
|
95
69
|
files:
|
96
|
-
- ".gitignore"
|
97
|
-
- Gemfile
|
98
|
-
- Gemfile.lock
|
99
70
|
- MIT-LICENSE
|
100
71
|
- README.md
|
101
72
|
- Rakefile
|
102
|
-
-
|
103
|
-
-
|
73
|
+
- app/assets/config/minimalist_authentication_manifest.js
|
74
|
+
- app/views/sessions/_form.html.erb
|
75
|
+
- app/views/sessions/new.html.erb
|
76
|
+
- config/routes.rb
|
104
77
|
- lib/minimalist/authentication.rb
|
105
78
|
- lib/minimalist/authorization.rb
|
106
79
|
- lib/minimalist/sessions.rb
|
107
80
|
- lib/minimalist/test_helper.rb
|
108
|
-
- lib/minimalist/version.rb
|
109
81
|
- lib/minimalist_authentication.rb
|
82
|
+
- lib/minimalist_authentication/engine.rb
|
83
|
+
- lib/minimalist_authentication/version.rb
|
110
84
|
- lib/tasks/minimalist_authentication_tasks.rake
|
111
|
-
- minimalist_authentication.gemspec
|
112
|
-
- test/.gitignore
|
113
|
-
- test/authentication_test.rb
|
114
|
-
- test/authorization_test.rb
|
115
|
-
- test/factories.rb
|
116
|
-
- test/jenkins.bash
|
117
|
-
- test/rails_root/README
|
118
|
-
- test/rails_root/Rakefile
|
119
|
-
- test/rails_root/app/controllers/application_controller.rb
|
120
|
-
- test/rails_root/app/controllers/sessions_controller.rb
|
121
|
-
- test/rails_root/app/helpers/application_helper.rb
|
122
|
-
- test/rails_root/app/models/user.rb
|
123
|
-
- test/rails_root/app/views/layouts/application.html.erb
|
124
|
-
- test/rails_root/config.ru
|
125
|
-
- test/rails_root/config/application.rb
|
126
|
-
- test/rails_root/config/boot.rb
|
127
|
-
- test/rails_root/config/database.yml
|
128
|
-
- test/rails_root/config/environment.rb
|
129
|
-
- test/rails_root/config/environments/development.rb
|
130
|
-
- test/rails_root/config/environments/production.rb
|
131
|
-
- test/rails_root/config/environments/test.rb
|
132
|
-
- test/rails_root/config/initializers/backtrace_silencers.rb
|
133
|
-
- test/rails_root/config/initializers/inflections.rb
|
134
|
-
- test/rails_root/config/initializers/mime_types.rb
|
135
|
-
- test/rails_root/config/initializers/secret_token.rb
|
136
|
-
- test/rails_root/config/initializers/session_store.rb
|
137
|
-
- test/rails_root/config/locales/en.yml
|
138
|
-
- test/rails_root/config/routes.rb
|
139
|
-
- test/rails_root/db/.gitignore
|
140
|
-
- test/rails_root/db/schema.rb
|
141
|
-
- test/rails_root/db/seeds.rb
|
142
|
-
- test/rails_root/doc/README_FOR_APP
|
143
|
-
- test/rails_root/lib/tasks/.gitkeep
|
144
|
-
- test/rails_root/log/.gitignore
|
145
|
-
- test/rails_root/log/.gitkeep
|
146
|
-
- test/rails_root/script/rails
|
147
|
-
- test/rails_root/test/performance/browsing_test.rb
|
148
|
-
- test/rails_root/test/test_helper.rb
|
149
|
-
- test/sessions_test.rb
|
150
|
-
- test/test_helper.rb
|
151
85
|
homepage: https://github.com/wwidea/minimalist_authentication
|
152
86
|
licenses:
|
153
87
|
- MIT
|
@@ -168,46 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
102
|
version: '0'
|
169
103
|
requirements: []
|
170
104
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.6.12
|
172
106
|
signing_key:
|
173
107
|
specification_version: 4
|
174
108
|
summary: A Rails authentication plugin that takes a minimalist approach.
|
175
|
-
test_files:
|
176
|
-
- test/authentication_test.rb
|
177
|
-
- test/authorization_test.rb
|
178
|
-
- test/factories.rb
|
179
|
-
- test/jenkins.bash
|
180
|
-
- test/rails_root/README
|
181
|
-
- test/rails_root/Rakefile
|
182
|
-
- test/rails_root/app/controllers/application_controller.rb
|
183
|
-
- test/rails_root/app/controllers/sessions_controller.rb
|
184
|
-
- test/rails_root/app/helpers/application_helper.rb
|
185
|
-
- test/rails_root/app/models/user.rb
|
186
|
-
- test/rails_root/app/views/layouts/application.html.erb
|
187
|
-
- test/rails_root/config.ru
|
188
|
-
- test/rails_root/config/application.rb
|
189
|
-
- test/rails_root/config/boot.rb
|
190
|
-
- test/rails_root/config/database.yml
|
191
|
-
- test/rails_root/config/environment.rb
|
192
|
-
- test/rails_root/config/environments/development.rb
|
193
|
-
- test/rails_root/config/environments/production.rb
|
194
|
-
- test/rails_root/config/environments/test.rb
|
195
|
-
- test/rails_root/config/initializers/backtrace_silencers.rb
|
196
|
-
- test/rails_root/config/initializers/inflections.rb
|
197
|
-
- test/rails_root/config/initializers/mime_types.rb
|
198
|
-
- test/rails_root/config/initializers/secret_token.rb
|
199
|
-
- test/rails_root/config/initializers/session_store.rb
|
200
|
-
- test/rails_root/config/locales/en.yml
|
201
|
-
- test/rails_root/config/routes.rb
|
202
|
-
- test/rails_root/db/.gitignore
|
203
|
-
- test/rails_root/db/schema.rb
|
204
|
-
- test/rails_root/db/seeds.rb
|
205
|
-
- test/rails_root/doc/README_FOR_APP
|
206
|
-
- test/rails_root/lib/tasks/.gitkeep
|
207
|
-
- test/rails_root/log/.gitignore
|
208
|
-
- test/rails_root/log/.gitkeep
|
209
|
-
- test/rails_root/script/rails
|
210
|
-
- test/rails_root/test/performance/browsing_test.rb
|
211
|
-
- test/rails_root/test/test_helper.rb
|
212
|
-
- test/sessions_test.rb
|
213
|
-
- test/test_helper.rb
|
109
|
+
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
minimalist_authentication (0.6.14)
|
5
|
-
bcrypt (~> 3.1, >= 3.1.3)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (3.2.14)
|
11
|
-
actionpack (= 3.2.14)
|
12
|
-
mail (~> 2.5.4)
|
13
|
-
actionpack (3.2.14)
|
14
|
-
activemodel (= 3.2.14)
|
15
|
-
activesupport (= 3.2.14)
|
16
|
-
builder (~> 3.0.0)
|
17
|
-
erubis (~> 2.7.0)
|
18
|
-
journey (~> 1.0.4)
|
19
|
-
rack (~> 1.4.5)
|
20
|
-
rack-cache (~> 1.2)
|
21
|
-
rack-test (~> 0.6.1)
|
22
|
-
sprockets (~> 2.2.1)
|
23
|
-
activemodel (3.2.14)
|
24
|
-
activesupport (= 3.2.14)
|
25
|
-
builder (~> 3.0.0)
|
26
|
-
activerecord (3.2.14)
|
27
|
-
activemodel (= 3.2.14)
|
28
|
-
activesupport (= 3.2.14)
|
29
|
-
arel (~> 3.0.2)
|
30
|
-
tzinfo (~> 0.3.29)
|
31
|
-
activeresource (3.2.14)
|
32
|
-
activemodel (= 3.2.14)
|
33
|
-
activesupport (= 3.2.14)
|
34
|
-
activesupport (3.2.14)
|
35
|
-
i18n (~> 0.6, >= 0.6.4)
|
36
|
-
multi_json (~> 1.0)
|
37
|
-
arel (3.0.3)
|
38
|
-
bcrypt (3.1.11)
|
39
|
-
builder (3.0.4)
|
40
|
-
erubis (2.7.0)
|
41
|
-
factory_girl (4.5.0)
|
42
|
-
activesupport (>= 3.0.0)
|
43
|
-
hike (1.2.3)
|
44
|
-
i18n (0.7.0)
|
45
|
-
journey (1.0.4)
|
46
|
-
json (1.8.2)
|
47
|
-
mail (2.5.4)
|
48
|
-
mime-types (~> 1.16)
|
49
|
-
treetop (~> 1.4.8)
|
50
|
-
mime-types (1.25.1)
|
51
|
-
multi_json (1.10.1)
|
52
|
-
polyglot (0.3.5)
|
53
|
-
rack (1.4.5)
|
54
|
-
rack-cache (1.2)
|
55
|
-
rack (>= 0.4)
|
56
|
-
rack-ssl (1.3.4)
|
57
|
-
rack
|
58
|
-
rack-test (0.6.3)
|
59
|
-
rack (>= 1.0)
|
60
|
-
rails (3.2.14)
|
61
|
-
actionmailer (= 3.2.14)
|
62
|
-
actionpack (= 3.2.14)
|
63
|
-
activerecord (= 3.2.14)
|
64
|
-
activeresource (= 3.2.14)
|
65
|
-
activesupport (= 3.2.14)
|
66
|
-
bundler (~> 1.0)
|
67
|
-
railties (= 3.2.14)
|
68
|
-
railties (3.2.14)
|
69
|
-
actionpack (= 3.2.14)
|
70
|
-
activesupport (= 3.2.14)
|
71
|
-
rack-ssl (~> 1.3.2)
|
72
|
-
rake (>= 0.8.7)
|
73
|
-
rdoc (~> 3.4)
|
74
|
-
thor (>= 0.14.6, < 2.0)
|
75
|
-
rake (10.4.2)
|
76
|
-
rdoc (3.12.2)
|
77
|
-
json (~> 1.4)
|
78
|
-
sprockets (2.2.3)
|
79
|
-
hike (~> 1.2)
|
80
|
-
multi_json (~> 1.0)
|
81
|
-
rack (~> 1.0)
|
82
|
-
tilt (~> 1.1, != 1.3.0)
|
83
|
-
sqlite3 (1.3.10)
|
84
|
-
thor (0.19.1)
|
85
|
-
tilt (1.4.1)
|
86
|
-
treetop (1.4.15)
|
87
|
-
polyglot
|
88
|
-
polyglot (>= 0.3.1)
|
89
|
-
tzinfo (0.3.43)
|
90
|
-
|
91
|
-
PLATFORMS
|
92
|
-
ruby
|
93
|
-
|
94
|
-
DEPENDENCIES
|
95
|
-
factory_girl (~> 4.4, >= 4.4.0)
|
96
|
-
minimalist_authentication!
|
97
|
-
rails (= 3.2.14)
|
98
|
-
sqlite3 (~> 1.3, >= 1.3.9)
|
99
|
-
|
100
|
-
BUNDLED WITH
|
101
|
-
1.11.2
|