From 1360d6559e800a1b82623b8b7ac5d8009c339258 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 25 Feb 2020 13:57:19 -0800 Subject: [PATCH] Add AddOptions to AddAuthorizationCore (#18911) Fixes: #18471 AddAuthorizationCore previously assumed that options were already registered. This isn't the case in 5.0 in Blazor WASM. We don't want Blazor to register options in the default host because it prevents options from being linked out. note: we will have some remaining work for this issue after this change is merged. The Blazor WASM hosting changes haven't landed in master yet, so we'll need to update that code to remove options from the host. --- .../src/AuthorizationServiceCollectionExtensions.cs | 10 +++++++--- src/Security/build.sh | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 src/Security/build.sh diff --git a/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs b/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs index 0f788cd5ad..57fcf253b7 100644 --- a/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs +++ b/src/Security/Authorization/Core/src/AuthorizationServiceCollectionExtensions.cs @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.DependencyInjection public static class AuthorizationServiceCollectionExtensions { /// - /// Adds authorization services to the specified . + /// Adds authorization services to the specified . /// /// The to add services to. /// The so that additional calls can be chained. @@ -24,7 +24,11 @@ namespace Microsoft.Extensions.DependencyInjection { throw new ArgumentNullException(nameof(services)); } - + + // These services depend on options, and they are used in Blazor WASM, where options + // aren't included by default. + services.AddOptions(); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); @@ -35,7 +39,7 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// Adds authorization services to the specified . + /// Adds authorization services to the specified . /// /// The to add services to. /// An action delegate to configure the provided . diff --git a/src/Security/build.sh b/src/Security/build.sh new file mode 100755 index 0000000000..7046bb98a0 --- /dev/null +++ b/src/Security/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +repo_root="$DIR/../.." +"$repo_root/build.sh" --projects "$DIR/**/*.*proj" "$@"