diff --git a/Duende.Bff.sln b/Duende.Bff.sln index 63aced70..9aa9dc9f 100644 --- a/Duende.Bff.sln +++ b/Duende.Bff.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34414.90 @@ -43,11 +43,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duende.Bff.Blazor", "src\Du EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duende.Bff.Blazor.Client", "src\Duende.Bff.Blazor.Client\Duende.Bff.Blazor.Client.csproj", "{DDB9C401-6B1F-4727-A4CB-932034FBF94E}" EndProject -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.Wasm.Bff", "samples\Blazor.Wasm\Blazor.Wasm.Bff\Blazor.Wasm.Bff.csproj", "{BC21ADB7-F2CA-44F0-B6ED-0405E1EFFFA3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.Wasm.Client", "samples\Blazor.Wasm\Blazor.Wasm.Client\Blazor.Wasm.Client.csproj", "{4E69FCF6-AE76-4F6D-98B8-969E9D244AE4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duende.Bff.Blazor.Client.UnitTests", "test\Duende.Bff.Blazor.Client.UnitTests\Duende.Bff.Blazor.Client.UnitTests.csproj", "{001840D4-8B83-4A8C-AF2C-5429D4F9A370}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duende.Bff.Blazor.UnitTests", "test\Duende.Bff.Blazor.UnitTests\Duende.Bff.Blazor.UnitTests.csproj", "{2A04808A-A06C-4F10-87B9-2D12E065F729}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -250,6 +253,30 @@ Global {DDB9C401-6B1F-4727-A4CB-932034FBF94E}.Release|x64.Build.0 = Release|Any CPU {DDB9C401-6B1F-4727-A4CB-932034FBF94E}.Release|x86.ActiveCfg = Release|Any CPU {DDB9C401-6B1F-4727-A4CB-932034FBF94E}.Release|x86.Build.0 = Release|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Debug|Any CPU.Build.0 = Debug|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Debug|x64.ActiveCfg = Debug|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Debug|x64.Build.0 = Debug|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Debug|x86.ActiveCfg = Debug|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Debug|x86.Build.0 = Debug|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Release|Any CPU.ActiveCfg = Release|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Release|Any CPU.Build.0 = Release|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Release|x64.ActiveCfg = Release|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Release|x64.Build.0 = Release|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Release|x86.ActiveCfg = Release|Any CPU + {001840D4-8B83-4A8C-AF2C-5429D4F9A370}.Release|x86.Build.0 = Release|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Debug|x64.ActiveCfg = Debug|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Debug|x64.Build.0 = Debug|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Debug|x86.ActiveCfg = Debug|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Debug|x86.Build.0 = Debug|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Release|Any CPU.Build.0 = Release|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Release|x64.ActiveCfg = Release|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Release|x64.Build.0 = Release|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Release|x86.ActiveCfg = Release|Any CPU + {2A04808A-A06C-4F10-87B9-2D12E065F729}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -271,6 +298,8 @@ Global {CBB98134-92F5-487D-8CA3-84C19FF46775} = {E14F66D1-EA3E-40C6-835A-91A4382D4646} {E02DF032-C17F-4D0C-9CAA-3BD3CC9E4F84} = {3C549079-A502-4B40-B051-5278915AE91B} {DDB9C401-6B1F-4727-A4CB-932034FBF94E} = {3C549079-A502-4B40-B051-5278915AE91B} + {001840D4-8B83-4A8C-AF2C-5429D4F9A370} = {B2A776DB-385B-4AD4-96A5-61746FD909C3} + {2A04808A-A06C-4F10-87B9-2D12E065F729} = {B2A776DB-385B-4AD4-96A5-61746FD909C3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3DAD5980-4688-4794-9CF0-6F3CB67194E7} diff --git a/src/Duende.Bff.Blazor.Client/BffBlazorOptions.cs b/src/Duende.Bff.Blazor.Client/BffBlazorOptions.cs index 549ae63f..5f3b8d64 100644 --- a/src/Duende.Bff.Blazor.Client/BffBlazorOptions.cs +++ b/src/Duende.Bff.Blazor.Client/BffBlazorOptions.cs @@ -4,38 +4,38 @@ namespace Duende.Bff.Blazor.Client; /// -/// Options for Blazor BFF +/// Options for Blazor BFF /// public class BffBlazorOptions { /// - /// The base path to use for remote APIs. + /// The base path to use for remote APIs. /// public string RemoteApiPath { get; set; } = "remote-apis/"; /// - /// The base address to use for remote APIs. If unset (the default), the - /// blazor hosting environment's base address is used. + /// The base address to use for remote APIs. If unset (the default), the + /// blazor hosting environment's base address is used. /// public string? RemoteApiBaseAddress { get; set; } = null; /// - /// The base address to use for the state provider's calls to the - /// /bff/user endpoint. If unset (the default), the blazor hosting - /// environment's base address is used. + /// The base address to use for the state provider's calls to the /bff/user + /// endpoint. If unset (the default), the blazor hosting environment's base + /// address is used. /// public string? StateProviderBaseAddress { get; set; } = null; /// - /// The delay, in milliseconds, before the AuthenticationStateProvider - /// will start polling the /bff/user endpoint. Defaults to 1000 ms. + /// The delay, in milliseconds, before the AuthenticationStateProvider will + /// start polling the /bff/user endpoint. Defaults to 1000 ms. /// public int StateProviderPollingDelay { get; set; } = 1000; /// - /// The delay, in milliseconds, between polling requests by the - /// AuthenticationStateProvider to the /bff/user endpoint. Defaults to - /// 5000 ms. + /// The delay, in milliseconds, between polling requests by the + /// AuthenticationStateProvider to the /bff/user endpoint. Defaults to 5000 + /// ms. /// public int StateProviderPollingInterval { get; set; } = 5000; } \ No newline at end of file diff --git a/src/Duende.Bff.Blazor.Client/BffClientAuthenticationStateProvider.cs b/src/Duende.Bff.Blazor.Client/BffClientAuthenticationStateProvider.cs index cf22b28c..558ac23d 100644 --- a/src/Duende.Bff.Blazor.Client/BffClientAuthenticationStateProvider.cs +++ b/src/Duende.Bff.Blazor.Client/BffClientAuthenticationStateProvider.cs @@ -22,9 +22,8 @@ public class BffClientAuthenticationStateProvider : AuthenticationStateProvider private ClaimsPrincipal _cachedUser = new(new ClaimsIdentity()); /// - /// An intended for use in - /// Blazor WASM. It polls the /bff/user endpoint to monitor session - /// state. + /// An intended for use in Blazor + /// WASM. It polls the /bff/user endpoint to monitor session state. /// public BffClientAuthenticationStateProvider( PersistentComponentState state, @@ -48,7 +47,6 @@ public override async Task GetAuthenticationStateAsync() var user = await GetUser(); var state = new AuthenticationState(user); - // Periodically if (user.Identity is { IsAuthenticated: true }) { _logger.LogInformation("starting background check.."); diff --git a/src/Duende.Bff.Blazor.Client/ServiceCollectionExtensions.cs b/src/Duende.Bff.Blazor.Client/ServiceCollectionExtensions.cs index c758bd71..ad716ddc 100644 --- a/src/Duende.Bff.Blazor.Client/ServiceCollectionExtensions.cs +++ b/src/Duende.Bff.Blazor.Client/ServiceCollectionExtensions.cs @@ -10,6 +10,10 @@ namespace Duende.Bff.Blazor.Client; public static class ServiceCollectionExtensions { + /// + /// Adds Duende.BFF services to a Blazor Client (wasm) application. + /// + /// A callback used to set . public static IServiceCollection AddBffBlazorClient(this IServiceCollection services, Action? configureAction = null) { diff --git a/src/Duende.Bff.Blazor/ServerSideTokenStore.cs b/src/Duende.Bff.Blazor/ServerSideTokenStore.cs index 099c9d86..b7562f22 100644 --- a/src/Duende.Bff.Blazor/ServerSideTokenStore.cs +++ b/src/Duende.Bff.Blazor/ServerSideTokenStore.cs @@ -10,7 +10,7 @@ namespace Duende.Bff.Blazor; /// -/// A token store that retrieves tokens from server side sessions. +/// A token store that retrieves tokens from server side sessions. /// public class ServerSideTokenStore( IStoreTokensInAuthenticationProperties tokensInAuthProperties, diff --git a/src/Duende.Bff.Shared/ClaimLite.cs b/src/Duende.Bff.Shared/ClaimLite.cs index ee7fd863..6d9a989a 100644 --- a/src/Duende.Bff.Shared/ClaimLite.cs +++ b/src/Duende.Bff.Shared/ClaimLite.cs @@ -4,22 +4,22 @@ namespace Duende.Bff; /// -/// Serialization friendly claim +/// Serialization friendly claim /// public class ClaimLite { /// - /// The type + /// The type /// public string Type { get; init; } = default!; /// - /// The value + /// The value /// public string Value { get; init; } = default!; /// - /// The value type + /// The value type /// public string? ValueType { get; init; } } \ No newline at end of file diff --git a/src/Duende.Bff.Shared/ClaimsLiteExtensions.cs b/src/Duende.Bff.Shared/ClaimsLiteExtensions.cs index d113d978..ba44f60d 100644 --- a/src/Duende.Bff.Shared/ClaimsLiteExtensions.cs +++ b/src/Duende.Bff.Shared/ClaimsLiteExtensions.cs @@ -8,7 +8,7 @@ namespace Duende.Bff; public static class ClaimsLiteExtensions { /// - /// Converts a ClaimsPrincipalLite to ClaimsPrincipal + /// Converts a ClaimsPrincipalLite to ClaimsPrincipal /// public static ClaimsPrincipal ToClaimsPrincipal(this ClaimsPrincipalLite principal) { @@ -21,7 +21,7 @@ public static ClaimsPrincipal ToClaimsPrincipal(this ClaimsPrincipalLite princip } /// - /// Converts a ClaimsPrincipal to ClaimsPrincipalLite + /// Converts a ClaimsPrincipal to ClaimsPrincipalLite /// public static ClaimsPrincipalLite ToClaimsPrincipalLite(this ClaimsPrincipal principal) { diff --git a/src/Duende.Bff.Shared/ClaimsPrincipalLite.cs b/src/Duende.Bff.Shared/ClaimsPrincipalLite.cs index ee880aa3..455f8116 100644 --- a/src/Duende.Bff.Shared/ClaimsPrincipalLite.cs +++ b/src/Duende.Bff.Shared/ClaimsPrincipalLite.cs @@ -4,27 +4,27 @@ namespace Duende.Bff; /// -/// Serialization friendly ClaimsPrincipal +/// Serialization friendly ClaimsPrincipal /// public class ClaimsPrincipalLite { /// - /// The authentication type + /// The authentication type /// public string? AuthenticationType { get; init; } /// - /// The name claim type + /// The name claim type /// public string? NameClaimType { get; init; } /// - /// The role claim type + /// The role claim type /// public string? RoleClaimType { get; init; } /// - /// The claims + /// The claims /// public ClaimLite[] Claims { get; init; } = default!; } \ No newline at end of file diff --git a/test/Duende.Bff.Blazor.UnitTests/Duende.Bff.Blazor.UnitTests.csproj b/test/Duende.Bff.Blazor.UnitTests/Duende.Bff.Blazor.UnitTests.csproj new file mode 100644 index 00000000..9c5b30a2 --- /dev/null +++ b/test/Duende.Bff.Blazor.UnitTests/Duende.Bff.Blazor.UnitTests.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + +