Skip to content

Commit

Permalink
Merge pull request #422 from bcgov/BCPSDEMS-1696-test-hostname-changes
Browse files Browse the repository at this point in the history
Kafka config changes
  • Loading branch information
leewrigh authored Jan 26, 2024
2 parents 1162a64 + 0d02114 commit f89043f
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions backend/NotificationService/Kafka/ConsumerSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerTokenEndpointUrl = config.KafkaCluster.SaslOauthbearerTokenEndpointUrl,
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SslCertificateLocation = config.KafkaCluster.SslCertificateLocation,
SslKeyLocation = config.KafkaCluster.SslKeyLocation
Expand All @@ -38,7 +38,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerTokenEndpointUrl = config.KafkaCluster.SaslOauthbearerTokenEndpointUrl,
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class KafkaClusterConfiguration
public string SslKeyLocation { get; set; } = string.Empty;
public string Scope { get; set; } = "openid";
public string ConsumerGroupId { get; set; } = "jum-notification-consumer-group";

public string HostnameVerification { get; set; } = "Https";

}

Expand Down
4 changes: 2 additions & 2 deletions backend/edt.casemanagement/ConsumerSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SocketKeepaliveEnable = true,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
ConnectionsMaxIdleMs = 600000,
SslCertificateLocation = config.KafkaCluster.SslCertificateLocation,
Expand All @@ -49,7 +49,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerScope = config.KafkaCluster.Scope,
ClientId = Dns.GetHostName(),
RequestTimeoutMs = 60000,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down
2 changes: 2 additions & 0 deletions backend/edt.casemanagement/EdtServiceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public class KafkaClusterConfiguration : BaseKafkafiguration
public string AckTopicName { get; set; } = string.Empty;
public string ConsumerGroupId { get; set; } = "caseaccess-consumer-group";
public string RetryConsumerGroupId { get; set; } = "caseaccess-retry-consumer-group";
public string HostnameVerification { get; set; } = "Https";

}


Expand Down
4 changes: 2 additions & 2 deletions backend/edt.casemanagement/Kafka/ConsumerSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SocketKeepaliveEnable = true,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
ConnectionsMaxIdleMs = 600000,
SslCertificateLocation = config.KafkaCluster.SslCertificateLocation,
Expand All @@ -46,7 +46,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerScope = config.KafkaCluster.Scope,
ClientId = Dns.GetHostName(),
RequestTimeoutMs = 60000,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public class KafkaClusterConfiguration
public string ConsumerGroupId { get; set; } = "disclosure-consumer-group";
public string RetryConsumerGroupId { get; set; } = "disclosure-retry-consumer-group";
public string CoreFolioCreationNotificationTopic { get; set; } = string.Empty;
public string HostnameVerification { get; set; } = "Https";


}
Expand Down
4 changes: 2 additions & 2 deletions backend/edt.disclosure/Kafka/ConsumerSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SocketKeepaliveEnable = true,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
ConnectionsMaxIdleMs = 600000,
SslCertificateLocation = config.KafkaCluster.SslCertificateLocation,
Expand All @@ -52,7 +52,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerScope = config.KafkaCluster.Scope,
ClientId = Dns.GetHostName(),
RequestTimeoutMs = 60000,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down
11 changes: 6 additions & 5 deletions backend/jumwebapi/Infrastructure/Auth/AuthenticationSetup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.IdentityModel.Tokens.Jwt;
using Confluent.Kafka;
using jumwebapi.Extensions;
using jumwebapi.Kafka.Producer;
Expand All @@ -6,7 +7,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System.IdentityModel.Tokens.Jwt;

