basic_auth_mark 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/basic_auth_mark.gemspec +2 -2
- data/lib/basic_auth_mark.rb +12 -0
- data/lib/basic_auth_mark/middleware.rb +18 -11
- data/lib/basic_auth_mark/railtie.rb +1 -0
- data/lib/basic_auth_mark/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd31e4c0da901e5afa10db5ffb65100b55738d0b
|
4
|
+
data.tar.gz: 3c9b3a9d7d76d38eabe936d053af9e2b23326856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729660cd2276b579ac0d48f81023829d4e4551c7bd179127d7105c073f07503c6297cd313da5f0641a25b7d000e1a4b0c43c935b156948a80bec644d979fa3c8
|
7
|
+
data.tar.gz: 3bc3680bc3b71050abadcaa008c48488d41ddf5d81260eca7d11106a56018626800f8b15dc0dbfb37fd4f3a408a36c31ee7ebc1e71a6aed76699fa34519f7dd7
|
data/README.md
CHANGED
@@ -20,6 +20,8 @@ Rails.application.configure do
|
|
20
20
|
config.basic_auth_mark.position = 'left-bottom' # left-top/right-top/left-bottom/right-bottom
|
21
21
|
# change color(default: 880000)
|
22
22
|
config.basic_auth_mark.color = '0000aa'
|
23
|
+
# change markable ip addresses(default: all ip addresses)
|
24
|
+
config.basic_auth_mark.markable_ip_addresses = ['127.0.0.1']
|
23
25
|
end
|
24
26
|
```
|
25
27
|
|
data/basic_auth_mark.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["kazuki ozawa"]
|
10
10
|
spec.email = ["kazuki.ozawa@outlook.jp"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Show ribbon mark if basic authenticaiton is enabled.}
|
13
|
+
spec.description = %q{Show ribbon mark if basic authenticaiton is enabled.}
|
14
14
|
spec.homepage = 'https://github.com/g-ozawa/basic_auth_mark'
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
data/lib/basic_auth_mark.rb
CHANGED
@@ -21,5 +21,17 @@ module BasicAuthMark
|
|
21
21
|
def color=(color)
|
22
22
|
@color = color
|
23
23
|
end
|
24
|
+
|
25
|
+
def markable_ip_addresses
|
26
|
+
@markable_ip_addresses ||= []
|
27
|
+
end
|
28
|
+
|
29
|
+
def markable_ip_addresses=(markable_ip_addresses)
|
30
|
+
if markable_ip_addresses.is_a?(Array)
|
31
|
+
@markable_ip_addresses = markable_ip_addresses
|
32
|
+
else
|
33
|
+
@markable_ip_addresses = [markable_ip_addresses]
|
34
|
+
end
|
35
|
+
end
|
24
36
|
end
|
25
37
|
end
|
@@ -12,19 +12,26 @@ module BasicAuthMark
|
|
12
12
|
return [status, headers, response] unless headers['Content-Type'].to_s =~ %r{\btext/html\b}i
|
13
13
|
return [status, headers, response] if status >= 300 && status < 400
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
markable_ip_addresses = BasicAuthMark.markable_ip_addresses
|
16
|
+
|
17
|
+
request = Rack::Request.new(env)
|
18
|
+
|
19
|
+
if markable_ip_addresses.empty? || markable_ip_addresses.include?(request.ip)
|
20
|
+
basic_request = Rack::Auth::Basic::Request.new(env)
|
21
|
+
|
22
|
+
if basic_request.provided? && basic_request.basic?
|
23
|
+
new_body = ''
|
24
|
+
response.each do |b|
|
25
|
+
begin
|
26
|
+
new_body << insert_basic_auth_marks(b)
|
27
|
+
rescue => exception
|
28
|
+
$stderr.write %Q|Failed to insert basic auth marks: #{exception.message}\n #{exception.backtrace.join(" \n")}|
|
29
|
+
end
|
23
30
|
end
|
31
|
+
response.close if response.respond_to?(:close)
|
32
|
+
headers['Content-Length'] &&= new_body.bytesize.to_s
|
33
|
+
response = [new_body]
|
24
34
|
end
|
25
|
-
response.close if response.respond_to?(:close)
|
26
|
-
headers['Content-Length'] &&= new_body.bytesize.to_s
|
27
|
-
response = [new_body]
|
28
35
|
end
|
29
36
|
|
30
37
|
[status, headers, response]
|
@@ -12,6 +12,7 @@ module BasicAuthMark
|
|
12
12
|
options = config.basic_auth_mark
|
13
13
|
BasicAuthMark.position = options.position if options.position
|
14
14
|
BasicAuthMark.color = options.color if options.color
|
15
|
+
BasicAuthMark.markable_ip_addresses = options.markable_ip_addresses if options.markable_ip_addresses
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basic_auth_mark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kazuki ozawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description:
|
69
|
+
description: Show ribbon mark if basic authenticaiton is enabled.
|
70
70
|
email:
|
71
71
|
- kazuki.ozawa@outlook.jp
|
72
72
|
executables: []
|
@@ -110,5 +110,5 @@ rubyforge_project:
|
|
110
110
|
rubygems_version: 2.4.5.1
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
|
-
summary:
|
113
|
+
summary: Show ribbon mark if basic authenticaiton is enabled.
|
114
114
|
test_files: []
|