Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SSL for connection to RabbitMQ by default and make RabbitMQ port configurable #1012

Merged
merged 7 commits into from
Jan 9, 2025
Merged
1 change: 1 addition & 0 deletions .ci/appsettings.override.postgres.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"EventBus": {
"Vendor": "RabbitMQ",
"ConnectionInfo": "rabbitmq",
"RabbitMQEnableSsl": false,
"RabbitMQUsername": "guest",
"RabbitMQPassword": "guest"
},
Expand Down
1 change: 1 addition & 0 deletions .ci/appsettings.override.postgres.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"EventBus": {
"Vendor": "RabbitMQ",
"ConnectionInfo": "localhost",
"RabbitMQEnableSsl": false,
"RabbitMQUsername": "guest",
"RabbitMQPassword": "guest"
},
Expand Down
1 change: 1 addition & 0 deletions .ci/appsettings.override.sqlserver.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"EventBus": {
"Vendor": "RabbitMQ",
"ConnectionInfo": "rabbitmq",
"RabbitMQEnableSsl": false,
"RabbitMQUsername": "guest",
"RabbitMQPassword": "guest"
},
Expand Down
1 change: 1 addition & 0 deletions .ci/appsettings.override.sqlserver.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"EventBus": {
"Vendor": "RabbitMQ",
"ConnectionInfo": "localhost",
"RabbitMQEnableSsl": false,
"RabbitMQUsername": "guest",
"RabbitMQPassword": "guest"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@ public static void AddRabbitMq(this IServiceCollection services, Action<RabbitMq

var factory = new ConnectionFactory
{
HostName = options.HostName
HostName = options.HostName,
Port = options.Port,
};

if (!string.IsNullOrEmpty(options.Username)) factory.UserName = options.Username;
if (options.EnableSsl)
{
factory.Ssl = new SslOption
{
Enabled = true,
ServerName = options.HostName
};
}

if (!string.IsNullOrEmpty(options.Username))
factory.UserName = options.Username;

if (!string.IsNullOrEmpty(options.Password)) factory.Password = options.Password;
if (!string.IsNullOrEmpty(options.Password))
factory.Password = options.Password;

return new DefaultRabbitMqPersistentConnection(factory, logger, options.ConnectionRetryCount);
});
Expand All @@ -48,9 +60,11 @@ public static void AddRabbitMq(this IServiceCollection services, Action<RabbitMq

public class RabbitMqOptions : BasicBusOptions
{
public bool EnableSsl { get; set; } = true;
public string ExchangeName { get; set; } = null!;
public string QueueName { get; set; } = null!;
public string HostName { get; set; } = null!;
public int Port { get; set; } = 5672;
public string Username { get; set; } = null!;
public string Password { get; set; } = null!;
public int ConnectionRetryCount { get; set; } = 5;
Expand Down
2 changes: 2 additions & 0 deletions Infrastructure/EventBus/EventBusConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class EventBusConfiguration
[Required]
public string SubscriptionClientName { get; set; } = null!;

public bool RabbitMqEnableSsl { get; set; } = true;
public int RabbitMqPort { get; set; } = 5672;
tnotheis marked this conversation as resolved.
Show resolved Hide resolved
public string RabbitMqUsername { get; set; } = null!;
public string RabbitMqPassword { get; set; } = null!;
public string RabbitMqExchangeName { get; set; } = "enmeshed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public static void AddEventBus(this IServiceCollection services, EventBusConfigu
services.AddRabbitMq(options =>
{
LoadBasicBusOptions(configuration, options);
options.EnableSsl = configuration.RabbitMqEnableSsl;
options.HostName = configuration.ConnectionInfo;
options.Port = configuration.RabbitMqPort;
options.Username = configuration.RabbitMqUsername;
options.Password = configuration.RabbitMqPassword;
options.ExchangeName = configuration.RabbitMqExchangeName;
Expand Down
4 changes: 3 additions & 1 deletion appsettings.override.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"RunMigrations": true,
"Authentication": {
"JwtSigningCertificate": "MIIJ7w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jBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA",
Expand All @@ -15,6 +15,8 @@
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
"ConnectionInfo": "localhost",

"RabbitMQEnableSsl": false,

"RabbitMQUsername": "guest", // only available for RabbitMQ
"RabbitMQPassword": "guest", // only available for RabbitMQ
"ConnectionRetryCount": 5, // only available for RabbitMQ
Expand Down
1 change: 1 addition & 0 deletions docker-compose/adminui.appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
"ConnectionInfo": "rabbitmq",

"RabbitMQEnableSsl": false,
"RabbitMQUsername": "guest", // only available for RabbitMQ
"RabbitMQPassword": "guest", // only available for RabbitMQ
"ConnectionRetryCount": 5, // only available for RabbitMQ
Expand Down
1 change: 1 addition & 0 deletions docker-compose/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
"ConnectionInfo": "rabbitmq",

"RabbitMQEnableSsl": false,
"RabbitMQUsername": "guest", // only available for RabbitMQ
"RabbitMQPassword": "guest", // only available for RabbitMQ
"ConnectionRetryCount": 5, // only available for RabbitMQ
Expand Down
Loading