authorized_networks 1.0.0 → 1.0.1
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
- checksums.yaml.gz.sig +2 -1
- data.tar.gz.sig +0 -0
- data/lib/authorized_networks/config.rb +13 -0
- data/lib/authorized_networks/instance.rb +19 -5
- data/lib/authorized_networks/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3954c21789b8c65cf2317bb9ddc52f25dd181a565accbe591a4e33d5768ffc5b
|
4
|
+
data.tar.gz: 06fbc9eb20a3e43cb5a232eded7b8488afca862475c4f693a21fb938cc8df58d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c28e96f6885162c0b2e4f49b72d17859d5ba97ea95aaa0cfb2cf5f299efb35aa94327e8a5fab2b8e6eb986e95f92f44885f29adbcc8518218c96ad05c9ee0dac
|
7
|
+
data.tar.gz: b9314211914c77f1cd00fe718df558fe3c4caa50d1fe444f55c67149971ddc2389b2e9a2cd51f26428aa00a50062002f31812dd0205424f68232ca63af0d644a
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�-C��!�-�sg��)��Å{��.���ve���O��u��T0��!�ƍ^�!
|
2
|
+
ͻQ��Ke����C�#{����+�(�[�1D�K+Q��5M]��|7��q��&=��]�(��5��o2����Ԋ�eZ��]3�M�����4��P�������wl�53Lͭ�٪t�C��Ȝ���ìS|�*y勏��ӥ)�g��\6}�b]{���>�n>�;��3�����O`���0A�QXL�lš�v�������u'�J�P~�8
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -30,6 +30,19 @@ module AuthorizedNetworks
|
|
30
30
|
end
|
31
31
|
attr_writer :network_list_cache_ttl
|
32
32
|
|
33
|
+
# Is this disabled?
|
34
|
+
#
|
35
|
+
# @return [Boolean]
|
36
|
+
def disabled?
|
37
|
+
@disabled || false
|
38
|
+
end
|
39
|
+
|
40
|
+
# Disable everything. Any call to valid_ip? will be returned as true and no
|
41
|
+
# network lists will be loaded.
|
42
|
+
def disable!
|
43
|
+
@disabled = true
|
44
|
+
end
|
45
|
+
|
33
46
|
private
|
34
47
|
|
35
48
|
def find_default_networks_file_path
|
@@ -20,7 +20,15 @@ module AuthorizedNetworks
|
|
20
20
|
|
21
21
|
@networks ||= begin
|
22
22
|
if @config.networks
|
23
|
-
|
23
|
+
if @config.networks.is_a?(Proc)
|
24
|
+
normalize_ips(@config.networks.call)
|
25
|
+
elsif @config.networks.is_a?(Hash)
|
26
|
+
normalize_ips(@config.networks)
|
27
|
+
elsif @config.networks.is_a?(Array)
|
28
|
+
normalize_ips(:default => @config.networks)
|
29
|
+
else
|
30
|
+
{}
|
31
|
+
end
|
24
32
|
elsif File.exist?(@config.networks_file_path)
|
25
33
|
@networks_cached_at = Time.now.utc
|
26
34
|
normalize_ips(YAML.safe_load(File.read(@config.networks_file_path)))
|
@@ -34,6 +42,8 @@ module AuthorizedNetworks
|
|
34
42
|
#
|
35
43
|
# @return [Boolean]
|
36
44
|
def valid_ip?(ip, options = {})
|
45
|
+
return true if @config.disabled?
|
46
|
+
|
37
47
|
ip = IPAddr.new(ip.to_s) rescue nil
|
38
48
|
return false unless ip.is_a?(IPAddr)
|
39
49
|
groups = options[:groups] || @config.default_groups
|
@@ -61,10 +71,14 @@ module AuthorizedNetworks
|
|
61
71
|
hash.each_with_object({}) do |(group_name, networks), hash|
|
62
72
|
networks = [networks.to_s] unless networks.is_a?(Array)
|
63
73
|
hash[group_name.to_sym] = networks.map do |network|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
74
|
+
if network.is_a?(IPAddr)
|
75
|
+
network
|
76
|
+
else
|
77
|
+
begin
|
78
|
+
IPAddr.new(network.to_s)
|
79
|
+
rescue IPAddr::InvalidAddressError
|
80
|
+
nil
|
81
|
+
end
|
68
82
|
end
|
69
83
|
end.compact
|
70
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authorized_networks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
iyQrH6PJ0xgVJNYx+DLq3eFmo2hYJkw/lVhYAK+MdajtYJbD5VvCIEHO0d5RRgV+
|
36
36
|
qnCNZoPPy0UtRmGKZTMZvVJEZiw4g0fY
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2018-03-
|
38
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description: An easy way to verify IPs are on authorized networkjs.
|
41
41
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|