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

Update OpenIdDictCore and NSwag #217

Merged
merged 4 commits into from
Jan 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.112">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.7.300.7" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.7.300.34" />
<PackageReference Include="Confluent.Kafka" Version="2.3.0" />
<PackageReference Include="FirebaseAdmin" Version="2.4.0" />
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="Fluid.Core" Version="2.5.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.25" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.57" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.27" />
<PackageReference Include="Mailjet.Api" Version="3.0.0" />
<PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.112">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.22.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.23.1" />
<PackageReference Include="NodaTime" Version="3.1.10" />
<PackageReference Include="OpenNotifications" Version="0.3.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
<PackageReference Include="Twilio" Version="6.15.1" />
<PackageReference Include="Twilio" Version="6.15.2" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions backend/src/Notifo.Domain/Notifo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="Fluid.Core" Version="2.5.0" />
<PackageReference Include="Jint" Version="3.0.0-beta-2037" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.25" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.112">
<PackageReference Include="libphonenumber-csharp" Version="8.13.27" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="Mjml.Net" Version="3.3.0" />
<PackageReference Include="MongoDB.Driver" Version="2.22.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="Mjml.Net" Version="3.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.23.1" />
<PackageReference Include="NodaTime" Version="3.1.10" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo.Identity/IdentityServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void AddMyMongoDbIdentity(this IServiceCollection services)
services.AddOpenIddict()
.AddCore(builder =>
{
builder.UseMongoDb<string>();
builder.UseMongoDb();

builder.SetDefaultScopeEntity<ImmutableScope>();

Expand Down
14 changes: 12 additions & 2 deletions backend/src/Notifo.Identity/InMemory/ImmutableApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Immutable;
using System.Globalization;
using System.Text.Json;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Abstractions;

namespace Notifo.Identity.InMemory;
Expand All @@ -20,11 +21,15 @@ public sealed class ImmutableApplication

public string? ClientSecret { get; }

public string? ClientType { get; }

public string? ConsentType { get; }

public string? DisplayName { get; }

public string? Type { get; }
public string? ApplicationType { get; }

public JsonWebKeySet? JsonWebKeySet { get; }

public ImmutableDictionary<CultureInfo, string> DisplayNames { get; }

Expand All @@ -38,19 +43,24 @@ public sealed class ImmutableApplication

public ImmutableDictionary<string, JsonElement> Properties { get; }

public ImmutableDictionary<string, string> Settings { get; }

public ImmutableApplication(string id, OpenIddictApplicationDescriptor descriptor)
{
Id = id;
ApplicationType = descriptor.ApplicationType;
ClientId = descriptor.ClientId;
ClientSecret = descriptor.ClientSecret;
ClientType = descriptor.ClientType;
ConsentType = descriptor.ConsentType;
DisplayName = descriptor.DisplayName;
DisplayNames = descriptor.DisplayNames.ToImmutableDictionary();
JsonWebKeySet = descriptor.JsonWebKeySet;
Permissions = descriptor.Permissions.ToImmutableArray();
PostLogoutRedirectUris = descriptor.PostLogoutRedirectUris.Select(x => x.ToString()).ToImmutableArray();
Properties = descriptor.Properties.ToImmutableDictionary();
RedirectUris = descriptor.RedirectUris.Select(x => x.ToString()).ToImmutableArray();
Requirements = descriptor.Requirements.ToImmutableArray();
Type = descriptor.Type;
Settings = descriptor.Settings.ToImmutableDictionary();
}
}
39 changes: 38 additions & 1 deletion backend/src/Notifo.Identity/InMemory/InMemoryApplicationStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text.Json;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Abstractions;

namespace Notifo.Identity.InMemory;
Expand Down Expand Up @@ -128,7 +129,7 @@ public virtual async IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<I
public virtual ValueTask<string?> GetClientTypeAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.Type.AsValueTask();
return application.ClientType.AsValueTask();
}

public virtual ValueTask<string?> GetConsentTypeAsync(ImmutableApplication application,
Expand Down Expand Up @@ -179,6 +180,24 @@ public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetProperties
return application.Properties.AsValueTask();
}

public ValueTask<string?> GetApplicationTypeAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.ApplicationType.AsValueTask();
}

public ValueTask<JsonWebKeySet?> GetJsonWebKeySetAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.JsonWebKeySet.AsValueTask();
}

public ValueTask<ImmutableDictionary<string, string>> GetSettingsAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.Settings.AsValueTask();
}

