Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/apis/account-and-transaction/openapi-aisp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Account and Transaction API",
"description": "Account and Transaction API for Open Banking Connector Web App",
"version": "20.0.0"
"version": "21.0.0"
},
"paths": {
"/aisp/account-access-consent-auth-contexts": {
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/auth-contexts/openapi-auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Auth Contexts API",
"description": "Auth Contexts API for Open Banking Connector Web App",
"version": "20.0.0"
"version": "21.0.0"
},
"paths": {
"/auth/redirect-delegate": {
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/management/openapi-manage.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Management API",
"description": "Management API for Open Banking Connector Web App",
"version": "20.0.0"
"version": "21.0.0"
},
"paths": {
"/manage/bank-registrations": {
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/payment-initiation/openapi-pisp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Payment Initiation API",
"description": "Payment Initiation API for Open Banking Connector Web App",
"version": "20.0.0"
"version": "21.0.0"
},
"paths": {
"/pisp/domestic-payment-consent-auth-contexts": {
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/variable-recurring-payments/openapi-vrp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Variable Recurring Payments API",
"description": "Variable Recurring Payments API for Open Banking Connector Web App",
"version": "20.0.0"
"version": "21.0.0"
},
"paths": {
"/vrp/domestic-vrp-consent-auth-contexts": {
Expand Down
19 changes: 9 additions & 10 deletions docs/configuration/database-settings.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#nullable enable

using System.Runtime.Serialization;
using FinnovationLabs.OpenBanking.Library.BankApiModels.UkObRw.V3p1p11.NSwagVrp.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
Expand All @@ -23,16 +22,17 @@ public enum DomesticVrpRefundConverterOptions
ContainsNestedAccountProperty = 1
}

public class DomesticVrpRefundConverter : JsonConverterWithOptions<OBCashAccountDebtorWithName?,
public class DomesticVrpRefundConverter<TRefund> : JsonConverterWithOptions<TRefund?,
DomesticVrpRefundConverterOptions>

where TRefund : class
{
public DomesticVrpRefundConverter() : base(null) { } // required for case where no label used

public DomesticVrpRefundConverter(JsonConverterLabel jsonConverterLabel) :
base(jsonConverterLabel) { }
base(jsonConverterLabel)
{ }

public override void WriteJson(JsonWriter writer, OBCashAccountDebtorWithName? value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, TRefund? value, JsonSerializer serializer)
{
if (value is null)
{
Expand All @@ -42,24 +42,16 @@ public override void WriteJson(JsonWriter writer, OBCashAccountDebtorWithName? v
{
JToken jt = JToken.FromObject(value);
jt.WriteTo(writer);
}
}
}

public override OBCashAccountDebtorWithName? ReadJson(
public override TRefund? ReadJson(
JsonReader reader,
Type objectType,
OBCashAccountDebtorWithName? existingValue,
TRefund? existingValue,
bool hasExistingValue,
JsonSerializer serializer)
{

// Validate objectType
if (objectType != typeof(OBCashAccountDebtorWithName))
{
throw new NotSupportedException($"The type {objectType} is not supported.");
}

// Handle JSON null value
if (reader.TokenType is JsonToken.Null)
{
return null;
Expand All @@ -68,7 +60,7 @@ public override void WriteJson(JsonWriter writer, OBCashAccountDebtorWithName? v
// Perform de-serialisation
var options = GetOptions(serializer);
var token = JToken.Load(reader);
OBCashAccountDebtorWithName? refund;
TRefund? refund;
if (options is DomesticVrpRefundConverterOptions.ContainsNestedAccountProperty)
{
if (token.Type is not JTokenType.Object)
Expand All @@ -80,18 +72,18 @@ public override void WriteJson(JsonWriter writer, OBCashAccountDebtorWithName? v
{
throw new Exception("Refund does not contain nested property Account.");
}
refund = accountToken.ToObject<OBCashAccountDebtorWithName>();
refund = accountToken.ToObject<TRefund>(serializer);
}
else
{
refund = token.ToObject<OBCashAccountDebtorWithName>();
refund = token.ToObject<TRefund>(serializer);
}

if (refund is null)
{
throw new Exception("Could not deserialise Refund account.");
}

return refund;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to Finnovation Labs Limited under one or more agreements.
// Finnovation Labs Limited licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace FinnovationLabs.OpenBanking.Library.BankApiModels.Json;

/// <summary>
/// Custom converter for deserialising a field that may be returned either as a single value or as a JSON array containing a single value.
/// </summary>
public class SingleOrArrayConverter<T> : JsonConverter
{
public override bool CanConvert(Type objectType) => true;
Comment thread
DanJakeNeal marked this conversation as resolved.

public override object? ReadJson(
JsonReader reader,
Type objectType,
object? existingValue,
JsonSerializer serializer)
{
JToken token = JToken.Load(reader);
if (token.Type == JTokenType.Array)
{
var array = (JArray) token;
if (array.Count != 1)
{
throw new JsonSerializationException(
$"We can accept JSON array with exactly one element when deserialising {typeof(T).Name}, but received array with {array.Count} elements.");
}
return array[0].ToObject<T>(serializer);
}

return token.ToObject<T>(serializer);
}

public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
serializer.Serialize(writer, value);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>annotations</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>FinnovationLabs.OpenBanking.Library.BankApiModels</AssemblyName>
Expand All @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="16.1.1"/>
<PackageReference Include="AutoMapper" Version="16.2.0"/>
<PackageReference Include="FluentValidation" Version="12.1.1"/>
<PackageReference Include="jose-jwt" Version="5.3.0"/>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.24"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public OBRegistrationProperties1(
/// 'tls_client_auth'
/// </summary>
[JsonProperty(PropertyName = "token_endpoint_auth_method")]
[JsonConverter(typeof(SingleOrArrayConverter<OBRegistrationProperties1tokenEndpointAuthMethodEnum>))]
public OBRegistrationProperties1tokenEndpointAuthMethodEnum TokenEndpointAuthMethod { get; set; }

/// <summary>
Expand Down Expand Up @@ -191,6 +192,7 @@ public OBRegistrationProperties1(
/// Gets or sets possible values include: 'RS256', 'PS256', 'ES256'
/// </summary>
[JsonProperty(PropertyName = "request_object_signing_alg")]
[JsonConverter(typeof(SingleOrArrayConverter<SupportedAlgorithmsEnum>))]
public SupportedAlgorithmsEnum RequestObjectSigningAlg { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public OBRegistrationProperties1(
/// 'tls_client_auth'
/// </summary>
[JsonProperty(PropertyName = "token_endpoint_auth_method")]
[JsonConverter(typeof(SingleOrArrayConverter<OBRegistrationProperties1tokenEndpointAuthMethodEnum>))]
public OBRegistrationProperties1tokenEndpointAuthMethodEnum TokenEndpointAuthMethod { get; set; }

/// <summary>
Expand Down Expand Up @@ -196,6 +197,7 @@ public OBRegistrationProperties1(
/// Gets or sets possible values include: 'RS256', 'PS256', 'ES256'
/// </summary>
[JsonProperty(PropertyName = "request_object_signing_alg")]
[JsonConverter(typeof(SingleOrArrayConverter<SupportedAlgorithmsEnum>))]
public SupportedAlgorithmsEnum RequestObjectSigningAlg { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public OBRegistrationProperties1()
/// 'tls_client_auth'
/// </summary>
[JsonProperty(PropertyName = "token_endpoint_auth_method")]
[JsonConverter(typeof(SingleOrArrayConverter<OBRegistrationProperties1tokenEndpointAuthMethodEnum>))]
public OBRegistrationProperties1tokenEndpointAuthMethodEnum TokenEndpointAuthMethod { get; set; }

/// <summary>
Expand Down Expand Up @@ -203,6 +204,7 @@ public OBRegistrationProperties1()
/// Gets or sets possible values include: 'RS256', 'PS256', 'ES256'
/// </summary>
[JsonProperty(PropertyName = "request_object_signing_alg")]
[JsonConverter(typeof(SingleOrArrayConverter<SupportedAlgorithmsEnum>))]
public SupportedAlgorithmsEnum RequestObjectSigningAlg { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ public partial record Data4
/// <br/>
/// </summary>
[Newtonsoft.Json.JsonConverter(
typeof(DomesticVrpRefundConverter),
typeof(DomesticVrpRefundConverter<OBCashAccountDebtorWithName>),
JsonConverterLabel.DomesticVrpRefund)]
[Newtonsoft.Json.JsonProperty("Refund", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public OBCashAccountDebtorWithName? Refund { get; set; } = default!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3133,6 +3133,9 @@ public partial record Data4
/// Only included in the response if `Data.ReadRefundAccount` is set to `Yes` in the consent.
/// <br/>
/// </summary>
[Newtonsoft.Json.JsonConverter(
typeof(DomesticVrpRefundConverter<OBCashAccountDebtorWithName>),
JsonConverterLabel.DomesticVrpRefund)]
[Newtonsoft.Json.JsonProperty("Refund", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public OBCashAccountDebtorWithName? Refund { get; set; } = default!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ public static IServiceCollection AddGenericHostServices(
// Configure DB
switch (databaseSettings.Provider)
{
case DbProvider.Sqlite:
services
// See e.g. https://jasonwatmore.com/post/2020/01/03/aspnet-core-ef-core-migrations-for-multiple-databases-sqlite-and-sql-server
.AddDbContext<BaseDbContext, SqliteDbContext>(
(sp, optionsBuilder) =>
{
var connectionStringService = sp.GetRequiredService<IDbConnectionString>();
optionsBuilder.UseSqlite(connectionStringService.GetConnectionString());
});
break;
case DbProvider.PostgreSql:
services.AddDbContext<BaseDbContext, PostgreSqlDbContext>(
(sp, optionsBuilder) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public StartupTasksHostedService(
{
_bankProfileService = bankProfileService ?? throw new ArgumentNullException(nameof(bankProfileService));
_configurationRoot =
(IConfigurationRoot) (configuration ?? throw new ArgumentNullException(nameof(configuration)));
(IConfigurationRoot)(configuration ?? throw new ArgumentNullException(nameof(configuration)));
_databaseSettingsProvider = databaseSettingsProvider ??
throw new ArgumentNullException(nameof(databaseSettingsProvider));
_settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService));
Expand Down Expand Up @@ -101,25 +101,6 @@ public async Task StartAsync(CancellationToken cancellationToken)
// Database startup tasks
switch (databaseSettings.Provider)
{
case DbProvider.Sqlite:
var sqliteDbContext = scope.ServiceProvider.GetRequiredService<SqliteDbContext>();
bool sqliteDbExists =
sqliteDbContext.Database.GetService<IRelationalDatabaseCreator>().Exists();
if (!sqliteDbExists)
{
if (databaseSettings.EnsureDatabaseCreated)
{
// Create database
sqliteDbContext.Database.EnsureCreated();
}
else
{
throw new ApplicationException(
"No database found. Note: set \"Database:EnsureDatabaseCreated\" to \"true\" to create database at application start-up.");
}
}

break;
case DbProvider.PostgreSql:
var postgreSqlDbContext = scope.ServiceProvider.GetRequiredService<PostgreSqlDbContext>();
bool postgreSqlExists =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>FinnovationLabs.OpenBanking.Library.Connector.GenericHost</AssemblyName>
Expand All @@ -23,20 +23,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Cloud.SecretManager.V1" Version="2.7.0"/>
<PackageReference Include="AWSSDK.SimpleSystemsManagement" Version="4.0.8.5"/>
<PackageReference Include="AWSSDK.SSO" Version="4.0.3.5"/>
<PackageReference Include="AWSSDK.SSOOIDC" Version="4.0.4.7"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.17"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.17"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.17"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.17"/>
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.17"/>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.16.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.16.0"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0"/>
<PackageReference Include="Google.Cloud.SecretManager.V1" Version="2.8.0"/>
<PackageReference Include="AWSSDK.SimpleSystemsManagement" Version="4.0.103.1"/>
<PackageReference Include="AWSSDK.SSO" Version="4.0.100.6"/>
<PackageReference Include="AWSSDK.SSOOIDC" Version="4.0.100.6"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.10"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.10"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.10"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.10"/>
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="10.0.10"/>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.17.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.17.0"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.17.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.8"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.15.1"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.17.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>FinnovationLabs.OpenBanking.Library.Connector.Web</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bank is not HsbcBank.MAndS
DomesticPayment =
new DomesticPaymentCustomBehaviour { PreferMisspeltContractPresentIndicator = true },
DomesticVrpConsentAuthCodeGrantPost =
new AuthCodeGrantPostCustomBehaviour { ExpectedResponseRefreshTokenMayBeAbsent = true },
new AuthCodeGrantPostCustomBehaviour(),
DomesticVrpConsent =
new DomesticVrpConsentCustomBehaviour { PreferMisspeltContractPresentIndicator = true },
DomesticVrp = new DomesticVrpCustomBehaviour
Expand Down
Loading