codeword 0.2.0.beta1 → 0.2.0.beta3
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/CHANGELOG.md +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +26 -6
- data/app/controllers/codeword/codeword_controller.rb +1 -1
- data/app/views/layouts/codeword/_inline_css.html.erb +2 -0
- data/app/views/layouts/codeword/_normalize.html.erb +2 -0
- data/app/views/layouts/codeword/application.html.erb +2 -4
- data/codeword.gemspec +2 -2
- data/lib/codeword/engine.rb +0 -4
- data/lib/codeword/version.rb +1 -1
- data/lib/codeword.rb +3 -5
- data/mise.toml +2 -0
- metadata +7 -10
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ffa70037e0cddb9a44c6fc47a7bd9e8f903570f3e78a2961221d25cd465e5b
|
4
|
+
data.tar.gz: 500afbda48f4632781878ef18b174505b1380b1d1afa86dd85e9f56c70d4b053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9703d78d830e6127fe13f77160d6ce6279b16f427a17283a100fb885934f5c97ffc6a345442b09e54c8fde882fee14474fef5e9e171d70dc90ad3133c0cd57
|
7
|
+
data.tar.gz: ef8fef69c8596dbb4f978f969841251de17ec1f87f245c4afc65254211f5ecac9e7ef94c48813b9f82e9c6f034b41c37c8904e805056f50b639cf5ec34316271
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -17,9 +17,29 @@ gem 'codeword'
|
|
17
17
|
3. Mount the engine in your application’s routes file (usually first, for best results):
|
18
18
|
|
19
19
|
```ruby
|
20
|
+
# config/routes.rb
|
20
21
|
mount Codeword::Engine, at: '/codeword'
|
21
22
|
```
|
22
23
|
|
24
|
+
4. Include the `Codeword` module in your application_controller.rb file and check for codeword:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# app/controllers/application_controller.rb
|
28
|
+
class ApplicationController < ActionController::Base
|
29
|
+
include Codeword
|
30
|
+
|
31
|
+
before_action :require_codeword!
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
5. Skip the check for codeword in the controller(s) you would like to restrict:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
class APIController < ApplicationController
|
39
|
+
skip_before_action :require_codeword!, raise: false
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
23
43
|
## Usage
|
24
44
|
|
25
45
|
To set a codeword, define CODEWORD in your environments/your_environment.rb file like so:
|
@@ -37,16 +57,16 @@ ENV['CODEWORD_HINT'] = 'Something that you do not tell everyone.'
|
|
37
57
|
You can add your codeword via Rails credentials in your `credentials.yml.enc` file (`$ bin/rails credentials:edit`):
|
38
58
|
|
39
59
|
```yml
|
40
|
-
codeword:
|
41
|
-
codeword_hint:
|
60
|
+
codeword: "love"
|
61
|
+
codeword_hint: "Pepé Le Pew"
|
42
62
|
```
|
43
63
|
|
44
64
|
Alternately, credentials in Rails >= 5.2 may be organized under the `codeword` namespace:
|
45
65
|
|
46
66
|
```yml
|
47
67
|
codeword:
|
48
|
-
codeword:
|
49
|
-
hint:
|
68
|
+
codeword: "love"
|
69
|
+
hint: "Pepé Le Pew"
|
50
70
|
```
|
51
71
|
|
52
72
|
**Codewords are not case-sensitive, by design. Keep it simple.**
|
@@ -60,13 +80,13 @@ codeword:
|
|
60
80
|
2. In your application_controller.rb file, add:
|
61
81
|
|
62
82
|
```ruby
|
63
|
-
skip_before_action :
|
83
|
+
skip_before_action :require_codeword!, raise: false
|
64
84
|
```
|
65
85
|
|
66
86
|
4. In the controller(s) you would like to restrict:
|
67
87
|
|
68
88
|
```ruby
|
69
|
-
before_action :
|
89
|
+
before_action :require_codeword!
|
70
90
|
```
|
71
91
|
|
72
92
|
### Link it with no typing:
|
@@ -2,7 +2,7 @@ module Codeword
|
|
2
2
|
class CodewordController < Codeword::ApplicationController
|
3
3
|
CRAWLER_REGEX = /crawl|googlebot|slurp|spider|bingbot|tracker|click|parser|spider/
|
4
4
|
|
5
|
-
skip_before_action :
|
5
|
+
skip_before_action :require_codeword!, raise: false
|
6
6
|
|
7
7
|
def unlock
|
8
8
|
user_agent = request.env['HTTP_USER_AGENT'].presence
|
@@ -8,10 +8,8 @@
|
|
8
8
|
|
9
9
|
<title>Please enter the code word to continue…</title>
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
<%= render partial: 'layouts/codeword/inline_css' %>
|
14
|
-
</style>
|
11
|
+
<%= render partial: 'layouts/codeword/normalize' %>
|
12
|
+
<%= render partial: 'layouts/codeword/inline_css' %>
|
15
13
|
</head>
|
16
14
|
|
17
15
|
<body>
|
data/codeword.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'codeword'
|
7
7
|
spec.version = Codeword::VERSION
|
8
8
|
spec.authors = ['Dan Kim', 'gb Studio']
|
9
|
-
spec.email = ['
|
9
|
+
spec.email = ['git@dan.kim']
|
10
10
|
|
11
11
|
spec.summary = 'Lock staging servers from search engines and prying eyespec.'
|
12
12
|
spec.description = 'A simple gem to more elegantly place a staging server or other in-progress application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet.'
|
@@ -21,7 +21,7 @@ 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', '>=
|
24
|
+
spec.add_dependency 'rails', '>= 7.2'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'capybara', '~> 2.9'
|
27
27
|
spec.add_development_dependency 'debug'
|
data/lib/codeword/engine.rb
CHANGED
data/lib/codeword/version.rb
CHANGED
data/lib/codeword.rb
CHANGED
@@ -5,10 +5,6 @@ require 'codeword/engine'
|
|
5
5
|
module Codeword
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
-
included do
|
9
|
-
before_action :check_for_codeword, except: ['unlock']
|
10
|
-
end
|
11
|
-
|
12
8
|
def self.from_config(setting)
|
13
9
|
store = Rails.application.credentials
|
14
10
|
|
@@ -19,7 +15,7 @@ module Codeword
|
|
19
15
|
|
20
16
|
private
|
21
17
|
|
22
|
-
def
|
18
|
+
def require_codeword!
|
23
19
|
return unless respond_to?(:codeword) && codeword_code
|
24
20
|
return if cookies[:codeword].present? && cookies[:codeword] == codeword_code.to_s.downcase
|
25
21
|
|
@@ -29,6 +25,8 @@ module Codeword
|
|
29
25
|
)
|
30
26
|
end
|
31
27
|
|
28
|
+
alias_method :check_for_codeword, :require_codeword!
|
29
|
+
|
32
30
|
def cookie_lifetime
|
33
31
|
@cookie_lifetime ||=
|
34
32
|
ENV['COOKIE_LIFETIME_IN_WEEKS'] ||
|
data/mise.toml
ADDED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeword
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kim
|
8
8
|
- gb Studio
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
@@ -17,14 +16,14 @@ dependencies:
|
|
17
16
|
requirements:
|
18
17
|
- - ">="
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
19
|
+
version: '7.2'
|
21
20
|
type: :runtime
|
22
21
|
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
24
|
- - ">="
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
26
|
+
version: '7.2'
|
28
27
|
- !ruby/object:Gem::Dependency
|
29
28
|
name: capybara
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,13 +84,12 @@ description: A simple gem to more elegantly place a staging server or other in-p
|
|
85
84
|
application behind a basic codeword. It’s easy to implement, share with clients/collaborators,
|
86
85
|
and more beautiful than the typical password-protection sheet.
|
87
86
|
email:
|
88
|
-
-
|
87
|
+
- git@dan.kim
|
89
88
|
executables: []
|
90
89
|
extensions: []
|
91
90
|
extra_rdoc_files: []
|
92
91
|
files:
|
93
92
|
- ".gitignore"
|
94
|
-
- ".ruby-version"
|
95
93
|
- CHANGELOG.md
|
96
94
|
- Gemfile
|
97
95
|
- LICENSE.txt
|
@@ -110,6 +108,7 @@ files:
|
|
110
108
|
- lib/codeword.rb
|
111
109
|
- lib/codeword/engine.rb
|
112
110
|
- lib/codeword/version.rb
|
111
|
+
- mise.toml
|
113
112
|
- screenshot.png
|
114
113
|
- script/rails
|
115
114
|
homepage: https://github.com/dankimio/codeword
|
@@ -119,7 +118,6 @@ metadata:
|
|
119
118
|
homepage_uri: https://github.com/dankimio/codeword
|
120
119
|
source_code_uri: https://github.com/dankimio/codeword
|
121
120
|
changelog_uri: https://github.com/dankimio/codeword/CHANGELOG.md
|
122
|
-
post_install_message:
|
123
121
|
rdoc_options: []
|
124
122
|
require_paths:
|
125
123
|
- lib
|
@@ -134,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
132
|
- !ruby/object:Gem::Version
|
135
133
|
version: '0'
|
136
134
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
-
signing_key:
|
135
|
+
rubygems_version: 3.7.1
|
139
136
|
specification_version: 4
|
140
137
|
summary: Lock staging servers from search engines and prying eyespec.
|
141
138
|
test_files: []
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.3.4
|