skull_island 1.2.6 → 1.2.7
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/skull_island/resources/basicauth_credential.rb +56 -4
- data/lib/skull_island/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8e575e528393418b57488afb653a8baa09afa06f97b88e86fcc7d984fb5bba6
|
4
|
+
data.tar.gz: a6a00f4e7c432fa0cfd77f6cc22b3cbbdc936043d12ac68e337d4500e8bb42d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 892f21ee6b9d43f943cbb562ae72d62e936928acc562752f8d3a7b42c3713a7281408fa401f49eb6c6394d34659131c0288c4c7832c3e5608bb58f67ee040ed3
|
7
|
+
data.tar.gz: 047ce3c0207470966af51a017d71ee23bcfa03fbe0a4371defdc4a1405e697549e519349af71ef5c3a6bcdfc8cc41d85201106d19a672d68e2fcbe8ae5d73fa9
|
data/Gemfile.lock
CHANGED
@@ -5,10 +5,12 @@ module SkullIsland
|
|
5
5
|
module Resources
|
6
6
|
# The BasicauthCredential resource class
|
7
7
|
#
|
8
|
-
# @see https://docs.konghq.com/hub/kong-inc/
|
8
|
+
# @see https://docs.konghq.com/hub/kong-inc/basic-auth/ Basic-Auth API definition
|
9
9
|
class BasicauthCredential < Resource
|
10
|
+
attr_accessor :hashed_password
|
11
|
+
|
10
12
|
property :username, required: true, validate: true
|
11
|
-
property :password, validated: true
|
13
|
+
property :password, validated: true, preprocess: true, postprocess: true
|
12
14
|
property(
|
13
15
|
:consumer,
|
14
16
|
required: true, validate: true, preprocess: true, postprocess: true
|
@@ -44,6 +46,17 @@ module SkullIsland
|
|
44
46
|
consumer ? "#{consumer.relative_uri}/basic-auth" : nil
|
45
47
|
end
|
46
48
|
|
49
|
+
def digest
|
50
|
+
Digest::MD5.hexdigest(
|
51
|
+
if new? && !password.match?(/^hash{.+}$/)
|
52
|
+
hashed_pass = Digest::SHA1.hexdigest((password || '') + consumer.id)
|
53
|
+
"#{username}:hash{#{hashed_pass}}"
|
54
|
+
else
|
55
|
+
"#{username}:#{password}"
|
56
|
+
end
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
47
60
|
def export(options = {})
|
48
61
|
hash = { 'username' => username, 'password' => password }
|
49
62
|
hash['consumer'] = "<%= lookup :consumer, '#{consumer.username}' %>" if consumer
|
@@ -56,15 +69,41 @@ module SkullIsland
|
|
56
69
|
hash.reject { |_, value| value.nil? }
|
57
70
|
end
|
58
71
|
|
59
|
-
#
|
72
|
+
# Credentials can't be updated, only deleted then created
|
60
73
|
def modified_existing?
|
61
|
-
false
|
74
|
+
return false unless new?
|
75
|
+
|
76
|
+
# Find credentials of the same username
|
77
|
+
basic_auths = consumer.credentials['basic-auth']
|
78
|
+
return false unless basic_auths
|
79
|
+
|
80
|
+
same_username = basic_auths.where(:username, username)
|
81
|
+
|
82
|
+
existing = same_username.size == 1 ? same_username.first : nil
|
83
|
+
# Need to destroy the old one then save the new one...
|
84
|
+
existing ? existing.destroy && save : false
|
62
85
|
end
|
63
86
|
|
64
87
|
def project
|
65
88
|
consumer ? consumer.project : nil
|
66
89
|
end
|
67
90
|
|
91
|
+
def <=>(other)
|
92
|
+
if id
|
93
|
+
if id < other.id
|
94
|
+
-1
|
95
|
+
elsif id > other.id
|
96
|
+
1
|
97
|
+
elsif id == other.id
|
98
|
+
0
|
99
|
+
else
|
100
|
+
raise Exceptions::InvalidArguments
|
101
|
+
end
|
102
|
+
else
|
103
|
+
digest <=> other.digest
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
68
107
|
private
|
69
108
|
|
70
109
|
def postprocess_consumer(value)
|
@@ -87,6 +126,19 @@ module SkullIsland
|
|
87
126
|
end
|
88
127
|
end
|
89
128
|
|
129
|
+
def postprocess_password(value)
|
130
|
+
hashed_password || !new? ? "hash{#{value}}" : value
|
131
|
+
end
|
132
|
+
|
133
|
+
def preprocess_password(input)
|
134
|
+
if input.match?(/^hash{.+}$/)
|
135
|
+
@hashed_password = true
|
136
|
+
input.match(/^hash{(.+)}$/)[1]
|
137
|
+
else
|
138
|
+
input
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
90
142
|
# Used to validate {#consumer} on set
|
91
143
|
def validate_consumer(value)
|
92
144
|
# allow either a Consumer object or a Hash
|
data/lib/skull_island/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skull_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deepsort
|