Skip to content

Commit

Permalink
feat: application pakages
Browse files Browse the repository at this point in the history
  • Loading branch information
aguacongas committed Apr 29, 2020
1 parent 64e44c3 commit 13395fb
Show file tree
Hide file tree
Showing 210 changed files with 970 additions and 693 deletions.
50 changes: 49 additions & 1 deletion TheIdServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aguacongas.TheIdServer.Auth
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aguacongas.TheIdServer.Authentication.IntegrationTest", "test\Aguacongas.TheIdServer.Authentication..Integration.Test\Aguacongas.TheIdServer.Authentication.IntegrationTest.csproj", "{7F9CAFD6-D361-4CB8-A6E1-7F1D0BEE4AEB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aguacongas.TheIdServer.Test", "test\Aguacongas.TheIdServer.Test\Aguacongas.TheIdServer.Test.csproj", "{34B6748E-64C1-46A3-AABE-56E215204542}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aguacongas.TheIdServer.Test", "test\Aguacongas.TheIdServer.Test\Aguacongas.TheIdServer.Test.csproj", "{34B6748E-64C1-46A3-AABE-56E215204542}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BlazorApp", "BlazorApp", "{8A3B91E5-02A3-42F0-B2E7-E419B5086FFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aguacongas.TheIdServer.BlazorApp.Infrastructure", "src\BlazorApp\Aguacongas.TheIdServer.BlazorApp.Infrastructure\Aguacongas.TheIdServer.BlazorApp.Infrastructure.csproj", "{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aguacongas.TheIdServer.BlazorApp.Components", "src\BlazorApp\Aguacongas.TheIdServer.BlazorApp.Components\Aguacongas.TheIdServer.BlazorApp.Components.csproj", "{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aguacongas.TheIdServer.BlazorApp.Pages", "src\BlazorApp\Aguacongas.TheIdServer.BlazorApp.Pages\Aguacongas.TheIdServer.BlazorApp.Pages.csproj", "{665F5796-7F54-44D7-8976-9ADA169353F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -443,6 +451,42 @@ Global
{34B6748E-64C1-46A3-AABE-56E215204542}.Release|x64.Build.0 = Release|Any CPU
{34B6748E-64C1-46A3-AABE-56E215204542}.Release|x86.ActiveCfg = Release|Any CPU
{34B6748E-64C1-46A3-AABE-56E215204542}.Release|x86.Build.0 = Release|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Debug|x64.ActiveCfg = Debug|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Debug|x64.Build.0 = Debug|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Debug|x86.ActiveCfg = Debug|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Debug|x86.Build.0 = Debug|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Release|Any CPU.Build.0 = Release|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Release|x64.ActiveCfg = Release|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Release|x64.Build.0 = Release|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Release|x86.ActiveCfg = Release|Any CPU
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08}.Release|x86.Build.0 = Release|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Debug|x64.ActiveCfg = Debug|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Debug|x64.Build.0 = Debug|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Debug|x86.ActiveCfg = Debug|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Debug|x86.Build.0 = Debug|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Release|Any CPU.Build.0 = Release|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Release|x64.ActiveCfg = Release|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Release|x64.Build.0 = Release|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Release|x86.ActiveCfg = Release|Any CPU
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA}.Release|x86.Build.0 = Release|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Debug|x64.ActiveCfg = Debug|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Debug|x64.Build.0 = Debug|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Debug|x86.ActiveCfg = Debug|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Debug|x86.Build.0 = Debug|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Release|Any CPU.Build.0 = Release|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Release|x64.ActiveCfg = Release|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Release|x64.Build.0 = Release|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Release|x86.ActiveCfg = Release|Any CPU
{665F5796-7F54-44D7-8976-9ADA169353F1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -480,6 +524,10 @@ Global
{9F64CDFF-6347-4F62-B74F-C6CA2743E667} = {DF545B54-78FB-42D0-A842-A1490A579B37}
{7F9CAFD6-D361-4CB8-A6E1-7F1D0BEE4AEB} = {DE50F426-4409-4573-8502-93364ED12E0C}
{34B6748E-64C1-46A3-AABE-56E215204542} = {DE50F426-4409-4573-8502-93364ED12E0C}
{8A3B91E5-02A3-42F0-B2E7-E419B5086FFA} = {DF545B54-78FB-42D0-A842-A1490A579B37}
{C2806393-D1EB-4DDE-8A4B-AA65014B8D08} = {8A3B91E5-02A3-42F0-B2E7-E419B5086FFA}
{54A378B8-9BA4-4082-A044-2A8DEA7DEAEA} = {8A3B91E5-02A3-42F0-B2E7-E419B5086FFA}
{665F5796-7F54-44D7-8976-9ADA169353F1} = {8A3B91E5-02A3-42F0-B2E7-E419B5086FFA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5283BE0B-F6F2-4458-B12F-64C78CFF8CBA}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<PackageProjectUrl>https://github.com/Aguafrommars/TheIdServer/tree/master/src/Aguacongas.TheIdServer.BlazorApp</PackageProjectUrl>
<RepositoryUrl>https://github.com/Aguafrommars/TheIdServer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>theidserver;identity</PackageTags>
<Description>Identity stores implementation for TheIdServer API.</Description>
<PackageTags>theidserver;identityserver4;oidc;oauth;identity,authentication;security</PackageTags>
<Description>TheIdServer administration application.</Description>
<DebugType>Full</DebugType>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
Expand All @@ -20,6 +20,7 @@

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<CodeAnalysisRuleSet>Aguacongas.TheIdServer.BlazorApp.ruleset</CodeAnalysisRuleSet>
<NoWarn>1701;1702</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,8 +30,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aguacongas.AspNetCore.Authentication.EntityFramework" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview5.20216.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview5.20216.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview5.20216.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview3.20168.3" />
Expand All @@ -41,6 +40,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\IdentityServer\Aguacongas.IdentityServer.Admin.Http.Store\Aguacongas.IdentityServer.Admin.Http.Store.csproj" />
<ProjectReference Include="..\BlazorApp\Aguacongas.TheIdServer.BlazorApp.Pages\Aguacongas.TheIdServer.BlazorApp.Pages.csproj" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion src/Aguacongas.TheIdServer.BlazorApp/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="new[] { typeof(Pages.Index).Assembly }">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
Expand Down
10 changes: 0 additions & 10 deletions src/Aguacongas.TheIdServer.BlazorApp/Models/Settings.cs

This file was deleted.

65 changes: 5 additions & 60 deletions src/Aguacongas.TheIdServer.BlazorApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
using Aguacongas.AspNetCore.Authentication;
using Aguacongas.IdentityServer.Store;
using Aguacongas.TheIdServer.BlazorApp.Models;
using Aguacongas.TheIdServer.BlazorApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Threading.Tasks;

namespace Aguacongas.TheIdServer.BlazorApp
Expand All @@ -19,56 +9,11 @@ public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
ConfigureServices(builder.Services, builder.Configuration, builder.HostEnvironment.BaseAddress);
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.AddTheIdServerApp();
await builder.Build().RunAsync();
}

public static void ConfigureServices(IServiceCollection services, IConfiguration configuration, string baseAddress)
{
var settings = configuration.Get<Settings>();
services
.AddOptions()
.AddOidcAuthentication<RemoteAuthenticationState, RemoteUserAccount>(options =>
{
configuration.GetSection("AuthenticationPaths").Bind(options.AuthenticationPaths);
configuration.GetSection("UserOptions").Bind(options.UserOptions);
configuration.Bind("ProviderOptions", options.ProviderOptions);
})
.AddAccountClaimsPrincipalFactory<RemoteAuthenticationState, RemoteUserAccount, ClaimsPrincipalFactory>();

services.AddAuthorizationCore(options =>
{
options.AddIdentityServerPolicies();
});


services
.AddIdentityServer4AdminHttpStores(p =>
{
return Task.FromResult(CreateApiHttpClient(p, settings));
})
.AddSingleton(new HttpClient { BaseAddress = new Uri(baseAddress) })
.AddSingleton(p => settings)
.AddSingleton<Notifier>()
.AddSingleton<IAuthenticationSchemeOptionsSerializer, AuthenticationSchemeOptionsSerializer>()
.AddTransient<IAdminStore<User>, UserAdminStore>()
.AddTransient<IAdminStore<Role>, RoleAdminStore>()
.AddTransient<IAdminStore<ExternalProvider>, ExternalProviderStore>()
.AddHttpClient("oidc")
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
}

private static HttpClient CreateApiHttpClient(IServiceProvider p, Settings settings)
{
var httpClient = p.GetRequiredService<IHttpClientFactory>()
.CreateClient("oidc");

var apiUri = new Uri(settings.ApiBaseUrl);
httpClient.BaseAddress = apiUri;
return httpClient;
}
}

}
}
38 changes: 37 additions & 1 deletion src/Aguacongas.TheIdServer.BlazorApp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This project contains the code of the [Blazor wasm](https//blazor.net) application to manage an [IdentityServer4](https://identityserver4.readthedocs.io/en/latest/)

## Instalation

### From Docker

The application is embeded in the [server's Linux image](../Aguacongas.TheIdServer/README.md#from-docker).
Expand All @@ -16,6 +18,14 @@ Unzip in the destination of your choice, and use the server of your choice.

Read [Host and deploy ASP.NET Core Blazor WebAssembly](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/blazor/webassembly?view=aspnetcore-3.1) for more information.

### From Nuget packages

Nuget packages composing the application are available on [nuget.org](https://www.nuget.org/):

* **Aguacongas.TheIdServer.BlazorApp.Infrastructure** contains application models, services, validators and extensions
* **Aguacongas.TheIdServer.BlazorApp.Components** contains application components
* **Aguacongas.TheIdServer.BlazorApp.Pages** contains application pages

## Configuration

The application reads its configuration from *appsettings.json* and environment specific configuration data from *appsettings.{environment}.json*
Expand All @@ -30,6 +40,19 @@ The application reads its configuration from *appsettings.json* and environment
"remoteRegisterPath": "/identity/account/register",
"remoteProfilePath": "/identity/account/manage"
},
"loggingOptions": {
"minimum": "Debug",
"filters": [
{
"category": "System",
"level": "Warning"
},
{
"category": "Microsoft",
"level": "Information"
}
]
},
"userOptions": {
"roleClaim": "role"
},
Expand Down Expand Up @@ -66,6 +89,18 @@ The application doesn't contain pages to register a new user or manage the curre

For more informations read [ASP.NET Core Blazor WebAssembly additional security scenarios / Customize app routes](https://docs.microsoft.com/en-us/aspnet/core/security/blazor/webassembly/additional-scenarios?view=aspnetcore-3.1#customize-app-routes).

### loggingOptions

Defines logging options.

#### minimum

Defines the [log minimum level](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1).

#### filters

Each item in this array add a log filter by category and [LogLevel](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1)

### userOptions

The section **userOptions** is binded to the class `Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationUserOptions`.
Expand Down Expand Up @@ -119,4 +154,5 @@ This endpoint should return an html fragment code.

* [ASP.NET Core Blazor hosting model configuration](https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-model-configuration?view=aspnetcore-3.1#configuration)
* [ASP.NET Core Blazor WebAssembly additional security scenarios](https://docs.microsoft.com/en-us/aspnet/core/security/blazor/webassembly/additional-scenarios?view=aspnetcore-3.1#customize-app-routes)
* [Secure an ASP.NET Core Blazor WebAssembly standalone app with the Authentication library](https://docs.microsoft.com/en-us/aspnet/core/security/blazor/webassembly/standalone-with-authentication-library?view=aspnetcore-3.1#authentication-service-support)
* [Secure an ASP.NET Core Blazor WebAssembly standalone app with the Authentication library](https://docs.microsoft.com/en-us/aspnet/core/security/blazor/webassembly/standalone-with-authentication-library?view=aspnetcore-3.1#authentication-service-support)
* [LogLevel Enum](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-3.1)
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{
"loggingOptions": {
"minimum": "Debug",
"filters": [
{
"category": "System",
"level": "Warning"
},
{
"category": "Microsoft",
"level": "Information"
}
]
},
"providerOptions": {
"postLogoutRedirectUri": "https://localhost:5443/authentication/logout-callback",
"redirectUri": "https://localhost:5443/authentication/login-callback"
Expand Down
3 changes: 3 additions & 0 deletions src/Aguacongas.TheIdServer.BlazorApp/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"administratorEmail": "[email protected]",
"apiBaseUrl": "https://localhost:5443/api",
"loggingOptions": {
"minimum": "Warning"
},
"authenticationPaths": {
"remoteRegisterPath": "/identity/account/register",
"remoteProfilePath": "/identity/account/manage"
Expand Down
2 changes: 1 addition & 1 deletion src/Aguacongas.TheIdServer.BlazorApp/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</head>
<body>
<app>Loading...</app>
<script src="scripts/interop.js"></script>
<script src="_content/Aguacongas.TheIdServer.BlazorApp.Infrastructure/TheIdServerInterop.js"></script>
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/Aguacongas.TheIdServer/Aguacongas.TheIdServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageProjectUrl>https://github.com/Aguafrommars/TheIdServer/tree/master/src/Aguacongas.TheIdServer</PackageProjectUrl>
<RepositoryUrl>https://github.com/Aguafrommars/TheIdServer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>aspnetcore;oidc,oauth;authentication;security</PackageTags>
<PackageTags>aspnetcore;identityserver4;oidc,oauth;authentication;security</PackageTags>
<Description>OpenID/Connect server base on IdentityServer4.</Description>
<DebugType>Full</DebugType>
<UserSecretsId>f6987681-1871-440a-a6ea-a606c2c5ccf6</UserSecretsId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Authors>Olivier Lefebvre</Authors>
<Copyright>Copyright (c) 2020 @Olivier Lefebvre</Copyright>
<PackageLicense>https://raw.githubusercontent.com/Aguafrommars/TheIdServer/master/LICENSE</PackageLicense>
<PackageProjectUrl>https://github.com/Aguafrommars/TheIdServer/tree/master/src/Aguacongas.TheIdServer.BlazorApp</PackageProjectUrl>
<RepositoryUrl>https://github.com/Aguafrommars/TheIdServer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>theidserver;identityserver4;oidc;oauth;identity,authentication;security</PackageTags>
<Description>TheIdServer administration application components.</Description>
<DebugType>Full</DebugType>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Aguacongas.TheIdServer.BlazorApp.Infrastructure\Aguacongas.TheIdServer.BlazorApp.Infrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ private void SetValue(TimeSpan? time)
{
var timeValue = time.Value;
var type = typeof(T);
if (type.IsGenericType)
{
type = type.GetGenericArguments()[0];
if (type.IsGenericType)
{
type = type.GetGenericArguments()[0];
}
Value = (T)Convert.ChangeType(timeValue.TotalSeconds, type);
ValueChanged.InvokeAsync(Value);
Expand Down
Loading

0 comments on commit 13395fb

Please sign in to comment.