liveness 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/liveness/access.rb +14 -3
- data/lib/liveness/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630199531d58103ad49748b74a839676e701ac9e85efb7f2880f9242b66ae30b
|
4
|
+
data.tar.gz: 11efa4ea8d069d8fcd1d132eeaad736b2f3755ee390ea147b40843b68795a202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e22c3008961610bb37e82ece2372c4b66899a0990d93164cdbbc16620e44958fe26571075ac1ade583391a7d13a3f04792efae5a710f3ba14a778e9c520be88
|
7
|
+
data.tar.gz: d23c983e988c45bf0a3e4b438c29e72b391c8af559b6f1d448479dbe91a9637c0c0c35de8e7a57eb157720e68f30461ab8f6e6ffd36a76d611d753337c98dba4
|
data/Gemfile.lock
CHANGED
data/lib/liveness/access.rb
CHANGED
@@ -7,6 +7,10 @@ module Liveness
|
|
7
7
|
#
|
8
8
|
# @since 0.3.0
|
9
9
|
class Access
|
10
|
+
# @since 0.3.2
|
11
|
+
LOCAL_IPV4 = IPAddr.new('127.0.0.1')
|
12
|
+
LOCAL_IPV6 = IPAddr.new('::1')
|
13
|
+
|
10
14
|
# @param request [Rack::Request]
|
11
15
|
# @param config [Liveness::Config]
|
12
16
|
#
|
@@ -22,7 +26,7 @@ module Liveness
|
|
22
26
|
#
|
23
27
|
# @since 0.3.0
|
24
28
|
def allowed?
|
25
|
-
whitelist? && valid_token?
|
29
|
+
local? || (whitelist? && valid_token?)
|
26
30
|
end
|
27
31
|
|
28
32
|
# Is token valid
|
@@ -36,6 +40,15 @@ module Liveness
|
|
36
40
|
@config.token == @request.params['token']
|
37
41
|
end
|
38
42
|
|
43
|
+
# Is from localhost
|
44
|
+
#
|
45
|
+
# @return [Boolean]
|
46
|
+
#
|
47
|
+
# @since 0.3.2
|
48
|
+
def local?
|
49
|
+
LOCAL_IPV4.include?(@request.ip) || LOCAL_IPV6.include?(@request.ip)
|
50
|
+
end
|
51
|
+
|
39
52
|
# Is ip in whitelist
|
40
53
|
#
|
41
54
|
# @return [Boolean]
|
@@ -43,8 +56,6 @@ module Liveness
|
|
43
56
|
# @sicne 0.3.0
|
44
57
|
def whitelist?
|
45
58
|
return true if @config.ip_whitelist.empty?
|
46
|
-
return true if IPAddr.new('127.0.0.1').include?(@request.ip)
|
47
|
-
return true if IPAddr.new('::1').include?(@request.ip)
|
48
59
|
|
49
60
|
@config
|
50
61
|
.ip_whitelist
|
data/lib/liveness/version.rb
CHANGED