codeword 0.1.0 → 0.2.0.beta1
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/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +13 -0
- data/README.md +14 -11
- data/app/controllers/codeword/codeword_controller.rb +9 -24
- data/app/helpers/codeword/codeword_helper.rb +1 -5
- data/app/views/codeword/codeword/unlock.html.erb +5 -5
- data/codeword.gemspec +2 -2
- data/lib/codeword/engine.rb +0 -6
- data/lib/codeword/version.rb +1 -1
- data/lib/codeword.rb +5 -16
- data/screenshot.png +0 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20a9e39af2e13a2e11bbc41e27257d98c9c2e35b1a4b63580be50456aec8b8b7
|
4
|
+
data.tar.gz: ae29b06372954d34efb4aec5a71d76fda264ab346f8d2c1ca63935991ead2c77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6466641140f9f984745286ccd9d172aaf98f5cedbbbea2b2788f87c8ca72ee1596eabcbba4c1f8507c748290c8febe6c8a879b7902a27e57944060aee0023815
|
7
|
+
data.tar.gz: f6d0701f7c961ec8274356aa4c2b38557ea18ea205ef509b0c69604e6c21ce46c67ea64f341f33e613a7eea2c848e9853fe4f852ea2cd58656d3ef07cc245ba6
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
- BREAKING: Deprecate Rails secrets in favor of Rails credentials
|
4
|
+
- BREAKING: Drop support for Rails < 6.0
|
5
|
+
|
6
|
+
## [0.1.1] - 2021-12-17
|
7
|
+
|
8
|
+
- Fix unlocks
|
9
|
+
- Refactor CodewordController
|
10
|
+
|
11
|
+
## [0.1.0] - 2021-12-17
|
12
|
+
|
13
|
+
- Initial release
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Codeword
|
2
2
|
|
3
|
-
A simple gem to more elegantly place a staging server or other in-progress
|
3
|
+
A simple gem to more elegantly place a staging server or other in-progress Ruby on Rails application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet.
|
4
|
+
|
5
|
+