public virtual ValueTask CreateAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -268,4 +287,22 @@ public virtual ValueTask SetRequirementsAsync(ImmutableApplication application,
{
throw new NotSupportedException();
}

public ValueTask SetApplicationTypeAsync(ImmutableApplication application, string? type,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}

public ValueTask SetJsonWebKeySetAsync(ImmutableApplication application, JsonWebKeySet? set,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}

public ValueTask SetSettingsAsync(ImmutableApplication application, ImmutableDictionary<string, string> settings,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
}
2 changes: 1 addition & 1 deletion backend/src/Notifo.Identity/InMemoryConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Applications(IUrlGenerator urlGenerator, IOptions<NotifoIdentityOptions>
DisplayName = "React Frontend Application",
ClientId = Constants.FrontendClient,
ClientSecret = null,
Type = ClientTypes.Public,
ClientType = ClientTypes.Public,
PostLogoutRedirectUris =
{
new Uri(urlGenerator.BuildUrl("authentication/logout-callback", false))
Expand Down
10 changes: 5 additions & 5 deletions backend/src/Notifo.Identity/Notifo.Identity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="8.0.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.112">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="4.10.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="4.0.1-dev" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.0.1" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="5.1.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions backend/src/Notifo.Identity/TokenStoreInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ private async Task SetupIndexAsync(
{
var database = await scope.ServiceProvider.GetRequiredService<IOpenIddictMongoDbContext>().GetDatabaseAsync(ct);

var collection = database.GetCollection<OpenIddictMongoDbToken<string>>(options.TokensCollectionName);
var collection = database.GetCollection<OpenIddictMongoDbToken>(options.TokensCollectionName);

await collection.Indexes.CreateOneAsync(
new CreateIndexModel<OpenIddictMongoDbToken<string>>(
Builders<OpenIddictMongoDbToken<string>>.IndexKeys
new CreateIndexModel<OpenIddictMongoDbToken>(
Builders<OpenIddictMongoDbToken>.IndexKeys
.Ascending(x => x.ReferenceId)),
cancellationToken: ct);
}
Expand Down
40 changes: 20 additions & 20 deletions backend/src/Notifo.Infrastructure/Notifo.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.8.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.112">
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -20,29 +20,29 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.22.0" />
<PackageReference Include="MongoDB.Driver" Version="2.23.1" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="NodaTime" Version="3.1.10" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" />
<PackageReference Include="OpenTelemetry" Version="1.6.0" />
<PackageReference Include="OpenTelemetry" Version="1.7.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="6.2.0" />
<PackageReference Include="Squidex.Assets.S3" Version="6.2.0" />
<PackageReference Include="Squidex.Caching" Version="6.2.0" />
<PackageReference Include="Squidex.Hosting" Version="6.2.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.2.0" />
<PackageReference Include="Squidex.Log" Version="6.2.0" />
<PackageReference Include="Squidex.Messaging" Version="6.2.0" />
<PackageReference Include="Squidex.Text" Version="6.2.0" />
<PackageReference Include="Squidex.Assets" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.Azure" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.FTP" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.Mongo" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.S3" Version="6.3.5" />
<PackageReference Include="Squidex.Caching" Version="6.3.5" />
<PackageReference Include="Squidex.Hosting" Version="6.3.5" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.3.5" />
<PackageReference Include="Squidex.Log" Version="6.3.5" />
<PackageReference Include="Squidex.Messaging" Version="6.3.5" />
<PackageReference Include="Squidex.Text" Version="6.3.5" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="8.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo/Areas/Account/Pages/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}

<environment include="Development">
<script type="module" src="@Url.Content("~/src/app/theme.tsx")"></script>
<script type="module" src="https://localhost:3002/src/app/theme.tsx")"></script>
</environment>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo/Areas/Account/Pages/_LayoutLogin.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var galleryEnabled = false;
}

<environment include="Development">
<script type="module" src="@Url.Content("~/src/app/theme.tsx")"></script>
<script type="module" src="https://localhost:3002/src/app/theme.tsx")"></script>
</environment>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo/Areas/Api/OpenApi/CommonProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Process(DocumentProcessorContext context)
context.Document.Info.Title = "Notifo API";
context.Document.BasePath = "/api";
context.Document.Info.Version = "1.0.0";
context.Document.Info.ExtensionData = new Dictionary<string, object>
context.Document.Info.ExtensionData = new Dictionary<string, object?>
{
["x-logo"] = new
{
Expand Down
14 changes: 8 additions & 6 deletions backend/src/Notifo/Areas/Api/OpenApi/OpenApiServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ public static void AddMyOpenApi(this IServiceCollection services)

services.AddOpenApiDocument(settings =>
{
settings.AllowReferencesWithProperties = true;
settings.DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
settings.DefaultDictionaryValueReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
settings.SchemaProcessors.Add(new RequiredSchemaProcessor());
var schemaSettings = settings.SchemaSettings;

settings.TypeMappers = new List<ITypeMapper>
schemaSettings.AllowReferencesWithProperties = true;
schemaSettings.DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
schemaSettings.DefaultDictionaryValueReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
schemaSettings.SchemaProcessors.Add(new RequiredSchemaProcessor());

schemaSettings.TypeMappers = new List<ITypeMapper>
{
CreateStringMap<Instant>(JsonFormatStrings.DateTime),
CreateStringMap<TopicId>()
};

settings.ReflectionService = new ReflectionServices();
schemaSettings.ReflectionService = new ReflectionServices();
});
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo/Areas/Api/OpenApi/ReflectionServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Notifo.Areas.Api.OpenApi;

public sealed class ReflectionServices : DefaultReflectionService
public sealed class ReflectionServices : SystemTextJsonReflectionService
{
protected override bool IsArrayType(ContextualType contextualType)
{
Expand Down
Loading