gitlab-mail_room 1.0.0 → 1.2.0
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/.github/workflows/ci.yml +3 -2
- data/.gitlab-ci.yml +1 -1
- data/.rubocop_todo.yml +9 -0
- data/CHANGELOG.md +12 -0
- data/README.md +4 -0
- data/lib/mail_room/arbitration/redis.rb +9 -22
- data/lib/mail_room/delivery/sidekiq.rb +10 -22
- data/lib/mail_room/redis_client_builder.rb +35 -0
- data/lib/mail_room/redis_credentials_provider.rb +52 -0
- data/lib/mail_room/version.rb +1 -1
- data/mail_room.gemspec +8 -4
- data/spec/lib/arbitration/redis_spec.rb +40 -0
- data/spec/lib/coordinator_spec.rb +1 -1
- data/spec/lib/delivery/postback_spec.rb +5 -1
- data/spec/lib/delivery/sidekiq_spec.rb +42 -0
- data/spec/lib/microsoft_graph/connection_spec.rb +3 -3
- metadata +55 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af85ac3afea2ae7872cce6fc431f960f9363d4e584a151e31ce9d725e117950b
|
|
4
|
+
data.tar.gz: 43b48ddebb1e853791b829a2702d4df288f1bd5adf52fe3e7650b4818db251fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 236dd78dcead247d9e69009f5698f9796e0b4eeccce286e6c0027176bb2214f1251b8ee8ffb48620e2fda064647512af928cb3a63c01842700ad91869bb111ed
|
|
7
|
+
data.tar.gz: '0368c5b56018dee27c2468a53d6530f07f3d79a23abcc3322495ef24f438b85b6f47f7fa29734dfd2820b6593e15321aa8076ee09691ec03d8ca0577d3471b21'
|
data/.github/workflows/ci.yml
CHANGED
data/.gitlab-ci.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -97,6 +97,14 @@ Layout/MultilineBlockLayout:
|
|
|
97
97
|
Exclude:
|
|
98
98
|
- 'spec/lib/delivery/que_spec.rb'
|
|
99
99
|
|
|
100
|
+
# Offense count: 1
|
|
101
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
102
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
103
|
+
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
|
104
|
+
Layout/MultilineMethodCallIndentation:
|
|
105
|
+
Exclude:
|
|
106
|
+
- 'lib/mail_room/imap/connection.rb'
|
|
107
|
+
|
|
100
108
|
# Offense count: 3
|
|
101
109
|
# This cop supports safe autocorrection (--autocorrect).
|
|
102
110
|
# Configuration parameters: EnforcedStyle.
|
|
@@ -281,6 +289,7 @@ Style/Documentation:
|
|
|
281
289
|
- 'lib/mail_room/arbitration/redis.rb'
|
|
282
290
|
- 'lib/mail_room/connection.rb'
|
|
283
291
|
- 'lib/mail_room/crash_handler.rb'
|
|
292
|
+
- 'lib/mail_room/health_check.rb'
|
|
284
293
|
- 'lib/mail_room/delivery.rb'
|
|
285
294
|
- 'lib/mail_room/imap.rb'
|
|
286
295
|
- 'lib/mail_room/imap/connection.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## gitlab-mail_room 1.2.0 ##
|
|
2
|
+
|
|
3
|
+
* Add Redis cloud auth support (rotating short-lived tokens, such as Microsoft Entra on Azure Managed Redis) via the new `redis_credentials_provider` and `redis_username` options for Sidekiq delivery and Redis arbitration
|
|
4
|
+
* Add `redis-cloud-auth` and `az-identity` runtime dependencies
|
|
5
|
+
|
|
6
|
+
## gitlab-mail_room 1.1.0 ##
|
|
7
|
+
|
|
8
|
+
* Bump `net-imap` to `>= 0.5, < 0.7` (allows the 0.6.x line on Ruby 3.2+)
|
|
9
|
+
* Raise minimum Ruby to 3.1 (`required_ruby_version >= 3.1`), required by `net-imap` 0.5+
|
|
10
|
+
* Modernize runtime dependency bounds: `oauth2 >= 2.0.9, < 3`, `jwt >= 2.0, < 4`, `redis-namespace >= 1.8.2, < 2`
|
|
11
|
+
* Drop Ruby 3.0 from the CI matrix (GitLab CI and GitHub Actions now test 3.1–3.4 and 4.0)
|
|
12
|
+
|
|
1
13
|
## mail_room 0.11.1 ##
|
|
2
14
|
|
|
3
15
|
https://github.com/tpitale/mail_room/compare/v0.11.0...v0.11.1
|
data/README.md
CHANGED
|
@@ -282,6 +282,10 @@ Delivery options:
|
|
|
282
282
|
Required, defaults to `redis://localhost:6379`.
|
|
283
283
|
- **sentinels**: A list of sentinels servers used to provide HA to Redis. (see [Sentinel Support](#sentinel-support))
|
|
284
284
|
Optional.
|
|
285
|
+
- **redis_username**: The Redis AUTH username, applied with or without `redis_credentials_provider`. When using `redis_credentials_provider`, set this to the identity (for Azure, the managed identity's object ID). The identity may instead be supplied in the `redis_url` userinfo, or inside the `redis_credentials_provider` descriptor itself (ElastiCache carries it as `user_id`; other providers as `username`); `redis_username` takes precedence, and the descriptor identity is used only when `redis_username` is unset.
|
|
286
|
+
Optional.
|
|
287
|
+
- **redis_credentials_provider**: Authenticate with a short-lived, rotating token (for example Microsoft Entra on Azure Managed Redis) instead of a static password. A hash of provider options, for example `{ :provider: azure, :resource: https://redis.azure.com }`. Use a `rediss://` URL. Uses the [`redis-cloud-auth`](https://gitlab.com/gitlab-org/ruby/gems/redis-cloud-auth) gem, which loads the per-provider SDK lazily on first connect. The `azure` provider's SDK, [`az-identity`](https://gitlab.com/gitlab-org/ruby/gems/az-identity), is a runtime dependency of mail_room, so you do not need to add it yourself. The `gcp` and `elasticache` providers need `googleauth` and `aws-sigv4` respectively; these are not bundled, so a standalone install (such as the CNG mailroom image, which installs only mail_room's runtime dependencies) must add them to its environment. When mail_room runs inside the GitLab Rails bundle (Omnibus or source), all three are already present. The same options are supported under `arbitration_options`.
|
|
288
|
+
Optional.
|
|
285
289
|
- **namespace**: [DEPRECATED] The Redis namespace Sidekiq works under. Use the same Redis namespace that's used to configure Sidekiq.
|
|
286
290
|
Optional.
|
|
287
291
|
- **queue**: The Sidekiq queue the job is pushed onto. Make sure Sidekiq actually reads off this queue.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
require "redis"
|
|
2
|
+
require "mail_room/redis_client_builder"
|
|
2
3
|
|
|
3
4
|
module MailRoom
|
|
4
5
|
module Arbitration
|
|
5
6
|
class Redis
|
|
6
|
-
Options = Struct.new(
|
|
7
|
+
Options = Struct.new(
|
|
8
|
+
:redis_url, :redis_ssl_params, :namespace, :redis_db, :sentinels,
|
|
9
|
+
:sentinel_username, :sentinel_password, :redis_username, :redis_credentials_provider
|
|
10
|
+
) do
|
|
7
11
|
def initialize(mailbox)
|
|
8
12
|
redis_url = mailbox.arbitration_options[:redis_url] || "redis://localhost:6379"
|
|
9
13
|
redis_ssl_params = mailbox.arbitration_options[:redis_ssl_params]
|
|
@@ -12,6 +16,8 @@ module MailRoom
|
|
|
12
16
|
sentinels = mailbox.arbitration_options[:sentinels]
|
|
13
17
|
sentinel_username = mailbox.arbitration_options[:sentinel_username]
|
|
14
18
|
sentinel_password = mailbox.arbitration_options[:sentinel_password]
|
|
19
|
+
redis_username = mailbox.arbitration_options[:redis_username]
|
|
20
|
+
redis_credentials_provider = mailbox.arbitration_options[:redis_credentials_provider]
|
|
15
21
|
|
|
16
22
|
if namespace
|
|
17
23
|
warn <<~MSG
|
|
@@ -20,7 +26,7 @@ module MailRoom
|
|
|
20
26
|
MSG
|
|
21
27
|
end
|
|
22
28
|
|
|
23
|
-
super(redis_url, redis_ssl_params, namespace, redis_db, sentinels, sentinel_username, sentinel_password)
|
|
29
|
+
super(redis_url, redis_ssl_params, namespace, redis_db, sentinels, sentinel_username, sentinel_password, redis_username, redis_credentials_provider)
|
|
24
30
|
end
|
|
25
31
|
end
|
|
26
32
|
|
|
@@ -48,26 +54,7 @@ module MailRoom
|
|
|
48
54
|
private
|
|
49
55
|
|
|
50
56
|
def client
|
|
51
|
-
@client ||=
|
|
52
|
-
sentinels = options.sentinels
|
|
53
|
-
redis_options = { url: options.redis_url, db: options.redis_db }
|
|
54
|
-
# Needed for redis-client 0.26.2 and older: https://github.com/redis-rb/redis-client/pull/277
|
|
55
|
-
redis_options[:ssl] = true if options.redis_url.start_with?("rediss://")
|
|
56
|
-
redis_options[:ssl_params] = options.redis_ssl_params if options.redis_ssl_params
|
|
57
|
-
redis_options[:sentinels] = sentinels if sentinels
|
|
58
|
-
redis_options[:sentinel_username] = options.sentinel_username if options.sentinel_username
|
|
59
|
-
redis_options[:sentinel_password] = options.sentinel_password if options.sentinel_password
|
|
60
|
-
|
|
61
|
-
redis = ::Redis.new(redis_options)
|
|
62
|
-
|
|
63
|
-
namespace = options.namespace
|
|
64
|
-
if namespace
|
|
65
|
-
require 'redis/namespace'
|
|
66
|
-
::Redis::Namespace.new(namespace, redis: redis)
|
|
67
|
-
else
|
|
68
|
-
redis
|
|
69
|
-
end
|
|
70
|
-
end
|
|
57
|
+
@client ||= MailRoom::RedisClientBuilder.build(options)
|
|
71
58
|
end
|
|
72
59
|
end
|
|
73
60
|
end
|
|
@@ -2,13 +2,18 @@ require "redis"
|
|
|
2
2
|
require "securerandom"
|
|
3
3
|
require "json"
|
|
4
4
|
require "charlock_holmes"
|
|
5
|
+
require "mail_room/redis_client_builder"
|
|
5
6
|
|
|
6
7
|
module MailRoom
|
|
7
8
|
module Delivery
|
|
8
9
|
# Sidekiq Delivery method
|
|
9
10
|
# @author Douwe Maan
|
|
10
11
|
class Sidekiq
|
|
11
|
-
Options = Struct.new(
|
|
12
|
+
Options = Struct.new(
|
|
13
|
+
:redis_url, :redis_ssl_params, :namespace, :sentinels, :queue, :worker,
|
|
14
|
+
:logger, :redis_db, :sentinel_username, :sentinel_password, :redis_username,
|
|
15
|
+
:redis_credentials_provider
|
|
16
|
+
) do
|
|
12
17
|
def initialize(mailbox)
|
|
13
18
|
redis_url = mailbox.delivery_options[:redis_url] || "redis://localhost:6379"
|
|
14
19
|
redis_ssl_params = mailbox.delivery_options[:redis_ssl_params]
|
|
@@ -20,6 +25,8 @@ module MailRoom
|
|
|
20
25
|
queue = mailbox.delivery_options[:queue] || "default"
|
|
21
26
|
worker = mailbox.delivery_options[:worker]
|
|
22
27
|
logger = mailbox.logger
|
|
28
|
+
redis_username = mailbox.delivery_options[:redis_username]
|
|
29
|
+
redis_credentials_provider = mailbox.delivery_options[:redis_credentials_provider]
|
|
23
30
|
|
|
24
31
|
if namespace
|
|
25
32
|
warn <<~MSG
|
|
@@ -28,7 +35,7 @@ module MailRoom
|
|
|
28
35
|
MSG
|
|
29
36
|
end
|
|
30
37
|
|
|
31
|
-
super(redis_url, redis_ssl_params, namespace, sentinels, queue, worker, logger, redis_db, sentinel_username, sentinel_password)
|
|
38
|
+
super(redis_url, redis_ssl_params, namespace, sentinels, queue, worker, logger, redis_db, sentinel_username, sentinel_password, redis_username, redis_credentials_provider)
|
|
32
39
|
end
|
|
33
40
|
end
|
|
34
41
|
|
|
@@ -54,26 +61,7 @@ module MailRoom
|
|
|
54
61
|
private
|
|
55
62
|
|
|
56
63
|
def client
|
|
57
|
-
@client ||=
|
|
58
|
-
sentinels = options.sentinels
|
|
59
|
-
redis_options = { url: options.redis_url, db: options.redis_db }
|
|
60
|
-
# Needed for redis-client 0.26.2 and older: https://github.com/redis-rb/redis-client/pull/277
|
|
61
|
-
redis_options[:ssl] = true if options.redis_url.start_with?("rediss://")
|
|
62
|
-
redis_options[:ssl_params] = options.redis_ssl_params if options.redis_ssl_params
|
|
63
|
-
redis_options[:sentinels] = sentinels if sentinels
|
|
64
|
-
redis_options[:sentinel_username] = options.sentinel_username if options.sentinel_username
|
|
65
|
-
redis_options[:sentinel_password] = options.sentinel_password if options.sentinel_password
|
|
66
|
-
|
|
67
|
-
redis = ::Redis.new(redis_options)
|
|
68
|
-
|
|
69
|
-
namespace = options.namespace
|
|
70
|
-
if namespace
|
|
71
|
-
require 'redis/namespace'
|
|
72
|
-
Redis::Namespace.new(namespace, redis: redis)
|
|
73
|
-
else
|
|
74
|
-
redis
|
|
75
|
-
end
|
|
76
|
-
end
|
|
64
|
+
@client ||= MailRoom::RedisClientBuilder.build(options)
|
|
77
65
|
end
|
|
78
66
|
|
|
79
67
|
def item_for(message)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "redis"
|
|
2
|
+
require "mail_room/redis_credentials_provider"
|
|
3
|
+
|
|
4
|
+
module MailRoom
|
|
5
|
+
# Builds the Redis client shared by the arbitration and Sidekiq-delivery
|
|
6
|
+
# paths. Both take the same Redis connection fields and optional
|
|
7
|
+
# credentials-provider (rotating-token) auth, so the wiring lives here once.
|
|
8
|
+
module RedisClientBuilder
|
|
9
|
+
class << self
|
|
10
|
+
# +options+ is an arbitration/delivery Options struct.
|
|
11
|
+
def build(options)
|
|
12
|
+
redis = ::Redis.new(redis_options(options))
|
|
13
|
+
return redis unless options.namespace
|
|
14
|
+
|
|
15
|
+
require "redis/namespace"
|
|
16
|
+
::Redis::Namespace.new(options.namespace, redis: redis)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def redis_options(options)
|
|
22
|
+
redis_options = { url: options.redis_url, db: options.redis_db }
|
|
23
|
+
# Needed for redis-client 0.26.2 and older: https://github.com/redis-rb/redis-client/pull/277
|
|
24
|
+
redis_options[:ssl] = true if options.redis_url.start_with?("rediss://")
|
|
25
|
+
redis_options[:ssl_params] = options.redis_ssl_params if options.redis_ssl_params
|
|
26
|
+
redis_options[:sentinels] = options.sentinels if options.sentinels
|
|
27
|
+
redis_options[:sentinel_username] = options.sentinel_username if options.sentinel_username
|
|
28
|
+
redis_options[:sentinel_password] = options.sentinel_password if options.sentinel_password
|
|
29
|
+
redis_options[:username] = options.redis_username if options.redis_username
|
|
30
|
+
|
|
31
|
+
MailRoom::RedisCredentialsProvider.configure(redis_options, options)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module MailRoom
|
|
2
|
+
# Wires rotating-token (cloud identity) Redis authentication into the
|
|
3
|
+
# arbitration and Sidekiq-delivery Redis clients, via the redis-cloud-auth
|
|
4
|
+
# gem. The connection authenticates with a short-lived token instead of a
|
|
5
|
+
# static password, and long-lived connections are re-authenticated before the
|
|
6
|
+
# token expires.
|
|
7
|
+
module RedisCredentialsProvider
|
|
8
|
+
class << self
|
|
9
|
+
# Augments +redis_options+ (a Hash passed to Redis.new) with a callable
|
|
10
|
+
# token password and the middleware descriptor, when +options+ carries a
|
|
11
|
+
# credentials_provider. +options+ is an arbitration/delivery Options
|
|
12
|
+
# struct. Returns the same Hash.
|
|
13
|
+
def configure(redis_options, options)
|
|
14
|
+
provider = options.redis_credentials_provider
|
|
15
|
+
return redis_options unless provider
|
|
16
|
+
|
|
17
|
+
require "redis_cloud_auth"
|
|
18
|
+
register!
|
|
19
|
+
|
|
20
|
+
descriptor = symbolize(provider)
|
|
21
|
+
descriptor[:username] ||= options.redis_username
|
|
22
|
+
|
|
23
|
+
# The AUTH identity is the Redis username; the caller has already applied
|
|
24
|
+
# redis_username (if set). Fall back to a descriptor identity for
|
|
25
|
+
# providers that carry it there: ElastiCache as :user_id, others as
|
|
26
|
+
# :username. Otherwise redis-client reads it from the URL userinfo.
|
|
27
|
+
# GCP MemoryStore needs no username.
|
|
28
|
+
redis_options[:username] ||= descriptor[:username] || descriptor[:user_id]
|
|
29
|
+
redis_options[:password] = ::RedisCloudAuth.credential(descriptor)
|
|
30
|
+
redis_options[:custom] = { credentials_provider: descriptor }
|
|
31
|
+
redis_options
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# RedisClient.register appends on each call, so only register the
|
|
37
|
+
# middleware once per process. The gem's default logger is a no-op; we do
|
|
38
|
+
# not wire mail_room's structured logger because it raises on the plain
|
|
39
|
+
# string messages the middleware logs. Re-auth failures are non-fatal.
|
|
40
|
+
def register!
|
|
41
|
+
return if @registered
|
|
42
|
+
|
|
43
|
+
::RedisCloudAuth.register!
|
|
44
|
+
@registered = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def symbolize(hash)
|
|
48
|
+
hash.transform_keys(&:to_sym)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/mail_room/version.rb
CHANGED
data/mail_room.gemspec
CHANGED
|
@@ -17,11 +17,15 @@ Gem::Specification.new do |gem|
|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
gem.require_paths = ["lib"]
|
|
19
19
|
|
|
20
|
-
gem.
|
|
21
|
-
|
|
22
|
-
gem.add_dependency "
|
|
20
|
+
gem.required_ruby_version = ">= 3.1"
|
|
21
|
+
|
|
22
|
+
gem.add_dependency "net-imap", [">= 0.5", "< 0.7"]
|
|
23
|
+
gem.add_dependency "oauth2", [">= 2.0.9", "< 3"]
|
|
24
|
+
gem.add_dependency "jwt", [">= 2.0", "< 4"]
|
|
25
|
+
gem.add_dependency "az-identity", "~> 0.1"
|
|
23
26
|
gem.add_dependency "redis", [">= 5", "< 6"]
|
|
24
|
-
gem.add_dependency "redis-
|
|
27
|
+
gem.add_dependency "redis-cloud-auth", "~> 0.1"
|
|
28
|
+
gem.add_dependency "redis-namespace", [">= 1.8.2", "< 2"]
|
|
25
29
|
|
|
26
30
|
gem.add_development_dependency "rake"
|
|
27
31
|
gem.add_development_dependency "rspec", "~> 3.9"
|
|
@@ -192,5 +192,45 @@ describe MailRoom::Arbitration::Redis do
|
|
|
192
192
|
expect(raw_client.config.ssl_params).to eq(redis_ssl_params)
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
|
+
|
|
196
|
+
context 'when a credentials_provider is configured' do
|
|
197
|
+
let(:redis_username) { "identity-object-id" }
|
|
198
|
+
let(:mailbox) {
|
|
199
|
+
build_mailbox(
|
|
200
|
+
arbitration_options: {
|
|
201
|
+
redis_url: 'rediss://cache.example.com:10000',
|
|
202
|
+
redis_username: redis_username,
|
|
203
|
+
redis_credentials_provider: { provider: 'azure', resource: 'https://redis.azure.com' }
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# Read the raw callable without calling it: RedisClient::Config#password
|
|
209
|
+
# invokes the callable (which would need the provider backend and network).
|
|
210
|
+
let(:raw_password) { raw_client.config.instance_variable_get(:@password) }
|
|
211
|
+
|
|
212
|
+
it 'authenticates with a rotating-token callable password and a middleware descriptor' do
|
|
213
|
+
expect(raw_client.config.username).to eq(redis_username)
|
|
214
|
+
expect(raw_password).to be_a(RedisCloudAuth::TokenCredential)
|
|
215
|
+
expect(raw_client.config.custom[:credentials_provider]).to eq(
|
|
216
|
+
provider: 'azure', resource: 'https://redis.azure.com', username: redis_username
|
|
217
|
+
)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
context 'with an ElastiCache credentials_provider and no redis_username' do
|
|
222
|
+
let(:mailbox) {
|
|
223
|
+
build_mailbox(
|
|
224
|
+
arbitration_options: {
|
|
225
|
+
redis_url: 'rediss://cache.example.com:6379',
|
|
226
|
+
redis_credentials_provider: { provider: 'elasticache', user_id: 'ec-user' }
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
it 'uses the descriptor user_id as the AUTH username' do
|
|
232
|
+
expect(raw_client.config.username).to eq('ec-user')
|
|
233
|
+
end
|
|
234
|
+
end
|
|
195
235
|
end
|
|
196
236
|
end
|
|
@@ -17,7 +17,7 @@ describe MailRoom::Coordinator do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'sets the health check' do
|
|
20
|
-
health_check = MailRoom::HealthCheck.new({ address: '127.0.0.1', port: 8080})
|
|
20
|
+
health_check = MailRoom::HealthCheck.new({ address: '127.0.0.1', port: 8080 })
|
|
21
21
|
coordinator = MailRoom::Coordinator.new([], health_check)
|
|
22
22
|
|
|
23
23
|
expect(coordinator.health_check).to eq(health_check)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'mail_room/delivery/postback'
|
|
3
3
|
require 'tempfile'
|
|
4
|
+
require 'base64'
|
|
4
5
|
require 'webmock/rspec'
|
|
5
6
|
|
|
6
7
|
describe MailRoom::Delivery::Postback do
|
|
@@ -94,7 +95,10 @@ describe MailRoom::Delivery::Postback do
|
|
|
94
95
|
|
|
95
96
|
let(:jwt_secret) do
|
|
96
97
|
file = Tempfile.new('secret')
|
|
97
|
-
|
|
98
|
+
# The secret is read back and Base64-decoded by MailRoom::JWT, so it
|
|
99
|
+
# must be valid Base64 and flushed to disk before it is read.
|
|
100
|
+
file.write(Base64.strict_encode64("test secret"))
|
|
101
|
+
file.flush
|
|
98
102
|
file
|
|
99
103
|
end
|
|
100
104
|
|
|
@@ -138,5 +138,47 @@ describe MailRoom::Delivery::Sidekiq do
|
|
|
138
138
|
expect(raw_client.config.ssl_params).to eq(redis_ssl_params)
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
|
+
|
|
142
|
+
context 'when a credentials_provider is configured' do
|
|
143
|
+
let(:redis_username) { "identity-object-id" }
|
|
144
|
+
let(:mailbox) {
|
|
145
|
+
build_mailbox(
|
|
146
|
+
delivery_method: :sidekiq,
|
|
147
|
+
delivery_options: {
|
|
148
|
+
redis_url: 'rediss://cache.example.com:10000',
|
|
149
|
+
redis_username: redis_username,
|
|
150
|
+
redis_credentials_provider: { provider: 'azure', resource: 'https://redis.azure.com' }
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Read the raw callable without calling it: RedisClient::Config#password
|
|
156
|
+
# invokes the callable (which would need the provider backend and network).
|
|
157
|
+
let(:raw_password) { raw_client.config.instance_variable_get(:@password) }
|
|
158
|
+
|
|
159
|
+
it 'authenticates with a rotating-token callable password and a middleware descriptor' do
|
|
160
|
+
expect(raw_client.config.username).to eq(redis_username)
|
|
161
|
+
expect(raw_password).to be_a(RedisCloudAuth::TokenCredential)
|
|
162
|
+
expect(raw_client.config.custom[:credentials_provider]).to eq(
|
|
163
|
+
provider: 'azure', resource: 'https://redis.azure.com', username: redis_username
|
|
164
|
+
)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
context 'when a redis_username is set without a credentials_provider' do
|
|
169
|
+
let(:mailbox) {
|
|
170
|
+
build_mailbox(
|
|
171
|
+
delivery_method: :sidekiq,
|
|
172
|
+
delivery_options: {
|
|
173
|
+
redis_url: 'redis://localhost:6379',
|
|
174
|
+
redis_username: 'acl-user'
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
it 'applies the username to the connection' do
|
|
180
|
+
expect(raw_client.config.username).to eq('acl-user')
|
|
181
|
+
end
|
|
182
|
+
end
|
|
141
183
|
end
|
|
142
184
|
end
|
|
@@ -106,7 +106,7 @@ describe MailRoom::MicrosoftGraph::Connection do
|
|
|
106
106
|
|
|
107
107
|
shared_examples 'with a single message' do
|
|
108
108
|
let(:message_id) { SecureRandom.hex }
|
|
109
|
-
let(:unread_messages_body) { { value: ['id' => message_id] } }
|
|
109
|
+
let(:unread_messages_body) { { value: [{ 'id' => message_id }] } }
|
|
110
110
|
let(:message_url) { "#{message_base_url}/#{message_id}" }
|
|
111
111
|
let(:message_body) { 'hello world' }
|
|
112
112
|
|
|
@@ -168,13 +168,13 @@ describe MailRoom::MicrosoftGraph::Connection do
|
|
|
168
168
|
context 'with multiple pages of messages' do
|
|
169
169
|
let(:message_ids) { [SecureRandom.hex, SecureRandom.hex] }
|
|
170
170
|
let(:next_page_url) { "#{graph_endpoint}/v1.0/nextPage" }
|
|
171
|
-
let(:unread_messages_body) { { value: ['id' => message_ids.first], '@odata.nextLink' => next_page_url } }
|
|
171
|
+
let(:unread_messages_body) { { value: [{ 'id' => message_ids.first }], '@odata.nextLink' => next_page_url } }
|
|
172
172
|
let(:message_body) { 'hello world' }
|
|
173
173
|
|
|
174
174
|
it 'requests message ID' do
|
|
175
175
|
stub_request(:get, next_page_url).to_return(
|
|
176
176
|
status: 200,
|
|
177
|
-
body: { value: ['id' => message_ids[1]] }.to_json
|
|
177
|
+
body: { value: [{ 'id' => message_ids[1] }] }.to_json
|
|
178
178
|
)
|
|
179
179
|
|
|
180
180
|
stubs = []
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitlab-mail_room
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tony Pitale
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-11-20 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: net-imap
|
|
@@ -15,21 +15,27 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: '0.5'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0.7'
|
|
19
22
|
type: :runtime
|
|
20
23
|
prerelease: false
|
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
25
|
requirements:
|
|
23
26
|
- - ">="
|
|
24
27
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
28
|
+
version: '0.5'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '0.7'
|
|
26
32
|
- !ruby/object:Gem::Dependency
|
|
27
33
|
name: oauth2
|
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
|
29
35
|
requirements:
|
|
30
36
|
- - ">="
|
|
31
37
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
38
|
+
version: 2.0.9
|
|
33
39
|
- - "<"
|
|
34
40
|
- !ruby/object:Gem::Version
|
|
35
41
|
version: '3'
|
|
@@ -39,7 +45,7 @@ dependencies:
|
|
|
39
45
|
requirements:
|
|
40
46
|
- - ">="
|
|
41
47
|
- !ruby/object:Gem::Version
|
|
42
|
-
version:
|
|
48
|
+
version: 2.0.9
|
|
43
49
|
- - "<"
|
|
44
50
|
- !ruby/object:Gem::Version
|
|
45
51
|
version: '3'
|
|
@@ -50,6 +56,9 @@ dependencies:
|
|
|
50
56
|
- - ">="
|
|
51
57
|
- !ruby/object:Gem::Version
|
|
52
58
|
version: '2.0'
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '4'
|
|
53
62
|
type: :runtime
|
|
54
63
|
prerelease: false
|
|
55
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -57,6 +66,23 @@ dependencies:
|
|
|
57
66
|
- - ">="
|
|
58
67
|
- !ruby/object:Gem::Version
|
|
59
68
|
version: '2.0'
|
|
69
|
+
- - "<"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '4'
|
|
72
|
+
- !ruby/object:Gem::Dependency
|
|
73
|
+
name: az-identity
|
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - "~>"
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '0.1'
|
|
79
|
+
type: :runtime
|
|
80
|
+
prerelease: false
|
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - "~>"
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0.1'
|
|
60
86
|
- !ruby/object:Gem::Dependency
|
|
61
87
|
name: redis
|
|
62
88
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -77,6 +103,20 @@ dependencies:
|
|
|
77
103
|
- - "<"
|
|
78
104
|
- !ruby/object:Gem::Version
|
|
79
105
|
version: '6'
|
|
106
|
+
- !ruby/object:Gem::Dependency
|
|
107
|
+
name: redis-cloud-auth
|
|
108
|
+
requirement: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - "~>"
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0.1'
|
|
113
|
+
type: :runtime
|
|
114
|
+
prerelease: false
|
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - "~>"
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0.1'
|
|
80
120
|
- !ruby/object:Gem::Dependency
|
|
81
121
|
name: redis-namespace
|
|
82
122
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,6 +124,9 @@ dependencies:
|
|
|
84
124
|
- - ">="
|
|
85
125
|
- !ruby/object:Gem::Version
|
|
86
126
|
version: 1.8.2
|
|
127
|
+
- - "<"
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '2'
|
|
87
130
|
type: :runtime
|
|
88
131
|
prerelease: false
|
|
89
132
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -91,6 +134,9 @@ dependencies:
|
|
|
91
134
|
- - ">="
|
|
92
135
|
- !ruby/object:Gem::Version
|
|
93
136
|
version: 1.8.2
|
|
137
|
+
- - "<"
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '2'
|
|
94
140
|
- !ruby/object:Gem::Dependency
|
|
95
141
|
name: rake
|
|
96
142
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -312,6 +358,8 @@ files:
|
|
|
312
358
|
- lib/mail_room/message.rb
|
|
313
359
|
- lib/mail_room/microsoft_graph.rb
|
|
314
360
|
- lib/mail_room/microsoft_graph/connection.rb
|
|
361
|
+
- lib/mail_room/redis_client_builder.rb
|
|
362
|
+
- lib/mail_room/redis_credentials_provider.rb
|
|
315
363
|
- lib/mail_room/version.rb
|
|
316
364
|
- logfile.log
|
|
317
365
|
- mail_room.gemspec
|
|
@@ -347,7 +395,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
347
395
|
requirements:
|
|
348
396
|
- - ">="
|
|
349
397
|
- !ruby/object:Gem::Version
|
|
350
|
-
version: '
|
|
398
|
+
version: '3.1'
|
|
351
399
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
352
400
|
requirements:
|
|
353
401
|
- - ">="
|