adminlock 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/MIT-LICENSE +18 -0
- data/app/controllers/adminlock/adminlock_controller.rb +58 -0
- data/app/controllers/adminlock/application_controller.rb +4 -0
- data/app/helper/adminlock/adminlock_helper.rb +11 -0
- data/app/helper/adminlock/application_helper.rb +4 -0
- data/app/view/adminlock/adminlock/unlock.html.erb +28 -0
- data/app/view/layout/adminlock/_common_css.html.erb +295 -0
- data/app/view/layout/adminlock/_common_js.html.erb +14 -0
- data/app/view/layout/adminlock/application.html.erb +19 -0
- data/config/routes.rb +4 -0
- data/lib/adminlock/engine.rb +15 -0
- metadata +12 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92cfbe4c86165d8f6e322e4215b68a39f4d9ec7dd52a53562674b64c1f9c4217
|
4
|
+
data.tar.gz: dc70b3824f7994fecba254943962480f9b9ab7d866d7cc9e903595dae764c067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cd193d5ddeffe929e90d55762b9570935aa392855b36cb3ed378aa9ee1263191a576e2ce6ffc5580f32662e22cdafedab91084c0c550088597c7f71894f6793
|
7
|
+
data.tar.gz: 2736b274c13b1a3f142ccb7b63aef9433928223f0539ec1ee05f5e509243acc031c821f6512032d2a78244ded263479ca834ad9aa7c0da66841ca0e486563c63
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
2
|
+
a copy of this software and associated documentation files (the
|
3
|
+
"Software"), to deal in the Software without restriction, including
|
4
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
5
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
6
|
+
permit persons to whom the Software is furnished to do so, subject to
|
7
|
+
the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be
|
10
|
+
included in all copies or substantial portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
13
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
14
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
15
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
16
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
17
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
18
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Adminlock
|
2
|
+
class AdminlockController < Adminlock::ApplicationController
|
3
|
+
CRAWLER_REGEX = /crawl|googlebot|slurp|spider|bingbot|tracker|click|parser|spider/
|
4
|
+
|
5
|
+
if self.respond_to?(:skip_before_action)
|
6
|
+
skip_before_action :check_for_adminlock
|
7
|
+
else
|
8
|
+
skip_before_filter :check_for_adminlock
|
9
|
+
end
|
10
|
+
|
11
|
+
def unlock
|
12
|
+
if params[:adminlock_codeword].present?
|
13
|
+
user_agent = request.env['HTTP_USER_AGENT'].presence
|
14
|
+
if user_agent && user_agent.downcase.match(CRAWLER_REGEX)
|
15
|
+
head :ok
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
@codeword = params[:adminlock_codeword].to_s.downcase
|
20
|
+
@return_to = params[:return_to]
|
21
|
+
if @codeword == adminlock_codeword.to_s.downcase
|
22
|
+
set_cookie
|
23
|
+
run_redirect
|
24
|
+
end
|
25
|
+
elsif request.post?
|
26
|
+
if params[:adminlock].present? && params[:adminlock].respond_to?(:'[]')
|
27
|
+
@codeword = params[:adminlock][:codeword].to_s.downcase
|
28
|
+
@return_to = params[:adminlock][:return_to]
|
29
|
+
if @codeword == adminlock_codeword.to_s.downcase
|
30
|
+
set_cookie
|
31
|
+
run_redirect
|
32
|
+
else
|
33
|
+
@wrong = true
|
34
|
+
end
|
35
|
+
else
|
36
|
+
head :ok
|
37
|
+
end
|
38
|
+
else
|
39
|
+
respond_to :html
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def set_cookie
|
46
|
+
cookies[:adminlock] = { value: @codeword.to_s.downcase, expires: (Time.now + adminlock_cookie_lifetime) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def run_redirect
|
50
|
+
if @return_to.present?
|
51
|
+
redirect_to "#{@return_to}"
|
52
|
+
else
|
53
|
+
redirect_to '/'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<h1>Please enter the code word to continue…</h1>
|
2
|
+
|
3
|
+
<% if @wrong %>
|
4
|
+
<div class="hmm">
|
5
|
+
<h3>Hmm… that doesn’t seem right. Try again?</h3>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%= form_for :adminlock, url: { action: 'unlock' } do |form| %>
|
10
|
+
<% unless @wrong == true %>
|
11
|
+
<p><%= form.password_field "codeword", placeholder: "code word", autofocus: true %></p>
|
12
|
+
<% else %>
|
13
|
+
<p><%= form.password_field "codeword", value: @codeword, class: 'nope', autofocus: true %></p>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% if adminlock_hint %>
|
17
|
+
<p id='hint_icon'>?</p>
|
18
|
+
<p id='hint'><%= adminlock_hint %></p>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if params[:return_to].present? %>
|
22
|
+
<%= form.hidden_field "return_to", value: params[:return_to] %>
|
23
|
+
<% elsif @return_to.present? %>
|
24
|
+
<%= form.hidden_field "return_to", value: @return_to %>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<p><%= button_tag "Go" %></p>
|
28
|
+
<% end %>
|
@@ -0,0 +1,295 @@
|
|
1
|
+
body {
|
2
|
+
padding: 12%;
|
3
|
+
font-family: Helvetica, sans-serif;
|
4
|
+
color: #fff;
|
5
|
+
background-color: #252525;
|
6
|
+
overflow: hidden;
|
7
|
+
}
|
8
|
+
h1 {
|
9
|
+
margin: 0 auto;
|
10
|
+
margin-top: 40px;
|
11
|
+
margin-bottom: 40px;
|
12
|
+
width: 100%;
|
13
|
+
font-family: Helvetica, sans-serif;
|
14
|
+
font-size: 60px;
|
15
|
+
text-align: center;
|
16
|
+
line-height: 70px;
|
17
|
+
}
|
18
|
+
form input[type='password'] {
|
19
|
+
display: block;
|
20
|
+
margin: 0 auto;
|
21
|
+
padding: 16px;
|
22
|
+
width: 200px;
|
23
|
+
color: #fff;
|
24
|
+
font-family: Helvetica, sans-serif;
|
25
|
+
font-size: 30px;
|
26
|
+
text-align: center;
|
27
|
+
background-color: #535353;
|
28
|
+
border: 1px solid #ccc;
|
29
|
+
-webkit-appearance: none;
|
30
|
+
outline: none;
|
31
|
+
-webkit-border-radius: 4px;
|
32
|
+
-moz-border-radius: 4px;
|
33
|
+
border-radius: 4px;
|
34
|
+
-webkit-transition: all 150ms ease-in-out;
|
35
|
+
-moz-transition: all 150ms ease-in-out;
|
36
|
+
-ms-transition: all 150ms ease-in-out;
|
37
|
+
-o-transition: all 150ms ease-in-out;
|
38
|
+
transition: all 150ms ease-in-out;
|
39
|
+
}
|
40
|
+
form input[type='password']:hover {
|
41
|
+
border-color: #ffcc33;
|
42
|
+
}
|
43
|
+
form input[type='password']:focus {
|
44
|
+
border-color: #266cec;
|
45
|
+
}
|
46
|
+
form input[type='password'].nope {
|
47
|
+
border-color: #d01a45;
|
48
|
+
background-color: #6c3137;
|
49
|
+
}
|
50
|
+
form button {
|
51
|
+
display: block;
|
52
|
+
margin: 0 auto;
|
53
|
+
padding: 6px 16px 6px 16px;
|
54
|
+
width: 232px;
|
55
|
+
color: #fff;
|
56
|
+
font-family: Helvetica, sans-serif;
|
57
|
+
font-size: 30px;
|
58
|
+
text-align: center;
|
59
|
+
background-color: #1ad056;
|
60
|
+
border: 0;
|
61
|
+
cursor: pointer;
|
62
|
+
-webkit-appearance: none;
|
63
|
+
outline: none;
|
64
|
+
-webkit-border-radius: 0;
|
65
|
+
-moz-border-radius: 0;
|
66
|
+
border-radius: 0;
|
67
|
+
-webkit-transition: all 150ms ease-in-out;
|
68
|
+
-moz-transition: all 150ms ease-in-out;
|
69
|
+
-ms-transition: all 150ms ease-in-out;
|
70
|
+
-o-transition: all 150ms ease-in-out;
|
71
|
+
transition: all 150ms ease-in-out;
|
72
|
+
}
|
73
|
+
form button:hover,
|
74
|
+
form button:focus {
|
75
|
+
background-color: #26ec67;
|
76
|
+
}
|
77
|
+
form button:active {
|
78
|
+
background-color: #266cec;
|
79
|
+
-webkit-transition: all 0 ease-in-out;
|
80
|
+
-moz-transition: all 0 ease-in-out;
|
81
|
+
-ms-transition: all 0 ease-in-out;
|
82
|
+
-o-transition: all 0 ease-in-out;
|
83
|
+
transition: all 0 ease-in-out;
|
84
|
+
}
|
85
|
+
form p {
|
86
|
+
margin-bottom: 32px
|
87
|
+
}
|
88
|
+
|
89
|
+
.hmm h3 {
|
90
|
+
display: block;
|
91
|
+
margin: 0 auto;
|
92
|
+
padding: 6px;
|
93
|
+
width: 400px;
|
94
|
+
color: #d01a45;
|
95
|
+
text-align: center;
|
96
|
+
background-color: #4a1f23;
|
97
|
+
}
|
98
|
+
#hint_icon {
|
99
|
+
width: 24px;
|
100
|
+
height: 24px;
|
101
|
+
position: absolute;
|
102
|
+
left: 50%;
|
103
|
+
text-align: center;
|
104
|
+
cursor: pointer;
|
105
|
+
color: #252525;
|
106
|
+
font-size: 16px;
|
107
|
+
line-height: 26px;
|
108
|
+
font-weight: bold;
|
109
|
+
margin: -91px 0 0 135px;
|
110
|
+
-webkit-border-radius: 15px;
|
111
|
+
-moz-border-radius: 15px;
|
112
|
+
border-radius: 15px;
|
113
|
+
background: #fff;
|
114
|
+
}
|
115
|
+
#hint {
|
116
|
+
font-size: 16px;
|
117
|
+
text-align: center;
|
118
|
+
overflow: hidden;
|
119
|
+
line-height: 0px;
|
120
|
+
margin-top: -16px;
|
121
|
+
-webkit-transition: all 150ms ease-in-out;
|
122
|
+
-moz-transition: all 150ms ease-in-out;
|
123
|
+
-ms-transition: all 150ms ease-in-out;
|
124
|
+
-o-transition: all 150ms ease-in-out;
|
125
|
+
transition: all 150ms ease-in-out;
|
126
|
+
}
|
127
|
+
#hint.show {
|
128
|
+
line-height: 18px;
|
129
|
+
margin-bottom: 23px;
|
130
|
+
}
|
131
|
+
#hint:before {
|
132
|
+
content: "Hint: ";
|
133
|
+
font-weight: bold;
|
134
|
+
}
|
135
|
+
|
136
|
+
@media only screen and (min-width : 1149px) and (max-width : 1570px) {
|
137
|
+
|
138
|
+
h1 {
|
139
|
+
width: 72%;
|
140
|
+
}
|
141
|
+
|
142
|
+
}
|
143
|
+
|
144
|
+
@media only screen and (min-width : 769px) and (max-width : 1148px) {
|
145
|
+
|
146
|
+
h1 {
|
147
|
+
width: 82%;
|
148
|
+
}
|
149
|
+
|
150
|
+
}
|
151
|
+
|
152
|
+
@media only screen and (min-width : 690px) and (max-width : 768px) {
|
153
|
+
|
154
|
+
h1 {
|
155
|
+
width: 80%;
|
156
|
+
}
|
157
|
+
|
158
|
+
}
|
159
|
+
|
160
|
+
@media only screen and (min-width : 641px) and (max-width : 689px) {
|
161
|
+
|
162
|
+
h1 {
|
163
|
+
width: 88%;
|
164
|
+
}
|
165
|
+
|
166
|
+
}
|
167
|
+
|
168
|
+
@media only screen and (min-width : 563px) and (max-width : 640px) {
|
169
|
+
|
170
|
+
h1 {
|
171
|
+
width: 90%;
|
172
|
+
}
|
173
|
+
|
174
|
+
}
|
175
|
+
|
176
|
+
@media only screen and (min-width : 481px) and (max-width : 562px) {
|
177
|
+
|
178
|
+
h1 {
|
179
|
+
width: 90%;
|
180
|
+
}
|
181
|
+
|
182
|
+
}
|
183
|
+
|
184
|
+
@media only screen and (min-width : 410px) and (max-width : 480px) {
|
185
|
+
|
186
|
+
h1 {
|
187
|
+
width: 84%;
|
188
|
+
}
|
189
|
+
|
190
|
+
}
|
191
|
+
|
192
|
+
@media only screen and (min-width : 350px) and (max-width : 409px) {
|
193
|
+
|
194
|
+
h1 {
|
195
|
+
width: 100%;
|
196
|
+
}
|
197
|
+
|
198
|
+
}
|
199
|
+
|
200
|
+
@media only screen and (min-width : 350px) and (max-width : 640px) {
|
201
|
+
body {
|
202
|
+
min-width: 1px;
|
203
|
+
max-width: 640px;
|
204
|
+
-webkit-text-size-adjust: none;
|
205
|
+
}
|
206
|
+
|
207
|
+
.mobile_only {
|
208
|
+
display: inline !important;
|
209
|
+
}
|
210
|
+
.no_mobile {
|
211
|
+
display: none !important;
|
212
|
+
}
|
213
|
+
|
214
|
+
h1 {
|
215
|
+
margin-top: 0px;
|
216
|
+
font-size: 36px;
|
217
|
+
line-height: 42px;
|
218
|
+
}
|
219
|
+
form input[type='password'] {
|
220
|
+
padding: 12px 8px;
|
221
|
+
width: 175px;
|
222
|
+
font-size: 22px;
|
223
|
+
}
|
224
|
+
form button {
|
225
|
+
width: 200px;
|
226
|
+
font-size: 22px;
|
227
|
+
}
|
228
|
+
.hmm h3 {
|
229
|
+
width: 90%;
|
230
|
+
font-size: 16px;
|
231
|
+
}
|
232
|
+
#hint_icon {
|
233
|
+
width: 20px;
|
234
|
+
height: 20px;
|
235
|
+
font-size: 12px;
|
236
|
+
line-height: 22px;
|
237
|
+
margin: -78px 0 0 105px;
|
238
|
+
}
|
239
|
+
#hint {
|
240
|
+
font-size: 14px;
|
241
|
+
margin-top: -12px;
|
242
|
+
}
|
243
|
+
#hint.show {
|
244
|
+
margin-bottom: 28px;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
@media only screen and (min-width : 1px) and (max-width : 349px) {
|
249
|
+
body {
|
250
|
+
min-width: 1px;
|
251
|
+
max-width: 349px;
|
252
|
+
-webkit-text-size-adjust: none;
|
253
|
+
}
|
254
|
+
|
255
|
+
.mobile_only {
|
256
|
+
display: inline !important;
|
257
|
+
}
|
258
|
+
.no_mobile {
|
259
|
+
display: none !important;
|
260
|
+
}
|
261
|
+
|
262
|
+
h1 {
|
263
|
+
margin-top: 0px;
|
264
|
+
width: 97%;
|
265
|
+
font-size: 32px;
|
266
|
+
line-height: 38px;
|
267
|
+
}
|
268
|
+
form input[type='password'] {
|
269
|
+
padding: 12px 8px;
|
270
|
+
width: 175px;
|
271
|
+
font-size: 22px;
|
272
|
+
}
|
273
|
+
form button {
|
274
|
+
width: 200px;
|
275
|
+
font-size: 22px;
|
276
|
+
}
|
277
|
+
.hmm h3 {
|
278
|
+
width: 90%;
|
279
|
+
font-size: 16px;
|
280
|
+
}
|
281
|
+
#hint_icon {
|
282
|
+
width: 20px;
|
283
|
+
height: 20px;
|
284
|
+
font-size: 12px;
|
285
|
+
line-height: 22px;
|
286
|
+
margin: -78px 0 0 105px;
|
287
|
+
}
|
288
|
+
#hint {
|
289
|
+
font-size: 14px;
|
290
|
+
margin-top: -12px;
|
291
|
+
}
|
292
|
+
#hint.show {
|
293
|
+
margin-bottom: 28px;
|
294
|
+
}
|
295
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
setTimeout(function () {
|
2
|
+
var hint = document.getElementById('hint');
|
3
|
+
var hint_icon = document.getElementById('hint_icon');
|
4
|
+
if (hint_icon != null) {
|
5
|
+
hint_icon.onclick = function () {
|
6
|
+
if(hint.className.indexOf('show') < 0) {
|
7
|
+
hint.className = hint.className + " show";
|
8
|
+
}
|
9
|
+
else {
|
10
|
+
hint.className = hint.className.replace(/\sshow/, '');
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}, 50);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
+
<meta name="robots" content="noindex, nofollow" />
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale = 1.0,maximum-scale = 1.0,user-scalable=no" />
|
7
|
+
|
8
|
+
<title>Please enter the code word to continue…</title>
|
9
|
+
<style>
|
10
|
+
<%= render partial: 'layouts/adminlock/common_css' %>
|
11
|
+
</style>
|
12
|
+
<script>
|
13
|
+
<%= render partial: 'layouts/adminlock/common_js' %>
|
14
|
+
</script>
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<%= yield %>
|
18
|
+
</body>
|
19
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Adminlock
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Adminlock
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec, fixture: false
|
7
|
+
g.assets false
|
8
|
+
g.helper false
|
9
|
+
end
|
10
|
+
|
11
|
+
initializer 'adminlock.app_controller' do |app|
|
12
|
+
ActiveSupport.on_load(:action_controller) { include Adminlock }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adminlock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- anoop
|
@@ -36,7 +36,18 @@ executables: []
|
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
|
+
- MIT-LICENSE
|
40
|
+
- app/controllers/adminlock/adminlock_controller.rb
|
41
|
+
- app/controllers/adminlock/application_controller.rb
|
42
|
+
- app/helper/adminlock/adminlock_helper.rb
|
43
|
+
- app/helper/adminlock/application_helper.rb
|
44
|
+
- app/view/adminlock/adminlock/unlock.html.erb
|
45
|
+
- app/view/layout/adminlock/_common_css.html.erb
|
46
|
+
- app/view/layout/adminlock/_common_js.html.erb
|
47
|
+
- app/view/layout/adminlock/application.html.erb
|
48
|
+
- config/routes.rb
|
39
49
|
- lib/adminlock.rb
|
50
|
+
- lib/adminlock/engine.rb
|
40
51
|
homepage: https://rubygems.org/gems/adminlock
|
41
52
|
licenses:
|
42
53
|
- MIT
|