|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -32,14 +34,14 @@ If you think you might need a hint:
|
|
32
34
|
ENV['CODEWORD_HINT'] = 'Something that you do not tell everyone.'
|
33
35
|
```
|
34
36
|
|
35
|
-
|
37
|
+
You can add your codeword via Rails credentials in your `credentials.yml.enc` file (`$ bin/rails credentials:edit`):
|
36
38
|
|
37
39
|
```yml
|
38
40
|
codeword: 'love'
|
39
41
|
codeword_hint: 'Pepé Le Pew'
|
40
42
|
```
|
41
43
|
|
42
|
-
Alternately,
|
44
|
+
Alternately, credentials in Rails >= 5.2 may be organized under the `codeword` namespace:
|
43
45
|
|
44
46
|
```yml
|
45
47
|
codeword:
|
@@ -47,13 +49,6 @@ codeword:
|
|
47
49
|
hint: 'Pepé Le Pew'
|
48
50
|
```
|
49
51
|
|
50
|
-
If you’re using [Figaro](https://github.com/laserlemon/figaro), set your Codeword codeword and hint (optional) in your application.yml file:
|
51
|
-
|
52
|
-
```yml
|
53
|
-
codeword: 'love'
|
54
|
-
codeword_hint: 'Pepé Le Pew'
|
55
|
-
```
|
56
|
-
|
57
52
|
**Codewords are not case-sensitive, by design. Keep it simple.**
|
58
53
|
|
59
54
|
## Advanced Usage
|
@@ -94,4 +89,12 @@ cookie_lifetime_in_weeks: 4
|
|
94
89
|
|
95
90
|
### Design Customization
|
96
91
|
|
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/
|
92
|
+
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.
|
93
|
+
|
94
|
+
## Development
|
95
|
+
|
96
|
+
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).
|
97
|
+
|
98
|
+
## Acknowledgements
|
99
|
+
|
100
|
+
Codeword is a fork of [lockup](https://github.com/interdiscipline/lockup).
|
@@ -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&.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
|
@@ -3,11 +3,7 @@
|
|
3
3
|
module Codeword
|
4
4
|
module CodewordHelper
|
5
5
|
def codeword_hint
|
6
|
-
@codeword_hint ||=
|
7
|
-
ENV['CODEWORD_HINT'] ||
|
8
|
-
ENV['codeword_hint'] ||
|
9
|
-
::Codeword.from_config(:hint, :secrets) ||
|
10
|
-
::Codeword.from_config(:hint)
|
6
|
+
@codeword_hint ||= ENV['CODEWORD_HINT'] || ENV['codeword_hint'] || ::Codeword.from_config(:hint)
|
11
7
|
end
|
12
8
|
end
|
13
9
|
end
|
@@ -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/codeword.gemspec
CHANGED
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
22
|
end
|
23
23
|
|
24
|
-
spec.add_dependency 'rails', '>= 6'
|
24
|
+
spec.add_dependency 'rails', '>= 6.1'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'capybara', '~> 2.9'
|
27
27
|
spec.add_development_dependency 'debug'
|
28
28
|
spec.add_development_dependency 'launchy', '~> 2.4'
|
29
|
-
spec.add_development_dependency 'rspec-rails', '~>
|
29
|
+
spec.add_development_dependency 'rspec-rails', '~> 6.0'
|
30
30
|
end
|
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,17 +6,11 @@ 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
|
-
def self.from_config(setting
|
17
|
-
|
18
|
-
|
19
|
-
store = Rails.application.public_send(secrets_or_credentials)
|
12
|
+
def self.from_config(setting)
|
13
|
+
store = Rails.application.credentials
|
20
14
|
|
21
15
|
store.codeword.respond_to?(:fetch) &&
|
22
16
|
store.codeword.fetch(setting, store.public_send("codeword_#{setting}")) ||
|
@@ -39,21 +33,16 @@ module Codeword
|
|
39
33
|
@cookie_lifetime ||=
|
40
34
|
ENV['COOKIE_LIFETIME_IN_WEEKS'] ||
|
41
35
|
ENV['cookie_lifetime_in_weeks'] ||
|
42
|
-
Codeword.from_config(:cookie_lifetime_in_weeks, :secrets) ||
|
43
36
|
Codeword.from_config(:cookie_lifetime_in_weeks)
|
44
37
|
end
|
45
38
|
|
46
39
|
def codeword_code
|
47
|
-
@codeword
|
48
|
-
ENV['CODEWORD'] ||
|
49
|
-
ENV['codeword'] ||
|
50
|
-
Codeword.from_config(:codeword, :secrets) ||
|
51
|
-
Codeword.from_config(:codeword)
|
40
|
+
@codeword_code ||= ENV['CODEWORD'] || ENV['codeword'] || Codeword.from_config(:codeword)
|
52
41
|
end
|
53
42
|
|
54
43
|
def codeword_cookie_lifetime
|
55
44
|
seconds = (cookie_lifetime.to_f * 1.week).to_i
|
56
|
-
if seconds
|
45
|
+
if seconds.positive?
|
57
46
|
seconds
|
58
47
|
else
|
59
48
|
5.years
|
data/screenshot.png
ADDED
Binary file
|
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.
|
4
|
+
version: 0.2.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kim
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '6'
|
20
|
+
version: '6.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '6'
|
27
|
+
version: '6.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: capybara
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '6.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '6.0'
|
84
84
|
description: A simple gem to more elegantly place a staging server or other in-progress
|
85
85
|
application behind a basic codeword. It’s easy to implement, share with clients/collaborators,
|
86
86
|
and more beautiful than the typical password-protection sheet.
|
@@ -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
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- lib/codeword.rb
|
110
111
|
- lib/codeword/engine.rb
|
111
112
|
- lib/codeword/version.rb
|
113
|
+
- screenshot.png
|
112
114
|
- script/rails
|
113
115
|
homepage: https://github.com/dankimio/codeword
|
114
116
|
licenses:
|
@@ -132,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
134
|
- !ruby/object:Gem::Version
|
133
135
|
version: '0'
|
134
136
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.5.15
|
136
138
|
signing_key:
|
137
139
|
specification_version: 4
|
138
140
|
summary: Lock staging servers from search engines and prying eyespec.
|