namespace jumwebapi.Infrastructure.Auth
{
Expand All @@ -26,7 +26,7 @@ public static IServiceCollection AddKeycloakAuth(this IServiceCollection service
SaslOauthbearerTokenEndpointUrl = config.KafkaCluster.SaslOauthbearerTokenEndpointUrl,
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down Expand Up @@ -62,7 +62,8 @@ public static IServiceCollection AddKeycloakAuth(this IServiceCollection service
};
options.Events = new JwtBearerEvents
{
OnTokenValidated = context => {
OnTokenValidated = context =>
{
return Task.CompletedTask;
},
OnAuthenticationFailed = context =>
Expand All @@ -72,7 +73,7 @@ public static IServiceCollection AddKeycloakAuth(this IServiceCollection service
context.NoResult();
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
context.Response.ContentType = "application/json";
string response =
var response =
JsonConvert.SerializeObject("The access token provided is not valid.");
if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
{
Expand All @@ -82,7 +83,7 @@ public static IServiceCollection AddKeycloakAuth(this IServiceCollection service
}
await context.Response.WriteAsync(response);
});
//context.HandleResponse();
//context.Response.WriteAsync(response).Wait();
return Task.CompletedTask;
Expand Down
2 changes: 2 additions & 0 deletions backend/jumwebapi/jumwebapiConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class KafkaClusterConfiguration
public string SslCertificateLocation { get; set; } = string.Empty;
public string SslKeyLocation { get; set; } = string.Empty;
public string Scope { get; set; } = "openid";
public string HostnameVerification { get; set; } = "Https";

}
public class JustinClientConfiguration
{
Expand Down
1 change: 1 addition & 0 deletions backend/service.edt/EdtServiceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class KafkaClusterConfiguration
public string ConsumerGroupId { get; set; } = "accessrequest-consumer-group";
public string RetryConsumerGroupId { get; set; } = "accessrequest-retry-consumer-group";
public string CoreFolioCreationNotificationTopic { get; set; } = string.Empty;
public string HostnameVerification { get; set; } = "Https";

}

Expand Down
4 changes: 2 additions & 2 deletions backend/service.edt/Kafka/ConsumerSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
ConnectionsMaxIdleMs = 2147483647,
TopicMetadataRefreshIntervalMs = 10000,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SslCertificateLocation = config.KafkaCluster.SslCertificateLocation,
SslKeyLocation = config.KafkaCluster.SslKeyLocation
Expand All @@ -54,7 +54,7 @@ public static IServiceCollection AddKafkaConsumer(this IServiceCollection servic
SaslOauthbearerScope = config.KafkaCluster.Scope,
ClientId = Dns.GetHostName(),
RequestTimeoutMs = 60000,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down
5 changes: 2 additions & 3 deletions backend/webapi/Features/Admin/Kafka/Topics/TopicQuery.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace Pidp.Features.Admin.Kafka.Topics;

using AutoMapper;
using Pidp.Features.Admin.Kafka.Models;
using Confluent.Kafka;
using Confluent.Kafka.Admin;
using Pidp.Features.Admin.Kafka.Models;

public record TopicQuery(string? topicName) : IQuery<List<TopicModel>>;

Expand Down Expand Up @@ -35,7 +34,7 @@ public async Task<List<TopicModel>> HandleAsync(TopicQuery query)
SslCertificateLocation = this.configuration.KafkaCluster.SslCertificateLocation,
SslCaLocation = this.configuration.KafkaCluster.SslCaLocation,
SaslOauthbearerScope = this.configuration.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (this.configuration.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslKeyLocation = this.configuration.KafkaCluster.SslKeyLocation,
SaslMechanism = SaslMechanism.OAuthBearer,
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
Expand Down
4 changes: 2 additions & 2 deletions backend/webapi/Infrastructure/HttpClients/HttpClientSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static IServiceCollection AddHttpClients(this IServiceCollection services
SaslOauthbearerTokenEndpointUrl = config.KafkaCluster.SaslOauthbearerTokenEndpointUrl,
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SaslOauthbearerScope = config.KafkaCluster.Scope,
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SslCertificateLocation = config.KafkaCluster.SslCertificateLocation,
SslKeyLocation = config.KafkaCluster.SslKeyLocation,
Expand All @@ -93,7 +93,7 @@ public static IServiceCollection AddHttpClients(this IServiceCollection services
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SaslOauthbearerScope = config.KafkaCluster.Scope,
ClientId = Dns.GetHostName(),
SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
SslEndpointIdentificationAlgorithm = (config.KafkaCluster.HostnameVerification == SslEndpointIdentificationAlgorithm.Https.ToString()) ? SslEndpointIdentificationAlgorithm.Https : SslEndpointIdentificationAlgorithm.None,
SslCaLocation = config.KafkaCluster.SslCaLocation,
SaslOauthbearerClientId = config.KafkaCluster.SaslOauthbearerProducerClientId,
SaslOauthbearerClientSecret = config.KafkaCluster.SaslOauthbearerProducerClientSecret,
Expand Down
1 change: 1 addition & 0 deletions backend/webapi/PidpConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class KafkaClusterConfiguration
public string ConsumerGroupId { get; set; } = "dems-notification-ack";
public string KafkaAdminClientId { get; set; } = string.Empty;
public string KafkaAdminClientSecret { get; set; } = string.Empty;
public string HostnameVerification { get; set; } = "Https";

}
public class JumClientConfiguration
Expand Down

0 comments on commit f89043f

Please sign in to comment.