Skip to content

Commit

Permalink
feat(app): strict extensions for web modules
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Dec 6, 2023
1 parent 6e97444 commit 3865683
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
37 changes: 25 additions & 12 deletions src/Sitko.Core.Auth.IdentityServer/ApplicationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using JetBrains.Annotations;
using Microsoft.Extensions.Hosting;
using Sitko.Core.App;
using Sitko.Core.App.Web;

namespace Sitko.Core.Auth.IdentityServer;

Expand All @@ -11,51 +12,63 @@ public static IHostApplicationBuilder AddJwtIdentityServer(this IHostApplication
Action<IApplicationContext, JwtIdentityServerModuleOptions> configure,
string? optionsKey = null)
{
hostApplicationBuilder.GetSitkoCore().AddJwtIdentityServer(configure, optionsKey);
hostApplicationBuilder.GetSitkoCore<ISitkoCoreWebApplicationBuilder>().AddJwtIdentityServer(configure, optionsKey);
return hostApplicationBuilder;
}

public static IHostApplicationBuilder AddJwtIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
Action<JwtIdentityServerModuleOptions>? configure = null, string? optionsKey = null)
{
hostApplicationBuilder.GetSitkoCore().AddJwtIdentityServer(configure, optionsKey);
hostApplicationBuilder.GetSitkoCore<ISitkoCoreWebApplicationBuilder>().AddJwtIdentityServer(configure, optionsKey);
return hostApplicationBuilder;
}

public static IHostApplicationBuilder AddOidcIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
Action<IApplicationContext, OidcIdentityServerModuleOptions> configure,
string? optionsKey = null)
{
hostApplicationBuilder.GetSitkoCore().AddOidcIdentityServer(configure, optionsKey);
hostApplicationBuilder.GetSitkoCore<ISitkoCoreWebApplicationBuilder>().AddOidcIdentityServer(configure, optionsKey);
return hostApplicationBuilder;
}

public static IHostApplicationBuilder AddOidcIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
Action<OidcIdentityServerModuleOptions>? configure = null, string? optionsKey = null)
{
hostApplicationBuilder.GetSitkoCore().AddOidcIdentityServer(configure, optionsKey);
hostApplicationBuilder.GetSitkoCore<ISitkoCoreWebApplicationBuilder>().AddOidcIdentityServer(configure, optionsKey);
return hostApplicationBuilder;
}

public static ISitkoCoreApplicationBuilder AddJwtIdentityServer(this ISitkoCoreApplicationBuilder applicationBuilder,
public static ISitkoCoreWebApplicationBuilder AddJwtIdentityServer(this ISitkoCoreWebApplicationBuilder applicationBuilder,
Action<IApplicationContext, JwtIdentityServerModuleOptions> configure,
string? optionsKey = null) =>
string? optionsKey = null)
{
applicationBuilder
.AddModule<JwtIdentityServerModule, JwtIdentityServerModuleOptions>(configure, optionsKey);
return applicationBuilder;
}

public static ISitkoCoreApplicationBuilder AddJwtIdentityServer(this ISitkoCoreApplicationBuilder applicationBuilder,
Action<JwtIdentityServerModuleOptions>? configure = null, string? optionsKey = null) =>
public static ISitkoCoreWebApplicationBuilder AddJwtIdentityServer(this ISitkoCoreWebApplicationBuilder applicationBuilder,
Action<JwtIdentityServerModuleOptions>? configure = null, string? optionsKey = null)
{
applicationBuilder
.AddModule<JwtIdentityServerModule, JwtIdentityServerModuleOptions>(configure, optionsKey);
return applicationBuilder;
}

public static ISitkoCoreApplicationBuilder AddOidcIdentityServer(this ISitkoCoreApplicationBuilder applicationBuilder,
public static ISitkoCoreWebApplicationBuilder AddOidcIdentityServer(this ISitkoCoreWebApplicationBuilder applicationBuilder,
Action<IApplicationContext, OidcIdentityServerModuleOptions> configure,
string? optionsKey = null) =>
string? optionsKey = null)
{
applicationBuilder.AddModule<OidcIdentityServerModule, OidcIdentityServerModuleOptions>(configure,
optionsKey);
return applicationBuilder;
}

public static ISitkoCoreApplicationBuilder AddOidcIdentityServer(this ISitkoCoreApplicationBuilder applicationBuilder,
Action<OidcIdentityServerModuleOptions>? configure = null, string? optionsKey = null) =>
public static ISitkoCoreWebApplicationBuilder AddOidcIdentityServer(this ISitkoCoreWebApplicationBuilder applicationBuilder,
Action<OidcIdentityServerModuleOptions>? configure = null, string? optionsKey = null)
{
applicationBuilder.AddModule<OidcIdentityServerModule, OidcIdentityServerModuleOptions>(configure,
optionsKey);
return applicationBuilder;
}
}
11 changes: 5 additions & 6 deletions src/Sitko.Core.Blazor.MudBlazor.Server/ApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ namespace Sitko.Core.Blazor.MudBlazor.Server;
[PublicAPI]
public static class ApplicationExtensions
{
public static WebApplicationBuilder AddMudBlazorServer(this WebApplicationBuilder webApplicationBuilder)
public static ISitkoCoreBlazorServerApplicationBuilder AddMudBlazorServer(this WebApplicationBuilder webApplicationBuilder) => webApplicationBuilder.AddSitkoCoreBlazorServer().AddMudBlazorServer();

public static ISitkoCoreBlazorServerApplicationBuilder
AddMudBlazorServer(this ISitkoCoreBlazorServerApplicationBuilder webApplicationBuilder)
{
webApplicationBuilder.AddSitkoCoreBlazorServer().AddMudBlazorServer();
webApplicationBuilder.AddMudBlazor();
return webApplicationBuilder;
}

public static ISitkoCoreBlazorApplicationBuilder
AddMudBlazorServer(this ISitkoCoreBlazorServerApplicationBuilder webApplicationBuilder) =>
webApplicationBuilder.AddMudBlazor();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Reflection;
using Sitko.Core.App;
using Sitko.Core.App.Web;

namespace Sitko.Core.Blazor.Server;

public interface ISitkoCoreBlazorServerApplicationBuilder : ISitkoCoreBlazorApplicationBuilder, ISitkoCoreServerApplicationBuilder
public interface ISitkoCoreBlazorServerApplicationBuilder : ISitkoCoreBlazorApplicationBuilder, ISitkoCoreServerApplicationBuilder, ISitkoCoreWebApplicationBuilder
{
ISitkoCoreBlazorServerApplicationBuilder AddForms<TAssembly>();
ISitkoCoreBlazorServerApplicationBuilder AddForms(Assembly assembly);
ISitkoCoreBlazorServerApplicationBuilder ForceAuthorization();
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,4 @@ public ISitkoCoreBlazorServerApplicationBuilder AddForms(Assembly assembly)
.WithTransientLifetime());
return this;
}

[PublicAPI]
public ISitkoCoreBlazorServerApplicationBuilder ForceAuthorization()
{
Services.AddRazorPages(options =>
{
options.Conventions.AuthorizeFolder("/");
});
return this;
}
}

0 comments on commit 3865683

Please sign in to comment.