codeword 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +14 -2
- data/app/controllers/codeword/codeword_controller.rb +9 -24
- data/app/views/codeword/codeword/unlock.html.erb +5 -5
- data/lib/codeword/engine.rb +0 -6
- data/lib/codeword/version.rb +1 -1
- data/lib/codeword.rb +2 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df77c174f33909ed5e7f6b4168485dea5e4888098f2ca4c41c576b60b4da44a
|
4
|
+
data.tar.gz: f0d1971d5214427371119fac86d8c63e0e40b76a23682a3cd766029e7e275460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b833d1f568e8c6e1b138b42ec0b80c2645c4def43e22b3b362fa0078d285f50a0c84efe571bd213fc81e87a666f0d0dc15a6c9a69e0e94360ec85f033b47a94b
|
7
|
+
data.tar.gz: 892591cc8b6feecccee50e0b6e084fb01f3f991f2eb21d23cef9f20a3177d517854964911c9eda0b79f7196cc76573732e01c39ee372719544a9030f5c0c11cc
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Codeword
|
2
2
|
|
3
|
-
A simple gem to more elegantly place a staging server or other in-progress rails application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet.
|
3
|
+
A simple gem to more elegantly place a staging server or other in-progress rails application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet. This is a fork of [lockup](https://github.com/interdiscipline/lockup).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -94,4 +94,16 @@ cookie_lifetime_in_weeks: 4
|
|
94
94
|
|
95
95
|
### Design Customization
|
96
96
|
|
97
|
-
If you would like to change the content or design of the codeword page, you can create the directories `app/views/layouts/codeword` and `app/views/codeword/codeword` and populate them with the default content from [here](https://github.com/
|
97
|
+
If you would like to change the content or design of the codeword page, you can create the directories `app/views/layouts/codeword` and `app/views/codeword/codeword` and populate them with the default content from [here](https://github.com/dankimio/codeword/tree/main/app/views), and then customize as desired.
|
98
|
+
|
99
|
+
## Development
|
100
|
+
|
101
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dankimio/codeword.
|
106
|
+
|
107
|
+
## License
|
108
|
+
|
109
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -2,38 +2,23 @@ module Codeword
|
|
2
2
|
class CodewordController < Codeword::ApplicationController
|
3
3
|
CRAWLER_REGEX = /crawl|googlebot|slurp|spider|bingbot|tracker|click|parser|spider/
|
4
4
|
|
5
|
-
|
6
|
-
skip_before_action :check_for_codeword
|
7
|
-
else
|
8
|
-
skip_before_filter :check_for_codeword
|
9
|
-
end
|
5
|
+
skip_before_action :check_for_codeword
|
10
6
|
|
11
7
|
def unlock
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
8
|
+
user_agent = request.env['HTTP_USER_AGENT'].presence
|
9
|
+
if user_agent && user_agent.downcase.match(CRAWLER_REGEX)
|
10
|
+
head :ok
|
11
|
+
return
|
12
|
+
end
|
18
13
|
|
14
|
+
if params[:codeword].present?
|
19
15
|
@codeword = params[:codeword].to_s.downcase
|
20
16
|
@return_to = params[:return_to]
|
21
|
-
if @codeword ==
|
17
|
+
if @codeword == codeword_code.to_s.downcase
|
22
18
|
set_cookie
|
23
19
|
run_redirect
|
24
|
-
end
|
25
|
-
elsif request.post?
|
26
|
-
if params[:codeword].present? && params[:codeword].respond_to?(:'[]')
|
27
|
-
@codeword = params[:codeword][:codeword].to_s.downcase
|
28
|
-
@return_to = params[:codeword][:return_to]
|
29
|
-
if @codeword == codeword.to_s.downcase
|
30
|
-
set_cookie
|
31
|
-
run_redirect
|
32
|
-
else
|
33
|
-
@wrong = true
|
34
|
-
end
|
35
20
|
else
|
36
|
-
|
21
|
+
@wrong = true
|
37
22
|
end
|
38
23
|
else
|
39
24
|
respond_to :html
|
@@ -9,17 +9,17 @@
|
|
9
9
|
</div>
|
10
10
|
<% end %>
|
11
11
|
|
12
|
-
<%=
|
12
|
+
<%= form_tag '/codeword/unlock' do %>
|
13
13
|
<% if params[:return_to].present? %>
|
14
|
-
<%=
|
14
|
+
<%= hidden_field_tag 'return_to', params[:return_to] %>
|
15
15
|
<% elsif @return_to.present? %>
|
16
|
-
<%=
|
16
|
+
<%= hidden_field_tag 'return_to', @return_to %>
|
17
17
|
<% end %>
|
18
18
|
|
19
19
|
<% unless @wrong == true %>
|
20
|
-
<%=
|
20
|
+
<%= password_field_tag 'codeword', nil, placeholder: "Code word", autofocus: true, required: true %>
|
21
21
|
<% else %>
|
22
|
-
<%=
|
22
|
+
<%= password_field_tag 'codeword', @codeword, class: 'nope', autofocus: true, required: true %>
|
23
23
|
<% end %>
|
24
24
|
|
25
25
|
<% if codeword_hint %>
|
data/lib/codeword/engine.rb
CHANGED
@@ -2,12 +2,6 @@ module Codeword
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace Codeword
|
4
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
5
|
initializer 'codeword.app_controller' do |_app|
|
12
6
|
ActiveSupport.on_load(:action_controller) { include Codeword }
|
13
7
|
end
|
data/lib/codeword/version.rb
CHANGED
data/lib/codeword.rb
CHANGED
@@ -6,11 +6,7 @@ module Codeword
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
|
10
|
-
before_action :check_for_codeword, except: ['unlock']
|
11
|
-
else
|
12
|
-
before_filter :check_for_codeword, except: ['unlock']
|
13
|
-
end
|
9
|
+
before_action :check_for_codeword, except: ['unlock']
|
14
10
|
end
|
15
11
|
|
16
12
|
def self.from_config(setting, secrets_or_credentials = :credentials)
|
@@ -44,7 +40,7 @@ module Codeword
|
|
44
40
|
end
|
45
41
|
|
46
42
|
def codeword_code
|
47
|
-
@
|
43
|
+
@codeword_code ||=
|
48
44
|
ENV['CODEWORD'] ||
|
49
45
|
ENV['codeword'] ||
|
50
46
|
Codeword.from_config(:codeword, :secrets) ||
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeword
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kim
|
@@ -92,6 +92,7 @@ extra_rdoc_files: []
|
|
92
92
|
files:
|
93
93
|
- ".gitignore"
|
94
94
|
- ".ruby-version"
|
95
|
+
- CHANGELOG.md
|
95
96
|
- Gemfile
|
96
97
|
- LICENSE.txt
|
97
98
|
- README.md
|