dry-stack 0.0.81 → 0.0.82
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/lib/dry-stack/apache_specific_md5.rb +76 -0
- data/lib/dry-stack/stack.rb +3 -3
- data/lib/version.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52aef15bc22cb7ef0bdadb32c686998849894138d6f2a06ae5e5f2e6b5d59a9c
|
4
|
+
data.tar.gz: eac3ce3089cfa955adb72974b0f68ad685a22f5217637fc89874fec2dd6582e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d57962ce0e295fe0bb8432b4f3eec4c15b68ba593a7e278f03a9b0d7632789ed3a3e7f7a25aff64b478806fecdc72b5d38506cb3fb2c99e0132315d3d4adb8b9
|
7
|
+
data.tar.gz: 658c93b70b9306d935ef6b5443b4bd25a3ccdc90c9239e38bae662ea3d423c1587f38d31e12c24b633048364ab0a1aa1f7516faa40c38613953a7fd3ebac1d41
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
APR1_MAGIC = '$apr1$'
|
4
|
+
ITOA64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
5
|
+
|
6
|
+
def to64(value, length)
|
7
|
+
result = ''
|
8
|
+
length.times do
|
9
|
+
result << ITOA64[value & 0x3f]
|
10
|
+
value >>= 6
|
11
|
+
end
|
12
|
+
result
|
13
|
+
end
|
14
|
+
|
15
|
+
def apr1_crypt(password, salt)
|
16
|
+
salt = salt[0, 8]
|
17
|
+
ctx = Digest::MD5.new
|
18
|
+
ctx.update(password + APR1_MAGIC + salt)
|
19
|
+
final = Digest::MD5.digest(password + salt + password)
|
20
|
+
|
21
|
+
password.length.times { |i| ctx.update(final[i % 16].chr) }
|
22
|
+
|
23
|
+
length = password.length
|
24
|
+
while length > 0
|
25
|
+
ctx.update(length & 1 != 0 ? "\0" : password[0].chr)
|
26
|
+
length >>= 1
|
27
|
+
end
|
28
|
+
|
29
|
+
final = ctx.digest
|
30
|
+
|
31
|
+
1000.times do |i|
|
32
|
+
ctx = Digest::MD5.new
|
33
|
+
ctx.update(i & 1 != 0 ? password : final)
|
34
|
+
ctx.update(salt) unless (i % 3).zero?
|
35
|
+
ctx.update(password) unless (i % 7).zero?
|
36
|
+
ctx.update(i & 1 != 0 ? final : password)
|
37
|
+
final = ctx.digest
|
38
|
+
end
|
39
|
+
|
40
|
+
hashed = final.bytes
|
41
|
+
result = [
|
42
|
+
to64((hashed[0] << 16) | (hashed[6] << 8) | hashed[12], 4),
|
43
|
+
to64((hashed[1] << 16) | (hashed[7] << 8) | hashed[13], 4),
|
44
|
+
to64((hashed[2] << 16) | (hashed[8] << 8) | hashed[14], 4),
|
45
|
+
to64((hashed[3] << 16) | (hashed[9] << 8) | hashed[15], 4),
|
46
|
+
to64((hashed[4] << 16) | (hashed[10] << 8) | hashed[5], 4),
|
47
|
+
to64(hashed[11], 2)
|
48
|
+
].join
|
49
|
+
|
50
|
+
"#{APR1_MAGIC}#{salt}$#{result}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def apr1_check(password, hashed_password)
|
54
|
+
parts = hashed_password.split('$')
|
55
|
+
return false if parts.length != 4 || parts[1] != 'apr1'
|
56
|
+
|
57
|
+
salt = parts[2]
|
58
|
+
apr1_crypt(password, salt) == hashed_password
|
59
|
+
end
|
60
|
+
|
61
|
+
# SELF TEST ============================================================================================================
|
62
|
+
if File.expand_path($0) == File.expand_path(__FILE__)
|
63
|
+
# openssl passwd -apr1 -salt 8sFt66rZ admin
|
64
|
+
password = "admin"
|
65
|
+
salt = "976CP"
|
66
|
+
|
67
|
+
hashed_password = apr1_crypt(password, salt)
|
68
|
+
puts "APR1 Hashed Password: #{hashed_password}"
|
69
|
+
|
70
|
+
hashed_password2 = '$apr1$pkcC6Tmo$4HpuLoFryypSnXeJ1e02n/'
|
71
|
+
hashed_password3 = '$apr1$976PimCP$PU7TWdOsyivf.u35yYGsv0'
|
72
|
+
|
73
|
+
p apr1_check(password, hashed_password)
|
74
|
+
p apr1_check(password, hashed_password2)
|
75
|
+
p apr1_check(password, hashed_password3)
|
76
|
+
end
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
|
|
3
3
|
require 'json'
|
4
4
|
require 'optparse'
|
5
5
|
require 'digest'
|
6
|
-
|
6
|
+
require_relative 'apache_specific_md5'
|
7
7
|
|
8
8
|
# class TrueClass
|
9
9
|
# def encode_with(coder) = coder.represent_scalar('tag:yaml.org,2002:str', 'true')
|
@@ -150,8 +150,8 @@ module Dry
|
|
150
150
|
service[:deploy][:labels] += @labels.map { "#{_1}=#{_2}" }
|
151
151
|
|
152
152
|
if service[:basic_auth]
|
153
|
-
ba_user, ba_password = service[:basic_auth].split ':'
|
154
|
-
hashed_password =
|
153
|
+
ba_user, ba_password, salt = service[:basic_auth].split ':'
|
154
|
+
hashed_password = apr1_crypt ba_password, (salt || rand(36**8).to_s(36))
|
155
155
|
service[:deploy][:labels] << "traefik.http.middlewares.%{service-name}_auth.basicauth.users=#{ba_user}:#{hashed_password.gsub('$','$$')}"
|
156
156
|
service[:deploy][:labels] << "traefik.http.routers.%{service-name}.middlewares=%{service-name}_auth"
|
157
157
|
service.delete :basic_auth
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.82
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artyom B
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bcrypt
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +106,7 @@ files:
|
|
120
106
|
- bin/stack1.drs
|
121
107
|
- bin/stack2.drs
|
122
108
|
- lib/dry-stack.rb
|
109
|
+
- lib/dry-stack/apache_specific_md5.rb
|
123
110
|
- lib/dry-stack/command_compose.rb
|
124
111
|
- lib/dry-stack/command_line.rb
|
125
112
|
- lib/dry-stack/command_swarm_deploy.rb
|