dry-stack 0.0.80 → 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/command_compose.rb +3 -1
- data/lib/dry-stack/stack.rb +11 -0
- data/lib/version.rb +1 -1
- metadata +3 -2
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
|
@@ -11,7 +11,9 @@ Dry::CommandLine::COMMANDS[:to_compose] = Class.new do
|
|
11
11
|
_params[:'no-env'] ? $stdout.puts(yaml) : system("echo \"#{yaml.gsub("`", '\\\`')}\"")
|
12
12
|
end
|
13
13
|
|
14
|
-
def help = 'Print stack in docker compose format'
|
14
|
+
def help = ['Print stack in docker compose format',
|
15
|
+
'[... to_compose <deploy name>] ']
|
16
|
+
|
15
17
|
end.new
|
16
18
|
|
17
19
|
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -3,6 +3,7 @@ require 'yaml'
|
|
3
3
|
require 'json'
|
4
4
|
require 'optparse'
|
5
5
|
require 'digest'
|
6
|
+
require_relative 'apache_specific_md5'
|
6
7
|
|
7
8
|
# class TrueClass
|
8
9
|
# def encode_with(coder) = coder.represent_scalar('tag:yaml.org,2002:str', 'true')
|
@@ -56,6 +57,7 @@ module Dry
|
|
56
57
|
def logging(opts) = (@service[:logging] ||= {}).merge! opts
|
57
58
|
def user(user) = @service[:user] = user # "${UID}:${GID}", "www-data:www-data"
|
58
59
|
def network(names) = (@service[:networks] ||= []) << names
|
60
|
+
def basic_auth(user_and_password) = @service[:basic_auth] = user_and_password
|
59
61
|
end
|
60
62
|
|
61
63
|
class SwarmFunction
|
@@ -126,6 +128,7 @@ module Dry
|
|
126
128
|
|
127
129
|
opts.merge! @swarm_deploy[deploy_name][:options]
|
128
130
|
end
|
131
|
+
|
129
132
|
compose = {
|
130
133
|
# name: @name.to_s, # https://docs.docker.com/compose/compose-file/#name-top-level-element
|
131
134
|
# Not allowed by docker stack deploy
|
@@ -146,6 +149,14 @@ module Dry
|
|
146
149
|
service[:deploy][:labels] ||= []
|
147
150
|
service[:deploy][:labels] += @labels.map { "#{_1}=#{_2}" }
|
148
151
|
|
152
|
+
if service[:basic_auth]
|
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
|
+
service[:deploy][:labels] << "traefik.http.middlewares.%{service-name}_auth.basicauth.users=#{ba_user}:#{hashed_password.gsub('$','$$')}"
|
156
|
+
service[:deploy][:labels] << "traefik.http.routers.%{service-name}.middlewares=%{service-name}_auth"
|
157
|
+
service.delete :basic_auth
|
158
|
+
end
|
159
|
+
|
149
160
|
if ingress[0] && (opts[:ingress] || opts[:traefik] || opts[:traefik_tls])
|
150
161
|
service[:networks] ||= []
|
151
162
|
service[:networks] << 'default' if service[:networks].empty?
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- bin/stack1.drs
|
107
107
|
- bin/stack2.drs
|
108
108
|
- lib/dry-stack.rb
|
109
|
+
- lib/dry-stack/apache_specific_md5.rb
|
109
110
|
- lib/dry-stack/command_compose.rb
|
110
111
|
- lib/dry-stack/command_line.rb
|
111
112
|
- lib/dry-stack/command_swarm_deploy.rb
|