diff --git a/Directory.Build.props b/Directory.Build.props index eb93f374..56289014 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -92,72 +92,39 @@ true - - true - - net462; - net472; net48 - net8.0; - net9.0; net10.0 - net9.0-android; net10.0-android - net9.0-ios; net10.0-ios - net9.0-maccatalyst; net10.0-maccatalyst - net9.0-macos; net10.0-macos - net8.0-windows7.0; - net8.0-windows10.0.17763; - net9.0-windows7.0; - net9.0-windows10.0.17763; net10.0-windows7.0; net10.0-windows10.0.17763 - - - netstandard2.0; - netstandard2.1 - - - - uap10.0.17763 - @@ -176,10 +143,8 @@ $([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory))) false - false - $(MSBuildThisFileDirectory)eng\AfterTargetFrameworkInference.targets + true $(TargetsForTfmSpecificContentInPackage);AddTfmSpecificPlaceholders - $(MSBuildThisFileDirectory)eng\msbuild\web\WebApplications\Microsoft.WebApplication.targets - + true - + annotations @@ -48,84 +41,29 @@ 7.0 - - $(DefineConstants);SUPPORTS_NAMED_PIPE_CONSTRUCTOR_WITH_ACL - - - $(DefineConstants);SUPPORTS_APPLICATION_CONFIGURATION_INITIALIZATION - $(DefineConstants);SUPPORTS_AUTHENTICATION_HANDLER_SELECTION_FALLBACK - $(DefineConstants);SUPPORTS_AUTHENTICATION_HANDLER_TIME_PROVIDER_ARGUMENT - $(DefineConstants);SUPPORTS_AUTHORIZATION_MIDDLEWARE - $(DefineConstants);SUPPORTS_BCL_ASYNC_ENUMERABLE - $(DefineConstants);SUPPORTS_BULK_DBSET_OPERATIONS - $(DefineConstants);SUPPORTS_DBSET_VALUETASK_FINDASYNC - $(DefineConstants);SUPPORTS_ENDPOINT_ROUTING - $(DefineConstants);SUPPORTS_ENVIRONMENT_PROCESS_PATH + $(DefineConstants);SUPPORTS_BROTLI_COMPRESSION + $(DefineConstants);SUPPORTS_CURRENT_USER_ONLY_PIPE_OPTION $(DefineConstants);SUPPORTS_HEXADECIMAL_STRING_CONVERSION $(DefineConstants);SUPPORTS_HTTP_CLIENT_DEFAULT_REQUEST_VERSION $(DefineConstants);SUPPORTS_HTTP_CLIENT_DEFAULT_REQUEST_VERSION_POLICY $(DefineConstants);SUPPORTS_HTTP_CLIENT_RESILIENCE - $(DefineConstants);SUPPORTS_INT32_RANDOM_NUMBER_GENERATOR_METHODS - $(DefineConstants);SUPPORTS_KESTREL_TLS_HANDSHAKE_CALLBACK_OPTIONS - $(DefineConstants);SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS $(DefineConstants);SUPPORTS_NAMED_PIPE_STATIC_FACTORY_WITH_ACL $(DefineConstants);SUPPORTS_ONE_SHOT_HASHING_METHODS $(DefineConstants);SUPPORTS_ONE_SHOT_KEY_DERIVATION_METHODS $(DefineConstants);SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON $(DefineConstants);SUPPORTS_PEM_ENCODED_KEY_IMPORT - $(DefineConstants);SUPPORTS_REDIRECTION_ON_SIGN_IN + $(DefineConstants);SUPPORTS_RELAXED_URI_LIMITS $(DefineConstants);SUPPORTS_TEXT_ELEMENT_ENUMERATOR + $(DefineConstants);SUPPORTS_TIME_CONSTANT_COMPARISONS + $(DefineConstants);SUPPORTS_TYPE_DESCRIPTOR_TYPE_REGISTRATION $(DefineConstants);SUPPORTS_VALUETASK_COMPLETED_TASK - $(DefineConstants);SUPPORTS_WINFORMS_TASK_DIALOG + $(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_CLONING $(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_CUSTOM_TRUST_STORE $(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_DOWNLOAD_MODE $(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_TRUST_MODE - $(DefineConstants);SUPPORTS_ZLIB_COMPRESSION - - - - $(DefineConstants);SUPPORTS_ECDSA - - - - $(DefineConstants);SUPPORTS_CERTIFICATE_GENERATION - $(DefineConstants);SUPPORTS_EPHEMERAL_KEY_SETS - $(DefineConstants);SUPPORTS_KEY_DERIVATION_WITH_SPECIFIED_HASH_ALGORITHM - $(DefineConstants);SUPPORTS_RSA_KEY_CREATION_WITH_SPECIFIED_SIZE - - - - $(DefineConstants);SUPPORTS_BROTLI_COMPRESSION - $(DefineConstants);SUPPORTS_CURRENT_USER_ONLY_PIPE_OPTION - $(DefineConstants);SUPPORTS_SERVICE_PROVIDER_IN_HTTP_MESSAGE_HANDLER_BUILDER - $(DefineConstants);SUPPORTS_TIME_CONSTANT_COMPARISONS - $(DefineConstants);SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST - - - - $(DefineConstants);SUPPORTS_CERTIFICATE_LOADER - $(DefineConstants);SUPPORTS_JSON_ELEMENT_DEEP_EQUALS - $(DefineConstants);SUPPORTS_JSON_ELEMENT_PROPERTY_COUNT - $(DefineConstants);SUPPORTS_KEYED_HTTP_CLIENT_RESOLUTION - $(DefineConstants);SUPPORTS_TYPE_DESCRIPTOR_TYPE_REGISTRATION - $(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_CLONING $(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_VERIFICATION_TIME_MODE - - - - $(DefineConstants);SUPPORTS_ASYNC_LINQ - $(DefineConstants);SUPPORTS_RELAXED_URI_LIMITS + $(DefineConstants);SUPPORTS_ZLIB_COMPRESSION $(DefineConstants);SUPPORTS_WINDOWS_RUNTIME - - - - - - reactive - - - - - - - diff --git a/Directory.Packages.props b/Directory.Packages.props index cb74a9dc..55744d2d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,104 +4,12 @@ Note: to cover as many platforms as possible and reduce the number of package references, OpenIddict extensively uses multi-targeting and per-framework package references. As such, package versions must be carefully chosen to ensure they are consistent and compatible with - the TFMs supported by OpenIddict (e.g for .NET 8, only Microsoft.AspNetCore.* packages within - the [8.0.0,9.0.0) range are allowed). Special care must also be taken when selecting versions - to ensure that transitive references also respect the same constraints (e.g for the .NET 8 TFM, - a package must only depend on Microsoft.Extensions.* packages within the [8.0.0,9.0.0) range). + the TFMs supported by OpenIddict (e.g for .NET 10, only Microsoft.AspNetCore.* packages within + the [10.0.0,11.0.0) range are allowed). Special care must also be taken when selecting versions + to ensure that transitive references also respect the same constraints (e.g for the .NET 10 TFM, + a package must only depend on Microsoft.Extensions.* packages within the [10.0.0,11.0.0) range). --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -168,15 +74,8 @@ - - - - - - - - + @@ -184,93 +83,13 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -371,57 +163,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(MSBuildThisFileDirectory)msbuild\uwp\Microsoft.Windows.UI.Xaml.CSharp.targets - - - diff --git a/eng/Tools.props b/eng/Tools.props index ec7d4e83..14a551e8 100644 --- a/eng/Tools.props +++ b/eng/Tools.props @@ -1,6 +1,7 @@ + @@ -41,6 +42,11 @@ + + + + diff --git a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll b/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll deleted file mode 100644 index 4b2ec52e..00000000 Binary files a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll and /dev/null differ diff --git a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.CPP.targets b/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.CPP.targets deleted file mode 100644 index a6a1e28d..00000000 --- a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.CPP.targets +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - MarkupCompilePass1; - $(BeforeClCompileTargets) - - - - ComputeXamlGeneratedCompileInputs; - $(ComputeCompileInputsTargets) - - - - $(ComputeLinkInputsTargets); - CreateWinMD; - ComputeGeneratedWinMD; - MarkupCompilePass2; - ComputeInvalidXamlGenerated; - CompileXamlGeneratedFiles; - $(AfterBuildCompileTargets) - - - - $(XamlPreLinkDependsOn); - ComputeXamlGeneratedCLOutputs - - - True - true - true - - - - - $(ValidatePresenceOfAppxManifestItemsDependsOn); - _CreateContentItemOutOfCustomAppxManifest - - - - - - - - - - - - - %(Link.WindowsMetadataFile) - - - - - - - - - - - - - Generated Files\ - $(GeneratedFilesDir) - $(ExtensionsToDeleteOnClean);*.g.h;*.g.cpp;*.xaml - - - - - - - - - - - XamlGeneratedFilesOutputGroup;$(GeneratedFilesOutputGroupDependsOn) - - - - - - - - - - - - - - - XamlGenerated - - - XamlGenerated - - - XamlGenerated - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - DesignTimeMarkupCompilation - - - DesignTimeMarkupCompilation - - - - - CppDesignTimeMarkupCompilation;$(MarkupCompilePass1DependsOn) - - - - - - - - diff --git a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.CSharp.targets b/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.CSharp.targets deleted file mode 100644 index 177d37ed..00000000 --- a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.CSharp.targets +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - 8.1 - WindowsPhoneApp - v8.1 - - - - 8.1 - .NETCore - v4.5.1 - - - - true - true - true - false - true - True - - - true - - - - - - - - - - - diff --git a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.Common.targets b/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.Common.targets deleted file mode 100644 index 1de50a60..00000000 --- a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.Common.targets +++ /dev/null @@ -1,664 +0,0 @@ - - - - - - - - - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSWinExpress\14.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VSWinExpress\14.0\Setup\VC@ProductDir) - - true - true - false - - XamlSaveStateFile.xml - $(IntermediateOutputPath)\$(XamlSavedStateFileName) - - - @(ReferenceAssemblyPaths); - $(WindowsSDK80Path) - - - - - - - - - - - - - - - - - - - - - - - $(AssemblyName).xr.xml - - - - - - - - $(TargetName) - - $(RootNamespace) - $(RootNamespace) - - $(TargetName) - - - - $(AvailablePlatforms),ARM - - - - ResolveKeySource; - MarkupCompilePass1; - XamlPreCompile; - MarkupCompilePass2; - $(PrepareResourcesDependsOn) - - - true - true - 6.02 - 6.00 - - _OnXamlPreCompileError - - - $(IntermediateOutputPath) - - - - - - - - - $(FrameworkSDKRoot)bin - - - true - - - - - - - - - - - - - - - - - - - - - - - GetXamlCppIncludeDirectories; - $(GetXamlCppIncludeDirectories) - - - - GetXamlCppIncludeDirectories; - $(GetXamlCppIncludeDirectories) - - - - GetXamlCppIncludeDirectories; - $(Prep_ComputeProcessXamlFilesDependsOn) - - - - - - - - - - - - - - DesignTimeMarkupCompilation; - $(CoreCompileDependsOn) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(WarningLevel) - 0 - - - - - - - - - $(PrevWarningLevel) - 1 - - - - - - @(XamlIntermediateAssembly->'%(Identity)') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_Temp Remove="@(_Temp)" /> - - - - - - %(AllProjectXamlPages.DefaultXamlLink) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(XamlGeneratedOutputPath) - $(OutputPath)\ - - - - - - - - - - - - - - - - GetPackagingOutputs; - $(PrepareLibraryLayoutDependsOn) - - - - - - - - <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'ContentFilesProjectOutputGroup'" /> - <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'CustomOutputGroupForPackaging'" /> - - - - - - - - - - - $(ResolveReferencesDependsOn); - ImplicitlyExpandTargetFramework; - ImplicitlyExpandTargetPlatform - - - - $(ImplicitlyExpandTargetFrameworkDependsOn); - GetReferenceAssemblyPaths - - - - - - - - false - false - .NET for Windows Store apps - $(TargetFrameworkMoniker) - ImplicitlyExpandTargetFramework - True - - - - - - - - - <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)" - Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetFramework'"/> - - - - - - - - true - false - $(TargetPlatformMoniker) - $(TargetPlatformDisplayName) - ImplicitlyExpandTargetPlatform - True - - - - - - - - - <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)" - Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetPlatform'"/> - - - - - - true - - - - - true - - - - - - diff --git a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.Cps.targets b/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.Cps.targets deleted file mode 100644 index 1940c6f7..00000000 --- a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.Cps.targets +++ /dev/null @@ -1,52 +0,0 @@ - - - - - ;BrowseObject - - - ProjectCapabilitySubscriptionService;BrowseObject - - - - - - - - - - - File;BrowseObject - - - - - - - - Never - - - Never - - - Never - - - Never - - - Never - - - Never - - - diff --git a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.VisualBasic.targets b/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.VisualBasic.targets deleted file mode 100644 index 73148929..00000000 --- a/eng/msbuild/uwp/8.1/Microsoft.Windows.UI.Xaml.VisualBasic.targets +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - 8.1 - WindowsPhoneApp - v8.1 - - - - 8.1 - .NETCore - v4.5.1 - - - - true - true - true - false - true - True - - true - true - - Empty - - - - - - - - - - diff --git a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Build.Tasks.dll b/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Build.Tasks.dll deleted file mode 100644 index 76707f72..00000000 Binary files a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Build.Tasks.dll and /dev/null differ diff --git a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.CPP.targets b/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.CPP.targets deleted file mode 100644 index 51c45c0f..00000000 --- a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.CPP.targets +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - MarkupCompilePass1; - $(BeforeClCompileTargets) - - - - ComputeXamlGeneratedCompileInputs; - $(ComputeCompileInputsTargets) - - - - $(ComputeLinkInputsTargets); - CreateWinMD; - ComputeGeneratedWinMD; - MarkupCompilePass2; - ComputeInvalidXamlGenerated; - CompileXamlGeneratedFiles; - $(AfterBuildCompileTargets) - - - - $(XamlPreLinkDependsOn); - ComputeXamlGeneratedCLOutputs - - - True - true - false - - - - - $(ValidatePresenceOfAppxManifestItemsDependsOn); - _CreateContentItemOutOfCustomAppxManifest - - - - - - - - - - - - - %(Link.WindowsMetadataFile) - - - - - - - - - - - - - Generated Files\ - $(GeneratedFilesDir) - $(ExtensionsToDeleteOnClean);*.g.h;*.g.cpp;*.xaml - - - - - - - - - - - XamlGeneratedFilesOutputGroup;$(GeneratedFilesOutputGroupDependsOn) - - - - - - - - - - - - - - - XamlGenerated - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - DesignTimeMarkupCompilation - - - DesignTimeMarkupCompilation - - - - - CppDesignTimeMarkupCompilation;$(MarkupCompilePass1DependsOn) - - - - - - - diff --git a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.CSharp.targets b/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.CSharp.targets deleted file mode 100644 index 6c877010..00000000 --- a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.CSharp.targets +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - 8.1 - WindowsPhoneApp - v8.1 - - - - 8.2 - .NETCore - v4.5.1 - - - - .NETCore - v5.0 - - - - Windows - 10.0 - - - - $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\NuGet\Repository', 'UWPNugetPackages', null, RegistryView.Registry32, RegistryView.Default)) - $(RestoreAdditionalProjectFallbackFolders);$(UWPNugetRepo) - - - - true - true - true - false - true - True - - - true - - - - - - - - - - diff --git a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Common.targets b/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Common.targets deleted file mode 100644 index 7c006909..00000000 --- a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Common.targets +++ /dev/null @@ -1,753 +0,0 @@ - - - - - - - - - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\15.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\15.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSWinExpress\15.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VSWinExpress\15.0\Setup\VC@ProductDir) - $(VsInstallRoot)\Common7\IDE\VC\ - - $(TargetPlatformSdkRootOverride) - $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\$(SDKIdentifier)\v$(SDKVersion)', 'InstallationFolder', null, RegistryView.Registry32, RegistryView.Default)) - - true - true - false - - XamlSaveStateFile.xml - $(IntermediateOutputPath)\$(XamlSavedStateFileName) - - - @(ReferenceAssemblyPaths); - $(WindowsSdkPath) - - - - $(WindowsSdkPath)\UnionMetadata\facade\Windows.winmd - - - - - - - - - - - - - - - - - - - - - - - $(AssemblyName).xr.xml - - - - - - - - $(TargetName) - - $(RootNamespace) - $(RootNamespace) - - $(TargetName) - - - - $(AvailablePlatforms),ARM - - - - ResolveKeySource; - MarkupCompilePass1; - XamlPreCompile; - MarkupCompilePass2; - $(PrepareResourcesDependsOn) - - - true - true - 6.02 - 6.00 - - _OnXamlPreCompileError - - - $(IntermediateOutputPath) - - - - - - - - - $(FrameworkSDKRoot)bin - - - true - - - - - - - - - - - - - - - - - - 8.2 - $(TargetPlatformVersion) - - - - - - - - - - - - - - GetXamlCppIncludeDirectories; - $(GetXamlCppIncludeDirectories) - - - - GetXamlCppIncludeDirectories; - $(GetXamlCppIncludeDirectories) - - - - GetXamlCppIncludeDirectories; - $(Prep_ComputeProcessXamlFilesDependsOn) - - - - - - - - - - - - - - DesignTimeMarkupCompilation; - $(CoreCompileDependsOn) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(WarningLevel) - 0 - - - - - - - - - $(PrevWarningLevel) - 1 - - - - - - @(XamlIntermediateAssembly->'%(Identity)') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_Temp Remove="@(_Temp)" /> - - - - - - %(AllProjectXamlPages.DefaultXamlLink) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ExpandSDKReference - - - ExpandSDKReference - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(XamlGeneratedOutputPath) - $(OutputPath)\ - - - - - - - - - - - - - - - - GetPackagingOutputs; - $(PrepareLibraryLayoutDependsOn) - - - - - - - - <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'ContentFilesProjectOutputGroup'" /> - <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'CustomOutputGroupForPackaging'" /> - - - - - - - - - - - $(ResolveReferencesDependsOn); - ImplicitlyExpandTargetFramework; - ImplicitlyExpandTargetPlatform - - - - $(ImplicitlyExpandTargetFrameworkDependsOn); - GetReferenceAssemblyPaths - - - - - - - - false - false - .NET for Windows Store apps - $(TargetFrameworkMoniker) - ImplicitlyExpandTargetFramework - True - - - - - - - - - <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)" - Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetFramework'"/> - - - - - - - - <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' != ''" Include="$(TargetPlatformSdkRootOverride)\References\**\*.winmd"> - true - false - $(TargetPlatformMoniker) - $(TargetPlatformDisplayName) - ImplicitlyExpandTargetPlatform - True - - <_TargetPlatformWinMDs Condition="'$(TargetPlatformSdkRootOverride)' == ''" Include="$([Microsoft.Build.Utilities.ToolLocationHelper]::GetTargetPlatformReferences($(SDKIdentifier), $(SDKVersion), $(TargetPlatformIdentifier), $(TargetPlatformMinVersion), $(TargetPlatformVersion)))"> - true - false - $(TargetPlatformMoniker) - $(TargetPlatformDisplayName) - ImplicitlyExpandTargetPlatform - True - - - - - - - - - - - true - false - $(TargetPlatformMoniker) - $(TargetPlatformDisplayName) - ImplicitlyExpandTargetPlatform - True - - <_ResolveAssemblyReferenceResolvedFiles Include="@(_TargetPlatformWinMDs)" /> - - - <_TargetPlatformWinMDs Remove="@(_TargetPlatformWinMDs)" /> - - - - - - true - - - - - true - - - - - - <_AppxWinmdFilesToHarvest Include="@(PackagingOutputs)" - Condition="'%(PackagingOutputs.Extension)' == '.winmd' - and '%(PackagingOutputs.ProjectName)' == '$(ProjectName)' - and '%(PackagingOutputs.ResolvedFrom)' != 'GetSDKReferenceFiles'"> - - WindowsRuntime 1.4;CLR v4.0.30319 - - WindowsRuntime 1.4 - - WindowsRuntime 1.4;CLR v4.0.30319 - - WindowsRuntime 1.4 - - WindowsRuntime 1.4 - - $(PrimaryProjectWinmdImageRuntimeOverride) - - - - - - - \ No newline at end of file diff --git a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Cps.targets b/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Cps.targets deleted file mode 100644 index 1940c6f7..00000000 --- a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.Cps.targets +++ /dev/null @@ -1,52 +0,0 @@ - - - - - ;BrowseObject - - - ProjectCapabilitySubscriptionService;BrowseObject - - - - - - - - - - - File;BrowseObject - - - - - - - - Never - - - Never - - - Never - - - Never - - - Never - - - Never - - - diff --git a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.VisualBasic.targets b/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.VisualBasic.targets deleted file mode 100644 index f8cf3ab8..00000000 --- a/eng/msbuild/uwp/8.2/Microsoft.Windows.UI.Xaml.VisualBasic.targets +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - 8.1 - WindowsPhoneApp - v8.1 - - - - 8.2 - .NETCore - v4.5.1 - - - - .NETCore - v5.0 - - - - Windows - 10.0 - - - - $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\NuGet\Repository', 'UWPNugetPackages', null, RegistryView.Registry32, RegistryView.Default)) - $(RestoreAdditionalProjectFallbackFolders);$(UWPNugetRepo) - - - - true - true - true - false - true - True - - true - true - - Empty - - - - - - - - - - - - - $(IntermediateOutputPath)$(TargetName).pdb - - - - diff --git a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.CPP.targets b/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.CPP.targets deleted file mode 100644 index 0409f7ef..00000000 --- a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.CPP.targets +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - MarkupCompilePass1; - $(BeforeClCompileTargets) - - - - ComputeXamlGeneratedCompileInputs; - $(ComputeCompileInputsTargets) - - - - - - - - $(ComputeLinkInputsTargets); - CreateWinMD; - ComputeGeneratedWinMD; - MarkupCompilePass2; - ComputeInvalidXamlGenerated; - CompileXamlGeneratedFiles; - $(AfterClCompileTargets) - - - - - - - $(ComputeLinkInputsTargets); - CreateWinMD; - ComputeGeneratedWinMD; - MarkupCompilePass2; - ComputeInvalidXamlGenerated; - CompileXamlGeneratedFiles; - $(AfterBuildCompileTargets) - - - - - - - - $(XamlPreLinkDependsOn); - ComputeXamlGeneratedCLOutputs - - - - $(XamlPreLibDependsOn); - ComputeXamlGeneratedCLOutputs - - - True - true - false - - - - - $(ValidatePresenceOfAppxManifestItemsDependsOn); - _CreateContentItemOutOfCustomAppxManifest - - - - - - - - - - - - - - - - %(Link.WindowsMetadataFile) - - - - - - - - - - - - - Generated Files\ - $(GeneratedFilesDir) - $(ExtensionsToDeleteOnClean);*.g.h;*.g.cpp;*.xaml - - - - - - - - - - - XamlGeneratedFilesOutputGroup;$(GeneratedFilesOutputGroupDependsOn) - - - - - - - - - - - - - - - XamlGenerated - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - DesignTimeMarkupCompilation - - - DesignTimeMarkupCompilation - - - - - CppDesignTimeMarkupCompilation;$(MarkupCompilePass1DependsOn) - - - - - - - diff --git a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.CSharp.targets b/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.CSharp.targets deleted file mode 100644 index 6c877010..00000000 --- a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.CSharp.targets +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - 8.1 - WindowsPhoneApp - v8.1 - - - - 8.2 - .NETCore - v4.5.1 - - - - .NETCore - v5.0 - - - - Windows - 10.0 - - - - $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\NuGet\Repository', 'UWPNugetPackages', null, RegistryView.Registry32, RegistryView.Default)) - $(RestoreAdditionalProjectFallbackFolders);$(UWPNugetRepo) - - - - true - true - true - false - true - True - - - true - - - - - - - - - - diff --git a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.Common.targets b/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.Common.targets deleted file mode 100644 index 66a72e31..00000000 --- a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.Common.targets +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - $(AvailablePlatforms),ARM64 - - - - - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\15.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\15.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSWinExpress\15.0\Setup\VC@ProductDir) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VSWinExpress\15.0\Setup\VC@ProductDir) - $(VsInstallRoot)\Common7\IDE\VC\ - - $(TargetPlatformSdkRootOverride)\ - $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot10', null, RegistryView.Registry32, RegistryView.Default)) - - - $(WindowsKitsPath)bin\$(TargetPlatformVersion)\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets - $(WindowsKitsPath)bin\$(TargetPlatformMinVersion)\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets - - - - - - - - - <_AppxWinmdFilesToHarvest Include="@(PackagingOutputs)" - Condition="'%(PackagingOutputs.Extension)' == '.winmd' - and '%(PackagingOutputs.ProjectName)' == '$(ProjectName)' - and '%(PackagingOutputs.ResolvedFrom)' != 'GetSDKReferenceFiles'"> - - WindowsRuntime 1.4;CLR v4.0.30319 - - WindowsRuntime 1.4 - - WindowsRuntime 1.4;CLR v4.0.30319 - - WindowsRuntime 1.4 - - WindowsRuntime 1.4 - - $(PrimaryProjectWinmdImageRuntimeOverride) - - - - - - - ContentFilesProjectOutputGroup; - Prep_ComputeProcessXamlFiles; - $(AddProcessedXamlFilesToCopyLocalDependsOn) - - - _CalculateXbfSupport; - $(AddProcessedXamlFilesToCopyLocalDependsOn) - - - - - - <_ProcessedXamlFilesToCopyLocal Include="@(GeneratedXamlSrc->'%(FullPath)')" /> - <_ProcessedXamlFilesToCopyLocal Condition="'$(GenerateLibraryLayout)' == 'true' and '$(DisableXbfGeneration)' != 'true'" Include="@(GeneratedXamlSrc0->'%(FullPath)')" /> - - - - - - - - <_AllChildProjectItemsWithTargetPath Include="@(_ProcessedXamlFilesToCopyLocalWithTargetPath)" Condition="'%(Extension)' != '.xbf' OR ('%(Extension)' == '.xbf' AND '$(_SupportXbfAsEmbedFileResources)' != 'true')"> - $(AppxPriInitialPath)\%(_ProcessedXamlFilesToCopyLocalWithTargetPath.TargetPath) - PreserveNewest - - - - - <_AllChildProjectItemsWithTargetPath Include="@(ContentFilesProjectOutputGroupOutput)"> - $(AppxPriInitialPath)\%(ContentFilesProjectOutputGroupOutput.TargetPath) - PreserveNewest - - - - - - - - - - - - <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'ContentFilesProjectOutputGroup'" /> - <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'CustomOutputGroupForPackaging'" /> - - - - - - - - diff --git a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.Cps.targets b/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.Cps.targets deleted file mode 100644 index 1940c6f7..00000000 --- a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.Cps.targets +++ /dev/null @@ -1,52 +0,0 @@ - - - - - ;BrowseObject - - - ProjectCapabilitySubscriptionService;BrowseObject - - - - - - - - - - - File;BrowseObject - - - - - - - - Never - - - Never - - - Never - - - Never - - - Never - - - Never - - - diff --git a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.VisualBasic.targets b/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.VisualBasic.targets deleted file mode 100644 index f8cf3ab8..00000000 --- a/eng/msbuild/uwp/8.21/Microsoft.Windows.UI.Xaml.VisualBasic.targets +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - 8.1 - WindowsPhoneApp - v8.1 - - - - 8.2 - .NETCore - v4.5.1 - - - - .NETCore - v5.0 - - - - Windows - 10.0 - - - - $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\NuGet\Repository', 'UWPNugetPackages', null, RegistryView.Registry32, RegistryView.Default)) - $(RestoreAdditionalProjectFallbackFolders);$(UWPNugetRepo) - - - - true - true - true - false - true - True - - true - true - - Empty - - - - - - - - - - - - - $(IntermediateOutputPath)$(TargetName).pdb - - - - diff --git a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.CPP.targets b/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.CPP.targets deleted file mode 100644 index c90dc830..00000000 --- a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.CPP.targets +++ /dev/null @@ -1,38 +0,0 @@ - - - True - - - - - - $(MarkupCompilePass1DependsOn);_WriteXamlTlogs - - - - - <_XamlReadTlog Include="^%(Page.FullPath)" - Condition="'%(Page.ExcludedFromBuild)' != 'true'"/> - - - <_XamlReadTlog Include="^%(ApplicationDefinition.FullPath)" - Condition="'%(ApplicationDefinition.ExcludedFromBuild)' != 'true'"/> - - - - - - - - <_XamlReadTlog Remove="@(_XamlReadTlog)" /> - - - - \ No newline at end of file diff --git a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.CSharp.targets b/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.CSharp.targets deleted file mode 100644 index 4fb0488b..00000000 --- a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.CSharp.targets +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.Common.targets b/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.Common.targets deleted file mode 100644 index c16526ba..00000000 --- a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.Common.targets +++ /dev/null @@ -1,49 +0,0 @@ - - - 8.0 - - - - 8.21 - - - - 8.2 - - - - $(TargetPlatformVersion) - - - - - 8.1 - - - - - $(VisualStudioVersion) - - - - - - true - - - - 16.11.0 - - - - - - - - $(UwpUnitTestSdkPkgVersion) - - - - - - \ No newline at end of file diff --git a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.VisualBasic.targets b/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.VisualBasic.targets deleted file mode 100644 index 9b70728d..00000000 --- a/eng/msbuild/uwp/Microsoft.Windows.UI.Xaml.VisualBasic.targets +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.AllFilesInProjectFolder.targets b/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.AllFilesInProjectFolder.targets deleted file mode 100644 index 87f143a6..00000000 --- a/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.AllFilesInProjectFolder.targets +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - - - - - - true - - - - - - - $(PublishPipelineCollectFilesCore); - CollectFilesFromProjectFolder; - - <_CollectFiles_IncludeIgnorableFile Condition="'$(_CollectFiles_IncludeIgnorableFile)'==''">False - - - False - True - - - - - - - - - - - - - - - - - - - - - - - <_KnownProjectItems Include="@(EmbeddedResource)" /> - <_KnownProjectItems Include="@(None)" /> - <_KnownProjectItems Include="@(Content)" /> - <_KnownProjectItems Include="@(Compile)" /> - - - - <_ProjectBaseIntermediateOutputPath Include="$(BaseIntermediateOutputPath)"/> - - - - - - - <_ExcludeRelativePathFromProjectFolder>^[^\\]*\.out$ - - - - - - - - - - - - - - - - $(OnBeforeCollectFilesFromProjectFolder_ExcludeSccFiles); - $(CollectFilesFromProjectFolder_ExcludeSccFilesDependsOn); - SetExcludeFromProjectFolder; - - - - - - <_ExcludeRelativePathFromProjectFolder>$(_ExcludeRelativePathFromProjectFolder);[^\\]*\.scc$;[^\\]*\.vssscc$;[^\\]*\.vspscc$ - - - - - - - - - - - - - $(OnBeforeCollectFilesFromProjectFolder); - $(CollectFilesFromProjectFolderDependsOn); - SetExcludeFromProjectFolder; - CollectFilesFromProjectFolder_ExcludeSccFiles; - - - - - - - - - - - - - - - - - - - - - %(_KnownProjectItems.Identity) - CollectFilesFromProjectFolder.KonwnProjectItems - AllFilesInProjectFolder - - - %(_KnownProjectItems.Link) - CollectFilesFromProjectFolder.KonwnProjectItems - AllFilesInProjectFolder - $(ExcludeLinkFilesInProject) - Link - - - - %(_AllFilesUnderProjectFolderExceptKnownProjectItems.Identity) - CollectFilesFromProjectFolder.ExceptKonwnProjectItems - AllFilesInProjectFolder - - - - - - - - - true - - - - - diff --git a/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.AllFilesInTheProject.targets b/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.AllFilesInTheProject.targets deleted file mode 100644 index 6456112b..00000000 --- a/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.AllFilesInTheProject.targets +++ /dev/null @@ -1,242 +0,0 @@ - - - - - true - - - - - - - False - - - - - - - - $(PublishPipelineCollectFilesCore); - CollectFilesFromCompile; - CollectFilesFromEmbeddedResource; - CollectFilesFromNone; - CollectFilesFromBaseApplicationManifest; - CollectFilesFromProjectFile; - - - - - - - - - - - $(OnBeforeCollectFilesFromCompile); - $(CollectFilesFromCompileDependsOn); - - - - - - - - - - - - %(Compile.Identity) - CollectFilesFromCompile - ProjectNotRunRequired - - - %(Compile.Link) - CollectFilesFromCompile - ProjectNotRunRequired - $(ExcludeLinkFilesInProject) - Link - - - - - - - - - - - $(OnBeforeCollectFilesFromEmbeddedResource); - $(CollectFilesFromEmbeddedResourceDependsOn); - - - - - - - - - - - %(EmbeddedResource.Identity) - CollectFilesFromEmbeddedResource - ProjectNotRunRequired - - - %(EmbeddedResource.Link) - CollectFilesFromEmbeddedResource - ProjectNotRunRequired - $(ExcludeLinkFilesInProject) - Link - - - - - - - - - - - $(OnBeforeCollectFilesFromNone); - $(CollectFilesFromNoneDependsOn); - - - - - - - - - - %(None.Identity) - CollectFilesFromNone - ProjectNotRunRequired - - - %(None.Link) - CollectFilesFromNone - ProjectNotRunRequired - $(ExcludeLinkFilesInProject) - Link - - - - - - - - - - - - $(OnBeforeCollectFilesFromBaseApplicationManifest); - $(CollectFilesFromBaseApplicationManifestDependsOn); - - - - - - - - - - - - %(BaseApplicationManifest.Identity) - CollectFilesFromBaseApplicationManifest - ProjectNotRunRequired - - - %(BaseApplicationManifest.Link) - CollectFilesFromBaseApplicationManifest - ProjectNotRunRequired - $(ExcludeLinkFilesInProject) - Link - - - - - - - - - - - - $(OnBeforeCollectFilesFromProjectFile); - $(CollectFilesFromProjectFileDependsOn); - - - - - - - - - - - $(MSBuildProjectFile) - CollectFilesFromProjectFile - ProjectNotRunRequired - - - $(MSBuildProjectFile).user - CollectFilesFromProjectFile - ProjectNotRunRequired - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.OnlyFilesToRunTheApp.targets b/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.OnlyFilesToRunTheApp.targets deleted file mode 100644 index 84667d52..00000000 --- a/eng/msbuild/web/Web/CollectFiles/Microsoft.Web.Publishing.OnlyFilesToRunTheApp.targets +++ /dev/null @@ -1,445 +0,0 @@ - - - - - - - - - true - - - - - - $(PublishPipelineCollectFilesCore); - CollectFilesFromIntermediateAssembly; - CollectFilesFromContent; - CollectFilesFromAddModules; - CollectFilesFrom_SGenDllCreated; - CollectFilesFromIntermediateSatelliteAssembliesWithTargetPath; - CollectFilesFromReference; - CollectFilesFromAllExtraReferenceFiles; - CollectFilesFrom_SourceItemsToCopyToOutputDirectory; - CollectFilesFromDocFileItem; - CollectFilesFrom_WebApplicationSilverlightXapFiles; - CollectFilesFrom_binDeployableAssemblies; - - True - - - - - - - - - $(OnBeforeCollectFilesFromIntermediateAssembly); - $(CollectFilesFromIntermediateAssemblyDependsOn); - - - - - - - - - - - - bin\%(FileName)%(Extension) - CollectFilesFromIntermediateAssembly - Run - - - - - - bin\%(FileName).pdb - CollectFilesFromIntermediateAssembly - Debug - - - - - - - - - - - - $(OnBeforeCollectFilesFromContent); - $(CollectFilesFromContentDependsOn); - - - - - - - - - - %(Content.Identity) - CollectFilesFromContent - Run - - - %(Content.Link) - CollectFilesFromContent - Run - $(ExcludeLinkFilesInProject) - Link - - - - - - - - - - - - $(OnBeforeCollectFilesFromAddModulesDependsOn); - $(CollectFilesFromAddModulesDependsOn); - - - - - - - - - - bin\%(FileName)%(Extension) - CollectFilesFromAddModules - Run - - - - - - - - - - - $(OnBeforeCollectFilesFrom_SGenDllCreated); - $(CollectFilesFrom_SGenDllCreatedDependsOn); - - - - - - - - - - bin\$(_SGenDllName) - CollectFilesFrom_SGenDllCreated - Run - - - - - - - - - - - $(OnBeforeCollectFilesFromIntermediateSatelliteAssembliesWithTargetPath); - $(CollectFilesFromIntermediateSatelliteAssembliesWithTargetPathDependsOn); - - - - - - - - - bin\%(IntermediateSatelliteAssembliesWithTargetPath.TargetPath) - CollectFilesFromIntermediateSatelliteAssembliesWithTargetPath - Run - - - - - - - - - - - - $(OnBeforeCollectFilesFromReference); - $(CollectFilesFromReferenceDependsOn); - ResolveProjectReferences; - ResolveAssemblyReferences; - - - - - - - - - - bin\%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(FileName)%(Extension) - CollectFilesFromReference - Run - - - - - - bin\%(FileName)%(Extension) - CollectFilesFromReference - Run - - - - - - - - - - - $(OnBeforeCollectFilesFromAllExtraReferenceFiles); - $(CollectFilesFromAllExtraReferenceFilesDependsOn); - - - - - - - - - - bin\%(FileName)%(Extension) - CollectFilesFromAllExtraReferenceFiles - Run - - - - - - - - - - - - - $(OnBeforeCollectFilesFrom_SourceItemsToCopyToOutputDirectory); - $(CollectFilesFrom_SourceItemsToCopyToOutputDirectoryDependsOn); - - - - - - - - - <_TempSourceItemsToCopyToOutputDirectory Include="@(_SourceItemsToCopyToOutputDirectoryAlways); @(_SourceItemsToCopyToOutputDirectory)" /> - - - - - - bin\%(_TempSourceItemsToCopyToOutputDirectory.TargetPath) - CollectFilesFrom_SourceItemsToCopyToOutputDirectory - Run - - - - - - - - - - - - $(OnBeforeCollectFilesFromDocFileItem); - $(CollectFilesFromDocFileItemDependsOn); - - - - - - - - - - bin\%(FileName)%(Extension) - CollectFilesFromDocFileItem - Run - - - - - - - - - - - $(OnBeforeCollectFilesFrom_WebApplicationSilverlightXapFiles); - $(CollectFilesFrom_WebApplicationSilverlightXapFilesDependsOn); - - - - - - - - - - - - - - %(_WebApplicationSilverlightXapFiles.Identity) - CollectFilesFrom_WebApplicationSilverlightXapFiles - Run - - - - - - - - - - - $(OnBeforeCollectFilesFrom_binDeployableAssemblies); - $(CollectFilesFrom_binDeployableAssembliesDependsOn); - _CopyBinDeployableAssemblies; - - - - - - - - - - - - - - bin\%(RecursiveDir)%(FileName)%(Extension) - CollectFilesFrom_binDeployableAssemblies_NoDestinationRelPath - Run - - - - bin\%(_binDeployableAssemblies_None.DestinationRelPath)%(FileName)%(Extension) - CollectFilesFrom_binDeployableAssemblies_WithDestinationRelPath - Run - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FPSE.targets b/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FPSE.targets deleted file mode 100644 index 2093b505..00000000 --- a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FPSE.targets +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - <_WPPWebPublishMethodSupports>$(_WPPWebPublishMethodSupports);WebFPSEPublish - - - - - - - - - $(OnBeforeWebFPSEPublish); - $(WebFPSEPublishDependsOn); - - - - - - - - - - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FTP.targets b/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FTP.targets deleted file mode 100644 index 9fc08695..00000000 --- a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FTP.targets +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - <_WPPWebPublishMethodSupports>$(_WPPWebPublishMethodSupports);WebFTPPublish - - - - - - - - - - $(OnBeforeWebFTPPublish); - $(WebFTPPublishDependsOn); - - - - - - - - - - - - - - - - true - - - - - diff --git a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FileSystem.targets b/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FileSystem.targets deleted file mode 100644 index 337c54ab..00000000 --- a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.FileSystem.targets +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - <_WPPWebPublishMethodSupports>$(_WPPWebPublishMethodSupports);WebFileSystemPublish - - - - - - - - - - $(OnBeforeWebFileSystemPublish); - $(WebFileSystemPublishDependsOn); - - - $(WebFileSystemPublishDependsOn); - PipelinePreDeployCopyAllFilesToOneFolder; - - - - - - - <_DoWebFileSystemPublishDeleteExtraFiles>False - <_DoWebFileSystemPublishDeleteExtraFiles Condition= "'$(DeleteExistingFiles)' == 'True'" >True - <_HttpHeader>http:// - <_DoWebFileSystemPublish>False - <_DoWebFileSystemPublish Condition="'$(PublishUrl)'!='' And '$(PublishUrl.StartsWith($(_HttpHeader), StringComparison.OrdinalIgnoreCase))' == 'False' And '$([System.IO.Path]::GetFullPath($(PublishUrl)))' != ''">True - - - - - - - - - - - - - - - - - - %(_AllFilesUnder_WPPAllFilesInSingleFolder.Identity) - WebFileSystemPublish - AllFilesInFolder - - - - - - - <_AllExtraFilesUnderPublishUrl Include="$(PublishUrl)\**" /> - <_AllExtraFilesUnderPublishUrl - Remove="@(FilesForFileCopy->'$(PublishUrl)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.MsDeploy.targets b/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.MsDeploy.targets deleted file mode 100644 index d3a85726..00000000 --- a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.MsDeploy.targets +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - true - - - - - - - - Microsoft.Web.Publishing.MSDeploy.Common.targets - - - - - True - - $(PipelineDeployPhaseDependsOn); - PipelineMsdeploySpecificTransformPhase; - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.Package.targets b/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.Package.targets deleted file mode 100644 index 17f7652c..00000000 --- a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.Deploy.Package.targets +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - true - - - - - Microsoft.Web.Publishing.MSDeploy.Common.targets - - - - - True - - $(PipelineDeployPhaseDependsOn); - PipelineMsdeploySpecificTransformPhase; - - - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.MsDeploy.Common.targets b/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.MsDeploy.Common.targets deleted file mode 100644 index f958c498..00000000 --- a/eng/msbuild/web/Web/Deploy/Microsoft.Web.Publishing.MsDeploy.Common.targets +++ /dev/null @@ -1,1192 +0,0 @@ - - - - - - - - - - - - - - true - - - - - - True - - - - True - InsertEFCodeFirstDeploy - $(_WPPDefaultIntermediateOutputPath)$(InsertEFCodeFirstDeployWebCofigIntermediateOutput) - - - - - - - True - - GetMSDeployInstalledVersionPath; - - - - - - - - - - - - - - - - - - - - - - - - - - - True - - $(ParseSQLScriptForMSDeployParametersDependsOn); - GetMSDeployInstalledVersionPath; - ProcessPublishDatabaseSettings; - - - - - <_DatabasesToPackageForSQL Include="@(_DatabasesToPackage)" - Condition="$(EnableSqlScriptVariableParameterize) - And '%(_DatabasesToPackage.SourceProvider)' == 'DbFullSql' - And '%(_DatabasesToPackage.SourcePath)' != '' - And Exists('%(_DatabasesToPackage.SourcePath)') - And '$([System.IO.Path]::GetExtension($([System.String]::new(%(_DatabasesToPackage.SourcePath)))))' == '.sql'"> - - - - - - - - - - - - - - - - - - - - - - True - - $(HandleEFCodeFirstDataMigrationDependsOn); - GetMSDeployInstalledVersionPath; - ProcessPublishDatabaseSettings; - - - - - - <_DatabasesToPackageForEFCodeFirst Include="@(_DatabasesToPackage)" - Condition="'%(_DatabasesToPackage.SourceProvider)' == 'DbCodeFirst' - And '%(_DatabasesToPackage.SourcePath)' == 'DBMigration'"> - - - - - - - - - - - - HandleEFCodeFirstDataMigration; - ProfileTransformWebConfig; - - - $(PreInsertEFCodeFirstDeployWebCofigBeforeTarget); - AutoParameterizationWebConfigConnectionStrings; - PreAutoParameterizationWebConfigConnectionStrings; - - - - - - <_WebConfigsToInsertEFCodeFirstDeployContext Include="@(FilesForPackagingFromProject)" - Condition="'%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ProjectConfigFileName)' - And !%(FilesForPackagingFromProject.Exclude) - And '%(DestinationRelativePath)' == '$(ProjectConfigFileName)'"> - $(InsertEFCodeFirstDeployWebCofigLocation)\original - $(InsertEFCodeFirstDeployWebCofigLocation)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_WebConfigsToInsertEFCodeFirstDeployContextOuputFiles Include="@(_WebConfigsToInsertEFCodeFirstDeployContext->'%(TransformOutputFile)')"> - - - - - <_WebConfigsToInsertEFCodeFirstDeployContextOuputDirectories>@(_WebConfigsToInsertEFCodeFirstDeployContextOuputFiles->'%(RootDir)%(Directory)') - <_WebConfigsToInsertEFCodeFirstDeployContextOuput>@(_WebConfigsToInsertEFCodeFirstDeployContext->'%(TransformOutputFile)'); - - - - <_WebConfigsToInsertEFCodeFirstDeployContextOuputDirectories Include="$(_WebConfigsToInsertEFCodeFirstDeployContextOuputDirectories)" /> - - - - - - - - - - - - - - - - - - - - - - - $(_PublishLocalizedString_EFCodeFirstConnectionStringParameterDescription) - - - - - - - - - - - %(_DatabasesToPackageForEFCodeFirst.DestinationPath) - %(_DatabasesToPackageForEFCodeFirst.DestinationGroup) $(_EscapedDeployParameterEFCodeFirstConnectionStringDescription) - True - False - - - - - <_InsertEFCodeFirstDeployContextNames Include="@(_DatabasesToPackageForEFCodeFirst)"> - - <add - name="%(_DatabasesToPackageForEFCodeFirst.DestinationGroup)_DatabasePublish" - connectionString="%(_DatabasesToPackageForEFCodeFirst.DestinationGroup)_DatabasePublish.ConnetionString" - providerName="$(InsertAdditionalWebConfigConnectionStringProviderName)" - xdt:Transform="InsertIfMissing" - xdt:Locator="Match(name)" - xdt:SupressWarnings="True" - /> - - - <context type="%(_DatabasesToPackageForEFCodeFirst.SourceDbContext)" - xdt:Transform="InsertIfMissing" - xdt:Locator="Match(type)" - xdt:SupressWarnings="true" - > - <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[%(_DatabasesToPackageForEFCodeFirst.SourceDbContext)], [%(_DatabasesToPackageForEFCodeFirst.SourceMigrationConfiguration)]], EntityFramework, PublicKeyToken=b77a5c561934e089"> - <parameters> - <parameter value="%(_DatabasesToPackageForEFCodeFirst.DestinationGroup)_DatabasePublish" /> - </parameters> - </databaseInitializer> - </context> - - - - - - - - <_WebConfigsToInsertEFCodeFirstDeployContext_Transform><?xml version="1.0"?> - <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> - <connectionStrings xdt:Transform="InsertIfMissing" xdt:SupressWarnings="True"> - @(_InsertEFCodeFirstDeployContextNames->'%(TransformXMLFragement_CSInsert)', '') - </connectionStrings> - <entityFramework xdt:Transform="InsertIfMissing" xdt:SupressWarnings="true"> - <contexts xdt:Transform="InsertIfMissing" xdt:SupressWarnings="true"> - @(_InsertEFCodeFirstDeployContextNames->'%(TransformXMLFragement_Deploy)', '') - </contexts> - </entityFramework> - </configuration> - - - - - - - - - - - - - - HandleEFCodeFirstDataMigration; - ProfileTransformWebConfig; - PreInsertEFCodeFirstDeployWebCofig; - - - - - - - - - - - - <_WebConfigToInsertEFCodeFirstDeployContext_Identity>%(_WebConfigsToInsertEFCodeFirstDeployContext.Identity) - <_WebConfigToInsertEFCodeFirstDeployContext_TransformOutputFile>%(_WebConfigsToInsertEFCodeFirstDeployContext.TransformOutputFile) - <_WebConfigsToInsertEFCodeFirstDeployContext_TransformScope>%(_WebConfigsToInsertEFCodeFirstDeployContext.TransformScope) - - - - - - - - - - - - - - - HandleEFCodeFirstDataMigration; - ProfileTransformWebConfig; - PreInsertEFCodeFirstDeployWebCofig; - InsertEFCodeFirstDeployWebCofigCore; - - - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforeInsertEFCodeFirstDeployWebCofig); - $(InsertEFCodeFirstDeployWebCofigDependsOn); - TransformWebConfig; - HandleEFCodeFirstDataMigration; - ProfileTransformWebConfig; - PreInsertEFCodeFirstDeployWebCofig; - InsertEFCodeFirstDeployWebCofigCore; - PostInsertEFCodeFirstDeployWebCofig; - - - $(InsertEFCodeFirstDeployWebCofigBeforeTargets); - PreAutoParameterizationWebConfigConnectionStrings; - AutoParameterizationWebConfigConnectionStrings; - PipelineMsdeploySpecificTransformPhase; - - - - - - - - - <_DbDacFxDestinationPathesToPublish Include="@(_DatabasesToPackage->'%(DestinationPath)')" Condition="'%(_DatabasesToPackage.SourceProvider)' == 'dbDacFx'" /> - - - - - - - - - - - - - - - True - - $(CollectDatabasesToPublishDependsOn); - GetMSDeployInstalledVersionPath; - ProcessPublishDatabaseSettings; - _CheckDBProvidersAreAvailableAtServer; - ParseSQLScriptForMSDeployParameters; - HandleEFCodeFirstDataMigration; - InsertEFCodeFirstDeployWebCofig; - - - - - - - - - - - - - - - $(BeforeAddDeclareParametersItemsForDatabaseScript); - CollectDatabasesToPublish; - - - - - - - - - - - - - - - - - - - - <_VsPublish_DatabaseToPackage_DeclareParameters Include="@(_DatabasesToPackage->'$(DeployParameterPrefix)%(DestinationGroup)-Deployment Connection String')" - Condition="'%(_DatabasesToPackage.Identity)' !='' And '%(_DatabasesToPackage.SourceProvider)' != 'DbCodeFirst' "> - ProviderPath - %(_DatabasesToPackage.SourceProvider) - ^%(_DatabasesToPackage.SourcePath_RegExExcaped)$ - $(DeployParameterIISAppConnectionStringDescription) - %(_DatabasesToPackage.DestinationPath) - %(_DatabasesToPackage.DestinationPath) - $(MsDeployDatabaseTag) - - - - <_VsPublish_DatabaseToPackage_DeclareParameters Include="@(_DatabasesToPackage_SqlVariables->'$(DeployParameterPrefix)Sql script variable %24(%(Identity)) in %(DestinationGroup) scripts')" - Condition="$(EnableSqlScriptVariableParameterize) And '%(_DatabasesToPackage_SqlVariables.Identity)' !=''"> - $(MsDeploySqlCommandVariableKind) - ^%(_DatabasesToPackage_SqlVariables.SourcePath_RegExExcaped)$ - %(_DatabasesToPackage_SqlVariables.Identity) - $(DeployParameterSqlScriptVariablesDescription) - %(_DatabasesToPackage_SqlVariables.Value) - %(_DatabasesToPackage_SqlVariables.Value) - sql - - - - <_VsPublish_DatabaseToPackage_DeclareParameters Include="@(_DatabasesToPackage_SqlVariables->'$(DeployParameterPrefix)Sql script variable %24(%(Identity)) in %(DestinationGroup) scripts')" - Condition="$(EnableSqlScriptVariableParameterize) and '%(_DatabasesToPackage_SqlVariables.Identity)' !='' and ('%(_DatabasesToPackage_SqlVariables.Value)' == '') and ('%(_DatabasesToPackage_SqlVariables.IsDeclared)' == 'true') "> - parameterValidation - AllowEmpty - - - - $(VsSQLDatabaseScriptParametersPriority) - - - - - - - - - - - - - $(WriteItemsToSourceManifestDependsOn); - AddDatabasesToSourceManifest; - - - - - - - - - $(BeforeAddDatabasesToSourceManifest); - CollectDatabasesToPublish; - - - $(AddDatabasesToSourceManifestAfterTargets); - AddIisSettingAndFileContentsToSourceManifest; - - - - - - - - - - - - - - - - - - - - GetMSDeployInstalledVersionPath; - GenerateMsDeployManifestSettings; - GenerateMsdeployManifestFiles; - - - $(GenerateSampleDeployScriptAfterTargets); - PackageUsingManifest; - - - - - - - - - - - - - manifest - @(_MSDeploySourceManifest->'%(FileName)%(Extension)') - package - @(_MSDeployPackageFile->'%(FileName)%(Extension)') - archiveDir - @(_MSDeployArchiveDir->'%(FileName)%(Extension)') - %25RootPath%25$(GenerateSampleDeployScriptSourceFileName) - %25_Destination%25 - - @(_MSDeploySampleParametersValue->'%25RootPath%25%(FileName)%(Extension)') - <_ScriptGenerateSampleDeployScriptReadMeLocation>%25RootPath%25$(GenerateSampleDeployScriptReadMeFileName) - <_MSdeployFwdLink>http://go.microsoft.com/?linkid=9278654 - <_SampleDeployCmdFwdLink>http://go.microsoft.com/fwlink/?LinkID=183544 - - - - <_MsDeployDeclareParametersNotExclude Include="@(MsDeployDeclareParameters)" Condition="'%(ExcludeFromSetParameter)' != true and '%(MsDeployDeclareParameters.Identity)' !=''" /> - - - - - - - - - - - - - - $(GenerateSampleDeployScriptSourceRoot) - $(DeployEncryptKey) - - - - $(GenerateSampleDeployScriptDestinationRoot) - $(DeployEncryptKey) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - diff --git a/eng/msbuild/web/Web/Microsoft.DNX.Publishing.targets b/eng/msbuild/web/Web/Microsoft.DNX.Publishing.targets deleted file mode 100644 index 0aa067bd..00000000 --- a/eng/msbuild/web/Web/Microsoft.DNX.Publishing.targets +++ /dev/null @@ -1,459 +0,0 @@ - - - - - - - true - - - - - - - - $(MSBuildThisFileDirectory) - $(MSBuildThisFileDirectory)..\DNX\ - - - - - - - - - - - - $(MSBuildProjectDirectory)\Properties\PublishProfiles\ - $([System.IO.Path]::GetFileNameWithoutExtension($(PublishProfile))) - $(PublishProfileRootFolder)$(PublishProfileName).pubxml - - - - - - - $([System.IO.Path]::GetTempPath())PublishTemp - $(PublishOutputPathNoTrailingSlash)\ - - - - - - - - - - - - - - - - - - - - $(GatherAllFilesToPublishDependsOn); - GetRuntimeToolingPathTarget - - - - - - - - $(MSBuildProjectDirectory) - - - wwwroot - - $(WebRoot) - - - true - true - $(LastUsedBuildConfiguration) - - - $(Configuration) - Release - - - - - - - - - - - - - - - - - - - - - - - $(FileSystemPublishDependsOn); - GatherAllFilesToPublish; - - - - - - - - - - - - - $(DockerPublishDependsOn); - GatherAllFilesToPublish; - - - - - - - - - - - - $(MSDeployPublishDependsOn); - GatherAllFilesToPublish; - GenerateSkipRuleForAppData - - - - - - - - - - - - - - - - - - - - - - - $(PublishOutputPath)$(WebRoot) - - - $(DeployIisAppPath) - $(MsDeployServiceUrl) - $(UserName) - $(Password) - False - Basic - - - - - contentLibExtension - 2 - DoNotDeleteRule - <_EnableRuleList>$(MsDeployDoNotDeleteRule) - - false - false - - - <_MSDeployUserAgentSource Condition=" '$(BuildingInsideVisualStudio)' != 'true'">$(VisualStudioVersion):CmdLine - <_MSDeployUserAgentSource Condition=" '$(BuildingInsideVisualStudio)' == 'true'">$(VisualStudioVersion):PublishDialog - <_MSDeployUserAgent>VS$(_MSDeployUserAgentSource) - - - - - - - - - - - - $(PackagePublishDependsOn); - FileSystemPublish - - - - - - - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\Web\Powershell\1.0.1\default-publish.ps1)) - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\Web\Powershell\1.0.1\package.pubxml)) - - - - - - - - - - $(DefaultPublishDependsOn); - FileSystemPublish - - - - - - - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\Web\Powershell\1.0.1\default-publish.ps1)) - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\Web\Powershell\1.0.1\FileSystem.pubxml)) - - - - - - - - - - - - - - - - - - $([System.String]::Copy('$(WebPublishProfileFile)').Replace('.pubxml','-publish.ps1')) - - $([System.IO.File]::ReadAllText($(PowerShellScriptFile))) - - - - - - - - - $(%(_PublishProperties.Identity)) - - - - - - - - - - - - - - - - - dirPath - $(_Escaped_PublishOutputPath)\\App_Data$ - Source - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - \ No newline at end of file diff --git a/eng/msbuild/web/Web/Microsoft.Web.Publishing.Tasks.dll b/eng/msbuild/web/Web/Microsoft.Web.Publishing.Tasks.dll deleted file mode 100644 index af77f24b..00000000 Binary files a/eng/msbuild/web/Web/Microsoft.Web.Publishing.Tasks.dll and /dev/null differ diff --git a/eng/msbuild/web/Web/Microsoft.Web.Publishing.targets b/eng/msbuild/web/Web/Microsoft.Web.Publishing.targets deleted file mode 100644 index 1e2935b6..00000000 --- a/eng/msbuild/web/Web/Microsoft.Web.Publishing.targets +++ /dev/null @@ -1,4802 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - <_WPPVersion>2.0 - <_WPPSupports>IISExpress;AspNetCompileMerge - <_WPPWebPublishMethodSupports>WebMSDeployPublish;WebPackagePublish - - - - <_WPPSupports Include="$(_WPPSupports)" /> - - - - - - <_IISApplicationPool Include="Clr4IntegratedAppPool"> - ASP.NET v4.0 - - <_IISApplicationPool Include="Clr4ClassicAppPool"> - ASP.NET v4.0 Classic - - <_IISApplicationPool Include="Clr2IntegratedAppPool"> - DefaultAppPool - - <_IISApplicationPool Include="Clr2ClassicAppPool"> - Classic .NET AppPool - - - - - - - - - - obj\ - $(BaseIntermediateOutputPath)\ - - - - $(BaseIntermediateOutputPath)$(Configuration)\ - $(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\ - $(IntermediateOutputPath)\ - - - - - - - $(MSBuildProjectDirectory) - $(WebPublishPipelineProjectDirectory) - - $(MSBuildProjectName) - $(MSBuildProjectFile) - $([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(WebPublishPipelineProjectDirectory), $(WebPublishPipelineProjectFile))))) - False - $(WebPublishPipeLineProjectFullPath) - <_WPPDefaultIntermediateOutputPathPathRoot Condition="'$(WebPublishPipelineProjectDirectory)' != '$(MSBuildProjectDirectory)'">$(MSBuildProjectDirectory)\ - False - True - <_LocalDBVersionToUseForSqlExpress Condition="'$(_LocalDBVersionToUseForSqlExpress)' == ''">11.0 - <_PublishProfileSet>False - True - - - <_WPPDefaultIntermediateOutputPath>$(IntermediateOutputPath) - <_WPPDefaultIntermediateOutputPath Condition="'$([System.IO.Path]::IsPathRooted($(IntermediateOutputPath)))' == 'False'">$(_WPPDefaultIntermediateOutputPathPathRoot)$(IntermediateOutputPath) - <_WPPDefaultIntermediateOutputFullPath>$([System.IO.Path]::GetFullPath($(_WPPDefaultIntermediateOutputPath))) - - - - - <_PublishProfileExtension>$([System.IO.Path]::GetExtension($(PublishProfile))) - <_PublishProfileDirectory>$([System.IO.Path]::GetDirectoryName($(PublishProfile))) - <_PublishProfileName>$([System.IO.Path]::GetFileNameWithoutExtension($(PublishProfile))) - <_PublishProfileSet>True - WebPublish - - - - $(WebPublishPipelineProjectDirectory)\$(AppDesignerFolder)\PublishProfiles - $(WebPublishPipelineProjectDirectory)\My Project\PublishProfiles - $(WebPublishPipelineProjectDirectory)\Properties\PublishProfiles - $(WebPublishPipelineProjectDirectory)\__profiles - - - - $(_PublishProfileName) - - - - $(PublishProfileRootFolder)\$(PublishProfileName).pubxml - $(WebPublishPipelineProjectDirectory)\App_Data\PublishProfiles\$(PublishProfileName).pubxml - - - - $(PublishProfile) - $(WebPublishPipelineProjectDirectory)\$(PublishProfile) - $(PublishProfileRootFolder)\$(PublishProfile) - - - - $([System.IO.Path]::GetFileNameWithoutExtension($(WebPublishProfileFile))) - <_PublishProfileName>$(PublishProfileName) - - - - <_WebPublishProfileFileWillBeImported>false - <_WebPublishProfileFileWillBeImported Condition="'$(EnableWebPublishProfileFile)'=='true' And '$(WebPublishProfileFile)' != '' And Exists($(WebPublishProfileFile))">true - - - - - - $([System.IO.Path]::ChangeExtension($(WebPublishProfileFile), '.wpp.targets')) - $([System.IO.Path]::ChangeExtension($(WebPublishProfileFile), '.parameters.xml')) - - - - - - - - - - $(WebPublishPipelineProjectDirectory)\*.wpp.targets - $(WebPublishPipelineProjectDirectory)\..\wpp.deploysettings.targets - - - - - - - - - <_WPPCleanTargets> - $(_WPPCleanTargets); - CleanWebsitesPackage; - CleanWebsitesWPPAllFilesInSingleFolder; - CleanWebPublishPipelineIntermediateOutput; - - - $(CleanDependsOn); - $(_WPPCleanTargets); - - - - - - OnlyFilesToRunTheApp - - - - - AllFilesInProjectFolder - $(WebPublishPipelineProjectDirectory) - $(AlternativeProjectDirectory) - - - - - True - - True - False - - - true - - False - $(ExcludeApp_Data) - False - - - True - False - - - <_CleanWPPIfNeedTo Condition="'$(_CleanWPPIfNeedTo)' == '' And '$(CleanWPPAllFilesInSingleFolder)'!=''">$(CleanWPPAllFilesInSingleFolder) - False - - False - - True - - True - False - True - True - True - True - True - False - - False - - True - False - CSAutoParameterize - $(_WPPDefaultIntermediateOutputPath)$(AutoParameterizationWebConfigConnectionStringsIntermediateOutput) - - <_WPPLastBuildInfoIntermediateOutput Condition="'$(_WPPLastBuildInfoIntermediateOutput)'==''">_WPPLastBuildInfo.txt - <_WPPLastBuildInfoLocation Condition="'$(_WPPLastBuildInfoLocation)'==''">$(_WPPDefaultIntermediateOutputPath)$(_WPPLastBuildInfoIntermediateOutput) - - True - InsertAdditionalCS - $(_WPPDefaultIntermediateOutputPath)$(InsertAdditionalWebCofigConnectionStringsIntermediateOutput) - System.Data.SqlClient - True - - - - - - - Database - $(_WPPDefaultIntermediateOutputPath)$(DatabaseDeployIntermediateRelativePath) - <_WebConfigsToAutoParmeterizeCsTransformOutputParametersFile>$(AutoParameterizationWebConfigConnectionStringsLocation).parameters.xml - - - Package - $(DeployDefaultTarget) - 2 - False - $(DeployOnBuildDefault) - false - false - false - - - False - - - - - - <_MSDeployUserAgentSource Condition=" '$(BuildingInsideVisualStudio)' != 'true'">$(VisualStudioVersion):CmdLine - <_MSDeployUserAgentSource Condition=" '$(BuildingInsideVisualStudio)' == 'true'">$(VisualStudioVersion):PublishDialog - <_MSDeployUserAgent>VS$(_MSDeployUserAgentSource) - - - - - False - - - - - True - False - - <_DeployOnBuild>$(DeployOnBuild) - - <_DeployOnBuild Condition="'$(BuildingInsideVisualStudio)' == 'true'">False - - - - PrepareForRun; - - - - False - True - False - - - - $(PipelineDependsOn); - BeforeBuild; - BuildOnlySettings; - ResolveReferences; - PrepareResourceNames; - ComputeIntermediateSatelliteAssemblies; - GetCopyToOutputDirectoryItems; - _SGenCheckForOutputs; - - - - $(PipelineDependsOn); - Build; - - - - $(PipelineDependsOn); - AfterBuild; - - - - - - - - Web.config - <_ProjectConfigFileExtension>$([System.IO.Path]::GetExtension($(ProjectConfigFileName))) - <_ProjectConfigFilePrefix>$([System.IO.Path]::GetFileNameWithoutExtension($(ProjectConfigFileName))) - - - $(_ProjectConfigFilePrefix).$(Configuration)$(_ProjectConfigFileExtension) - true - False - False - TransformWebConfig - $(_WPPDefaultIntermediateOutputPath)$(TransformWebConfigIntermediateOutput) - <_WebConfigTransformOutputParametersFile>$(TransformWebConfigIntermediateLocation).parameters.xml - - $(_ProjectConfigFilePrefix).$(PublishProfileName)$(_ProjectConfigFileExtension) - - - False - False - true - False - False - ProfileTransformWebConfig - $(_WPPDefaultIntermediateOutputPath)$(ProfileTransformWebConfigIntermediateOutput) - <_ProfileWebConfigTransformOutputParametersFile>$(ProfileTransformWebConfigIntermediateLocation).parameters.xml - - True - - - - - - - - True - False - $(WebProjectOutputDirInsideProjectDefault) - True - False - - - - - - - - $(OutDir)_PublishedWebsites\$(WebPublishPipelineProjectName)_Package - $(_WPPDefaultIntermediateOutputPath)Package - $(WebPublishPipelineProjectName).zip - Default Web Site - _deploy - $(WebPublishPipelineProjectName) - $(DefaultMSDeployDestinationSite)/$(DefaultMSDeployDestinationApplicationName)$(DefaultMsDeployAltSuffix) - $(DefaultMSDeployDestinationApplicationName)$(DefaultMsDeployAltSuffix) - - - - - - - True - - $(DesktopBuildPackageLocation) - $(PackageLocation) - $(PackageFileName)\$(DefaultPackageFileName) - $(DefaultPackageOutputDir)\$(DefaultPackageFileName) - $(PackageLocation) - $(DefaultPackageOutputDir) - $(_WPPDefaultIntermediateOutputPath)Package - - true - True - True - False - $(TargetFrameworkVersion) - - - - - True - $(DefaultPackageOutputDir)\Log - False - - Info - <_CreatePackage Condition="'$(_CreatePackage)'==''" >True - <_UseDefaultLinkExtensionValue>False - <_UseDefaultLinkExtensionValue Condition="'$(PackageEnableLinks)'=='' and '$(PackageDisableLinks)'==''">True - - AppPoolExtension;ContentExtension;CertificateExtension - AppPoolExtension - ContentExtension;CertificateExtension - $(MSBuildProjectDirectory)\Parameters.xml - $(WebPublishPipelineProjectDirectory)\Parameters.xml - False - $(WebPublishPipelineProjectName) - $(DeployParameterPrefix)IIS Web Application Name - $(DeployParameterPrefix)IIS Web Application Pool Name - $(DeployParameterPrefix)Add write permission to App_Data Folder - $(DeployParameterPrefix)Web Application Physical Path - - True - - - - - - - SqlConnectionString - SqlCommandVariable - - - :Connect;:!!;:Exit;:Help;:r;:Quit; - True - - - MultipleActiveResultSets;App; - - - False - <_PackageTempDir Condition ="'$(_PackageTempDir)' == '' ">$(PackageTempRootDir)\PackageTmp - $(_PackageTempDir) - False - - - - True - - - False - - - - - - - - - - - - - - - - $(WebPublishPipelineProjectDirectory)$(DefaultMsDeployAltSuffix) - - <_DestinationIisAppPhysicalPath>$(DeployIisAppPhysicalPath) - <_DestinationIisAppPhysicalPath Condition="'$(_DestinationIisAppPhysicalPath)'==''">$(DefaultDeployIisAppPhysicalPath) - - - - $(PackageEnableLinks) - $(PackageDisableLinks) - - False - - - - - - -100 - -80 - -70 - -60 - -55 - -50 - -40 - 60 - 100 - - - - - - - <_MSDeployPackageFile Include="$(PackageFileName)" /> - <_MSDeployArchiveDir Include="$(PackageArchiveRootDir)\Archive" /> - <_MSDeployPackageLocation Condition="$(PackageAsSingleFile)" Include="$(PackageFileName)" /> - <_MSDeployPackageLocation Condition="!$(PackageAsSingleFile)" Include="@(_MSDeployArchiveDir)" /> - - - - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).deploy.cmd') - - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).SourceManifest.xml') - $(UseMsdeployExe) - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).Package.Parameters.xml') - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).Publish.Parameters.xml') - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).deploy.cmd') - @(_MSDeployPackageLocation->'%(FileName).deploy-readme.txt') - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).deploy-readme.txt') - @(_MSDeployPackageLocation->'%(RootDir)%(Directory)%(FileName).SetParameters.xml') - $(GenerateSampleParametersValueLocationDefault) - @(_MSDeployPackageLocation->'%(FileName).SetParameters.xml') - - - - - - Unknown - - - Unknown - - - - - - - - - - False - Unknown - Run - Default - - - - - - - - False - Unknown - Run - Default - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unknown - - - - - - - - - - - - - - - - - - - $(MSBuildThisFileDirectory)\CollectFiles\$(FilesToIncludeForPublish).targets - $(MSBuildThisFileDirectory)\CollectFiles\Microsoft.Web.Publishing.$(FilesToIncludeForPublish).targets - - - - - - - - $(MSBuildThisFileDirectory)\Deploy\$(WebPublishMethod).targets - $(MSBuildThisFileDirectory)\Deploy\Microsoft.Web.Publishing.Deploy.$(WebPublishMethod).targets - - - - - - - False - True - - - - Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets - - - - - - - - - - - Deploy\Microsoft.Web.Publishing.MSDeploy.Common.targets - - - - - - - - - - - - - - - - - - - - ExcludeApp_Data - - - - - - - - - - - - - - - - - - ExcludeGeneratedDebugSymbol - - - - - - - @(ExcludeXmlAssemblyFilesDependsOn); - - - - - - ExcludeXmlAssemblyFiles - - - - - - - <_EnableCleanOnBuildForMvcViews Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='' ">true - - - - <_PublishTempFolderNamesToCleanup Include="Database;TransformWebConfig;CSAutoParameterize;InsertAdditionalCS;ProfileTransformWebConfig;Package" /> - - - - - - - - - - - true - $(ExcludeFilesByExtensionDependsOn); - .tt;.settings - - - - - - - - <_ExtToExclude>%(WebPublishExtnsionsToExcludeItem.Identity) - - - - - - - ExcludeFilesByExtension - - - - - - - - - - $(ExcludeFilesFromPackageDependsOn); - ExcludeApp_Data; - ExcludeGeneratedDebugSymbol; - ExcludeXmlAssemblyFiles; - ExcludeFilesByExtension; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - - - - - - - - - - - - - - - - - - - - %(_ImportedMSDeployDeclareParameters.DefaultValue) - $(UserParametersFileParametersPriority) - - - - - - - - - - - %(_ImportedProfileMSDeployDeclareParameters.DefaultValue) - $(UserProfileParametersFileParametersPriority) - - - - - - - - - - - - - - - %(MSDeployParameterValue.ParameterValue) - %(MSDeployParameterValue.ParameterValue) - %(MSDeployParameterValue.Description) - %(MSDeployParameterValue.ParameterPriority) - - - - - %(MSDeployParameterValue.ParameterValue) - %(MSDeployParameterValue.Description) - %(MSDeployParameterValue.ParameterPriority) - - - - - - - - $(ValidateGlobalSettingsDependsOn); - GetProjectWebProperties; - - - - - - - - - - - - - - - - $(ValidateGlobalPackageSettingDependsOn); - GetProjectWebProperties; - ValidateGlobalSettings; - - - - - - - - - - - - <_CheckPackageLocation Condition="$(PackageAsSingleFile)">$(PackageFileName) - <_CheckPackageLocation Condition="!$(PackageAsSingleFile)">$(PackageArchiveRootDir) - <_CheckPackageLocationArchiveDir Condition="!$(PackageAsSingleFile)">$(PackageArchiveRootDir)\Archive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_CleanWPPIfNeedToDependsOn> - $(_CleanWPPIfNeedToDependsOn); - ValidateGlobalSettings; - - - - - <_IsSameWPPBuildInfoAsLastBuildInfo>True - <_IsSameWPPBuildInfoAsLastBuildInfo Condition="!Exists($(_WPPLastBuildInfoLocation))">False - - - - - <_WPPCurrentBuildInfo>$(_WPPCurrentBuildInfo);PlatformName=$(PlatformName);Configuration=$(Configuration);WPPAllFilesInSingleFolder=$([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)));WebPublishProfileFile=$(WebPublishProfileFile) - - - - <_WPPCurrentBuildInfoItems Include="$(_WPPCurrentBuildInfo)" /> - - - - - - - - <_IsSameWPPBuildInfoAsLastBuildInfo Condition="'@(_WPPLastBuildInfo)' != '@(_WPPCurrentBuildInfoItems)'" >False - - - - - - - <_WPPLastBuildInfoLocationDirectory>$([System.IO.Path]::GetDirectoryName($(_WPPLastBuildInfoLocation))) - - - - - - - - - - - - - $(OnBeforePipelineCollectFilesPhase); - _CleanWPPIfNeedTo; - - - $(OnAfterPipelineCollectFilesPhase); - ExcludeFilesFromPackage; - ImportParametersFiles; - - - $(OnBeforePipelineCollectFilesPhase); - $(PipelineCollectFilesPhaseDependsOn); - WPPCopyWebApplicaitonPipelineCircularDependencyError; - ProcessItemToExcludeFromDeployment; - GetProjectWebProperties; - ValidateGlobalSettings; - ValidateGlobalPackageSetting; - $(PipelineDependsOn); - $(PublishPipelineCollectFilesCore); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(TransformWebConfigBeforeTargets); - MarkWebConfigAssistFilesAsExclude; - - - $(OnBeforeTransformWebConfig); - $(TransformWebConfigDependsOn); - PreTransformWebConfig; - TransformWebConfigCore; - ParameterizeTransformWebConfigCore; - PostTransformWebConfig; - - - - - - - - - - - - - - - $(OnBeforeCollectWebConfigsToTransform); - $(CollectWebConfigsToTransformDependsOn); - PipelineCollectFilesPhase; - - - - - - - - $([System.String]::new($(WebPublishPipelineProjectDirectory)\$([System.IO.Path]::GetDirectoryName($([System.String]::new(%(DestinationRelativePath)))))).TrimEnd('\'))\$(ProjectConfigTransformFileName) - $(TransformWebConfigIntermediateLocation)\original - $(TransformWebConfigIntermediateLocation)\assist - $(TransformWebConfigIntermediateLocation)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_WebConfigsToTransformOuputs Include="@(WebConfigsToTransform->'%(TransformOutputFile)')" /> - - - - - - - - - - - CollectWebConfigsToTransform; - - - - - - - - <_TempNoTransformWebConfigToTransform Include="@(WebConfigsToTransform)" - Condition="!Exists(%(TransformFile))" /> - - - - - - <_WebConfigsToTransformOuputsDirectories>@(_WebConfigsToTransformOuputs->'%(RootDir)%(Directory)') - - - - <_WebConfigsToTransformOuputsDirectories Include="$(_WebConfigsToTransformOuputsDirectories)" /> - - - - <_MessageArguments>@(WebConfigsToTransform->'%(DestinationRelativePath)', ', ') - - - - - - - - <_WebConfigTransformOutput>@(WebConfigsToTransform->'%(TransformOutputFile)') - <_WebConfigTransformOutput Condition="$(UseParameterizeToTransformWebConfig)">$(_WebConfigTransformOutput);$(_WebConfigTransformOutputParametersFile) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreTransformWebConfig; - - - - - - - - - - - - - - - - PreTransformWebConfig; - - - - - - - - - - - - - - - - - - - - - - - - - TransformWebConfigCore; - ParameterizeTransformWebConfigCore; - - - - - - - - - - - - - - - - - - - - - - %(_ImportParameterizeTransformWebConfig.DefaultValue) - $(UserWebConfigParametersPriority) - - - - - - - - - - - - - - $(OnBeforeMarkWebConfigAssistFilesAsExclude); - $(MarkWebConfigAssistFilesAsExcludeDependsOn); - - - - - - - <_AllProjectConfigsInFiles Include="@(FilesForPackagingFromProject)" - Condition="'%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ProjectConfigFileName)'" /> - - - - - - - - - - - - - - True - - - - - - - - - - - - $(ProfileTransformWebConfigBeforeTargets); - MarkWebConfigAssistFilesAsExclude; - - - $(ProfileTransformWebConfigAfterTargets); - TransformWebConfig; - - - $(OnBeforeProfileTransformWebConfig); - $(ProfileTransformWebConfigDependsOn); - PreProfileTransformWebConfig; - ProfileTransformWebConfigCore; - ParameterizeProfileTransformWebConfigCore; - PostProfileTransformWebConfig; - - - - - - - - - - - - - - - $(OnBeforeCollectFilesForProfileTransformWebConfigs); - $(CollectFilesForProfileTransformWebConfigsDependsOn); - PipelineCollectFilesPhase; - - - - - - - - - $(WebPublishPipelineProjectDirectory)\$([System.IO.Path]::GetDirectoryName($([System.String]::new(%(DestinationRelativePath)))))\$(ProjectProfileTransformFileName) - $(ProfileTransformWebConfigIntermediateLocation)\original - $(ProfileTransformWebConfigIntermediateLocation)\assist - $(ProfileTransformWebConfigIntermediateLocation)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_ProfileWebConfigsToTransformOuputs Include="@(ProfileWebConfigsToTransform->'%(TransformOutputFile)')" /> - - - - - - - - - - CollectFilesForProfileTransformWebConfigs; - - - - - - - - - <_TempNoTrnasformFileForProfileWebConfigsToTransform Include="@(ProfileWebConfigsToTransform)" - Condition="!Exists(%(TransformFile))" /> - - - - - - - <_ProfileWebConfigsToTransformOuputsDirectories>@(_ProfileWebConfigsToTransformOuputs->'%(RootDir)%(Directory)') - - - - <_ProfileWebConfigsToTransformOuputsDirectories Include="$(_ProfileWebConfigsToTransformOuputsDirectories)" /> - - - - - <_MessageArguments>@(ProfileWebConfigsToTransform->'%(DestinationRelativePath)', ', ') - - - - - - - - <_ProfileWebConfigTransformOutput>@(ProfileWebConfigsToTransform->'%(TransformOutputFile)') - <_ProfileWebConfigTransformOutput Condition="$(UseParameterizeToProfileTransformWebConfig)">$(_ProfileWebConfigTransformOutput);$(_ProfileWebConfigTransformOutputParametersFile) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreProfileTransformWebConfig; - - - - - - - - - - - - - - PreProfileTransformWebConfig; - - - - - - - - - - - - - - - - - - - - - - - - ProfileTransformWebConfigCore; - ParameterizeProfileTransformWebConfigCore; - - - - - - - - - - - - - - - - - - - - - - - %(_ImportParameterizeProfileTransformWebConfig.DefaultValue) - $(UserWebConfigParametersPriority) - - - - - - - - - - - - - ProfileTransformWebConfig; - - - - - - <_WebConfigsToInsertAdditionalCS Include="@(FilesForPackagingFromProject)" - Condition="$(InsertAdditionalWebConfigConnectionStringOnlyInRoot) - And '%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ProjectConfigFileName)' - And !%(FilesForPackagingFromProject.Exclude) - And '%(DestinationRelativePath)' == '$(ProjectConfigFileName)'"> - $(InsertAdditionalWebCofigConnectionStringsLocation)\original - $(InsertAdditionalWebCofigConnectionStringsLocation)\assist - $(InsertAdditionalWebCofigConnectionStringsLocation)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_WebConfigsToInsertAdditionalCS Include="@(FilesForPackagingFromProject)" - Condition="!$(InsertAdditionalWebConfigConnectionStringOnlyInRoot) - And '%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ProjectConfigFileName)' - And !%(FilesForPackagingFromProject.Exclude)"> - $(InsertAdditionalWebCofigConnectionStringsLocation)\original - $(InsertAdditionalWebCofigConnectionStringsLocation)\assist - $(InsertAdditionalWebCofigConnectionStringsLocation)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_WebConfigsToInsertAdditionalCSOuputFiles Include="@(_WebConfigsToInsertAdditionalCS->'%(TransformOutputFile)')"> - - - - - <_WebConfigsToInsertAdditionalCSOuputDirectories>@(_WebConfigsToInsertAdditionalCSOuputFiles->'%(RootDir)%(Directory)') - <_WebConfigsToInsertAdditionalCSOuput>@(_WebConfigsToInsertAdditionalCS->'%(TransformOutputFile)'); - - - - <_WebConfigsToInsertAdditionalCSOuputDirectories Include="$(_WebConfigsToInsertAdditionalCSOuputDirectories)" /> - - - - - - - - - - - - - - - - <_InsertAdditionalConnectionStringNamesPrepare Include="@(_ConnectionStringsToInsert)"> - %(_ConnectionStringsToInsert.Identity) - %(_ConnectionStringsToInsert.Identity)_ConnectionString - - <_InsertAdditionalConnectionStringNames Include="@(_InsertAdditionalConnectionStringNamesPrepare)"> - - <add - name="%(_InsertAdditionalConnectionStringNamesPrepare.ConnectionStringName)" - connectionString="%(_InsertAdditionalConnectionStringNamesPrepare.ConnectionString)" - providerName="$(InsertAdditionalWebConfigConnectionStringProviderName)" - xdt:Transform="InsertIfMissing" - xdt:Locator="Match(name)" - xdt:SupressWarnings="True" - /> - - - - - - - - <_WebConfigsToInsertAdditionalCS_Transform><?xml version="1.0"?> - <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> - <connectionStrings xdt:Transform="InsertIfMissing" xdt:SupressWarnings="True"> - @(_InsertAdditionalConnectionStringNames->'%(TransformXMLFragement)', '') - </connectionStrings> - </configuration> - - - - - - - - - - - - - - - - - - - - - - <_WebConfigToInsertAdditionalCS_Identity>%(_WebConfigsToInsertAdditionalCS.Identity) - <_WebConfigToInsertAdditionalCS_TransformOutputFile>%(_WebConfigsToInsertAdditionalCS.TransformOutputFile) - <_WebConfigsToInsertAdditionalCS_TransformScope>%(_WebConfigsToInsertAdditionalCS.TransformScope) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforeInsertAdditionalWebCofigConnectionStrings); - $(InsertAdditionalWebCofigConnectionStringsDependsOn); - TransformWebConfig; - ProfileTransformWebConfig; - PreInsertAdditionalWebCofigConnectionStrings; - InsertAdditionalWebCofigConnectionStringsCore; - PostInsertAdditionalWebCofigConnectionStrings; - - - $(InsertAdditionalWebCofigConnectionStringsBeforeTargets); - PreAutoParameterizationWebConfigConnectionStrings; - AutoParameterizationWebConfigConnectionStrings; - - - - - - - - - - - - PipelineTransformPhase; - - - - - - <_WebConfigsToAutoParmeterizeCS Include="@(FilesForPackagingFromProject)" - Condition="'%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ProjectConfigFileName)' And !%(FilesForPackagingFromProject.Exclude)"> - $(AutoParameterizationWebConfigConnectionStringsLocation)\original - $(AutoParameterizationWebConfigConnectionStringsLocation)\assist - $(AutoParameterizationWebConfigConnectionStringsLocation)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_WebConfigsToAutoParmeterizeCSOuputFiles Include="@(_WebConfigsToAutoParmeterizeCS->'%(TransformOutputFile)')"> - - - - - <_WebConfigsToAutoParmeterizeCSOuputDirectories>@(_WebConfigsToAutoParmeterizeCSOuputFiles->'%(RootDir)%(Directory)') - <_WebConfigsToAutoParmeterizeCSOuput>@(_WebConfigsToAutoParmeterizeCS->'%(TransformOutputFile)');$(_WebConfigsToAutoParmeterizeCsTransformOutputParametersFile) - - - - <_WebConfigsToAutoParmeterizeCSOuputDirectories Include="$(_WebConfigsToAutoParmeterizeCSOuputDirectories)" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(DeployParameterPrefix)%24(name)-$(ProjectConfigFileName) Connection String - %24(name) $(_PublishLocalizedString_WebConfigConnectionStringParameterDescription) - - - - - - - - - - - - - - - - - - - - - - - - - <_AutoParameterizeCSTransform>$(_AutoParameterizeCSTransformWithDefaultValue) - <_AutoParameterizeCSTransform Condition="$(AutoParameterizationWebConfigCSNoDefaultValue)">$(_AutoParameterizeCSTransformNoDefaultValue) - <_AutoParameterizeCSUseXPath Condition="'$(_AutoParameterizeCSUseXPath)'==''">True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %(_ImportAutoParameterizeCSTransformWebConfig.DefaultValue) - $(VsWebConfigAutoCsParametersPriority) - - - - - - - - - - - - $(OnBeforeAutoParameterizationWebConfigConnectionStrings); - $(AutoParameterizationWebConfigConnectionStringsDependsOn); - PipelineTransformPhase; - PreAutoParameterizationWebConfigConnectionStrings; - AutoParameterizationWebConfigConnectionStringsCore; - PostAutoParameterizationWebConfigConnectionStrings; - - - - - - - - - - - - True - - - $(OnBeforePipelineTransformPhase); - $(PipelineTransformPhaseDependsOn); - PipeLineCollectFilesPhase; - TransformWebConfig; - ProfileTransformWebConfig; - InsertAdditionalWebCofigConnectionStrings; - MarkWebConfigAssistFilesAsExclude; - - - - - - - - - - - - - - - - - - - - - - $(PipelineMsdeploySpecificTransformPhaseBeforeTargets); - CopyAllFilesToSingleFolderForMsdeploy; - PipelineCopyAllFilesToOneFolderForMsdeploy; - PipelineDeployPhase; - - - $(OnBeforePipelineMsdeploySpecificTransformPhase); - $(PipelineMsdeploySpecificTransformPhaseDependsOn); - InsertAdditionalWebCofigConnectionStrings; - PreAutoParameterizationWebConfigConnectionStrings; - AutoParameterizationWebConfigConnectionStrings; - - - - - - - - - - - - - - - - - - - - - - <_WPPCopyWebApplicationDependsOn> - $(OnBefore_WPPCopyWebApplication); - $(_WPPCopyWebApplicationDependsOn); - CleanWebProjectOutputDir; - PipelineTransformPhase; - - - - - - <_AllExtraFilesUnderProjectOuputFolder Include="$(WebProjectOutputDir)\**" /> - <_AllExtraFilesUnderProjectOuputFolder - Remove="@(FilesForPackagingFromProject->'$(WebProjectOutputDir)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforePipelinePreDeployCopyAllFilesToOneFolder); - $(PipelinePreDeployCopyAllFilesToOneFolderDependsOn); - PipelineTransformPhase; - CopyAllFilesToSingleFolderForPackage; - - - - - - - - - - - - - - - $(OnBeforeCopyAllFilesToSingleFolderForMsdeploy); - CleanWebsitesWPPAllFilesInSingleFolder; - - - $(OnBeforeCopyAllFilesToSingleFolderForMsdeploy); - $(CopyAllFilesToSingleFolderForMsdeployDependsOn); - - - - - - - <_AllExtraFilesUnderTempFolder Include="$(WPPAllFilesInSingleFolder)\**" /> - <_AllExtraFilesUnderTempFolder - Remove="@(FilesForPackagingFromProject->'$(WPPAllFilesInSingleFolder)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - - - - - - - - - - $(OnBeforePipelineCopyAllFilesToOneFolderForMsdeploy); - $(PipelineCopyAllFilesToOneFolderForMsdeployDependsOn); - PipelineTransformPhase; - CopyAllFilesToSingleFolderForMsdeploy; - - - - - - - - - - - - - - - - - - - - - - _CheckPublishToolsUpToDate - - - - - - - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Inetstp@MajorVersion) - 0 - - - - - - - - - <_DeploymentUseIis Condition="'$(_DeploymentUseIis)'=='' And $(IncludeIisSettings)">$(UseIis) - <_DeploymentUseIis Condition="'$(_DeploymentUseIis)'==''">False - <_DeploymentAsIisApp>$(DeployAsIisApp) - <_DeploymentAsIisApp Condition="$(_DeploymentUseIis)">False - $(UseIis) - False - <_DeploymentUseIISExpressHint>$(UseIISExpress) - <_DeploymentUseIISExpressHint Condition="'$(_DeploymentUseIISExpressHint)'==''">False - - - - - - - - - - - - - - - - - - - - - - - <_Destination_IisServer_IisAppPoolName Condition="'@(_IISApplicationPoolFound)'!=''">%(_IISApplicationPoolFound.DestinationIISApplicationPool) - <_Destination_IisServer_IisAppPoolName Condition="'$(_Destination_IisServer_IisAppPoolName)'==''">$(IisServer_IisAppPoolName) - - - - <_IsRootWebsite>False - <_IsRootWebsite Condition="('$(IisUrl_SiteRelativePath)' == '/')">True - $(DefaultDeployIisRootAppPath) - $(IisServer_IisMajorVersion) - $(LocalIisVersion) - - - - - - - - - - - - - - - - - - - - - - - <_MSDeployInstalledVersionPath Include="@(_MSDeployInstalledVersionPathFromRegistry)"> - $([MSBuild]::GetRegistryValue('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\%(_MSDeployInstalledVersionPathFromRegistry.Identity)', 'InstallPath')) - $([MSBuild]::GetRegistryValue('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\%(_MSDeployInstalledVersionPathFromRegistry.Identity)', 'Version')) - - <_MSDeployInstalledVersions Include="@(_MSDeployInstalledVersionPath)" Condition="'%(_MSDeployInstalledVersionPath.InstallPath)'!='' And '%(_MSDeployInstalledVersionPath.DllVersionString)'!=''" > - $([System.Version]::New(%(_MSDeployInstalledVersionPath.DllVersionString)).Major).$([System.Version]::New(%(_MSDeployInstalledVersionPath.DllVersionString)).Minor) - - - - - - - - - <_MSDeployInstalledVersions Remove="@(_NeedtoRemove_MSDeployInstalledVersions)" /> - - - - - - - - <_DefaultMSDeployMaxVersion>0 - <_DefaultMSDeployMaxVersion Condition="'%(_MSDeployInstalledVersions.Identity)' != ''">$([System.Math]::Max($([System.Convert]::ToUInt32('$(_DefaultMSDeployMaxVersion)')),$([System.Convert]::ToUInt32('%(_MSDeployInstalledVersions.Identity)')))) - - - - - - <_SelectedMSDeployMaxVersion Include="@(_MSDeployInstalledVersions)" - Condition="'%(_MSDeployInstalledVersions.Identity)' =='$(_DefaultMSDeployMaxVersion)' " /> - - - - - <_SelectedMSDeployPath Include="@(_MSDeployInstalledVersions)" - Condition="'%(_MSDeployInstalledVersions.InstallPath)' =='$(MSDeployPath)' " /> - - - <_MSDeployVersionsToTry>@(_SelectedMSDeployPath->'%(DllVersion)') - - - - - <_MSDeployVersionsToTry Condition="'$(_MSDeployVersionsToTry)' == ''">@(_SelectedMSDeployMaxVersion->'%(DllVersion)') - @(_SelectedMSDeployMaxVersion->'%(InstallPath)') - - - - - - - - - - - - - - PipelineCopyAllFilesToOneFolderForMsdeploy; - ImportPublishingParameterValues; - PipelineMsdeploySpecificTransformPhase; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_PackageFileLocation Include="$(PackageFileName)" /> - - - - <_PackageRoot Condition="$(PackageAsSingleFile)">@(_PackageFileLocation->'%(RootDir)%(Directory)') - <_PackageRoot Condition="!$(PackageAsSingleFile)">$(PackageArchiveRootDir) - - - - - - - - - $(OnBeforeCopyAllFilesToSingleFolderForPackage); - CleanWebsitesWPPAllFilesInSingleFolder; - - - $(OnBeforeCopyAllFilesToSingleFolderForPackage); - $(CopyAllFilesToSingleFolderForPackageDependsOn); - - - - - - - <_AllExtraFilesUnderTempFolder Include="$(WPPAllFilesInSingleFolder)\**" /> - <_AllExtraFilesUnderTempFolder - Remove="@(FilesForPackagingFromProject->'$(WPPAllFilesInSingleFolder)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - - - - - - - - - - - - - - - - $(BeforeAddIis7ToSourceManifest); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - - - - - - - - - - $(_MSDeployIisUrlSource_AppHostConfigPath) - - - - - - - - - - - - - - - - - $(BeforeAddDeclareParametersItemsForIis7); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - - - - - - - - - - ProviderPath - AppHostConfig - ^$(_EscapeRegEx_MSDeployIisUrlSource_AppHostConfigPath)$ - $(DeployParameterIISAppNameDescription) - $(_MSDeployIisAppPathIIS7) - $(_MSDeployIisAppPathIIS7) - IisApp - $(VsIisAppParametersPriority) - - - - DeploymentObjectAttribute - application - application[@applicationPool='$(IisServer_IisAppPoolName)']/@applicationPool - $(DeployParameterIISAppPoolNameDescription) - $(_Destination_IisServer_IisAppPoolName) - $(_Destination_IisServer_IisAppPoolName) - - $(VsIisAppParametersPriority) - - - - - - - - - - - - - - - - - - $(BeforeAddIis6ToSourceManifest); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - - - - - - - - - - - $(_MSDeployIisUrlSource_MetakeyPath) - - - - - - - - - - - - - - - - $(BeforeAddDeclareParametersItemsForIis6); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - - - - - - - - - - - - - - - ProviderPath - MetaKey - ^$(_EscapeRegEx_MSDeployIisUrlSource_MetakeyPathSearchPath)$ - $(DeployParameterIISAppNameDescription) - $(_MSDeployIisAppPathIIS6) - $(_MSDeployIisAppPathIIS6) - IisApp - $(VsIisAppParametersPriority) - - - - DeploymentObjectAttribute - metaProperty - metaProperty[@name='AppPoolId' and @value='$(IisServer_IisAppPoolName)']/@value - $(DeployParameterIISAppPoolNameDescription) - $(_Destination_IisServer_IisAppPoolName) - $(_Destination_IisServer_IisAppPoolName) - - $(VsIisAppParametersPriority) - - - - - - - - - - - - - - - - - - - $(BeforeAddIisSettingAndFileContentsToSourceManifest); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - AddContentPathToSourceManifest; - - - - - - - - - - - - - - - - - $(BeforeAddContentPathToSourceManifest); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - AddIis7ToSourceManifest; - AddIis6ToSourceManifest - - - - - - - - - - - - - <_DeployManagedRuntimeVersion Condition="'$(DeployManagedRuntimeVersionNumeric)' != '' And ($(DeployManagedRuntimeVersionNumeric) >= '4.0') ">$(DeployManagedRuntimeVersion) - - <_DeployManagedRuntimeVersion Condition="'$(DeployManagedRuntimeVersionNumeric)' == '' And '$(DeployManagedRuntimeVersion)'!=''">$(DeployManagedRuntimeVersion) - - - - - - $(_MSDeployDirPath_FullPath) - $(_DeployManagedRuntimeVersion) - $(DeployEnable32bitAppOnWin64) - $(DeployManagedPipelineMode) - managedRuntimeVersion;enable32bitAppOnWin64;managedPipelineMode - - - - $(_MSDeployDirPath_FullPath) - - - - - $(_MSDeployDirPath_FullPath) - Directory - setAclResourceType - - - - - $(_MSDeployDirPath_FullPath) - anonymousAuthenticationUser - Directory - setAclUser;setAclResourceType - - - - - $(_MSDeployDirPath_FullPath)\App_Data - Write - Directory - setAclResourceType;setAclAccess - - - - - - - - - - - - - - - - - $(BeforeAddIisAndContentDeclareParametersItems); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - AddDeclareParametersItemsForContentPath; - - - - - - - - - - - - - - - - - $(BeforeAddDeclareParametersItemsForContentPath); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - AddDeclareParametersItemsForIis7; - AddDeclareParametersItemsForIis6; - - - - - - - - <_DestinationContentPath>$(_DestinationIisAppPhysicalPath) - - <_DestinationContentPath Condition="($(DestinationUseIis) or $(_DeploymentAsIisApp)) And ($(DestinationIisVersion) < '7') And ('$(_MSDeployIisAppPathIIS6)'!= '') " >$(_MSDeployIisAppPathIIS6) - - <_DestinationContentPath Condition="($(DestinationUseIis) or $(_DeploymentAsIisApp)) And ($(DestinationIisVersion) >= '7') And ('$(_MSDeployIisAppPathIIS7)' !='')">$(_MSDeployIisAppPathIIS7) - - <_MsDeployParameterNameForContentPath>$(DeployParameterIISAppName) - <_MsDeployParameterNameForContentPath Condition="$(_DeploymentUseIis) And (!$(DestinationUseIis))">$(DeployParameterIISAppPhysicalPath) - <_MsDeployParameterTagForContentPath>PhysicalPath - <_MsDeployParameterTagForContentPath Condition="$(_DeploymentAsIisApp)">IisApp - <_MsDeployParameterDefaultValueForContentPath>$(_DestinationContentPath) - <_MsDeployParameterExcludeSetParameterForContentPath>False - <_MsDeployParameterPhysicalFolderForSetAcl>{$(_MsDeployParameterNameForContentPath)} - <_MsDeployParameterPhysicalFolderAppDataForSetAcl>{$(_MsDeployParameterNameForContentPath)}/App_Data - - - - - - - - - - - - - - - - - ProviderPath - IisApp - ^$(_EscapeRegEx_MSDeployDirPath)$ - $(DeployParameterIISAppNameDescription) - $(_MsDeployParameterDefaultValueForContentPath) - $(_DestinationContentPath) - $(_MsDeployParameterTagForContentPath) - $(VsIisAppParametersPriority) - $(_MsDeployParameterExcludeSetParameterForContentPath) - - - - ProviderPath - contentPath - ^$(_EscapeRegEx_MSDeployDirPath)$ - $(DeployParameterIISAppPhysicalPathDescription) - $(_MsDeployParameterDefaultValueForContentPath) - $(_DestinationContentPath) - $(_MsDeployParameterTagForContentPath) - $(VsContentPathParametersPriority) - $(_MsDeployParameterExcludeSetParameterForContentPath) - - - - - - - - ProviderPath - setAcl - ^$(_EscapeRegEx_MSDeployDirPath)$ - $(DeployParameterIISAppPhysicalPathDescription) - $(_MsDeployParameterDefaultValueForContentPath) - $(_DestinationContentPath) - - $(_MsDeployParameterExcludeSetParameterForContentPath) - $(VsSetAclPriority) - - - - ProviderPath - setAcl - ^$(_EscapeRegEx_MSDeployDirPath)\\App_Data$ - Add write permission to App_Data folder - {$(_MsDeployParameterNameForContentPath)}/App_Data - $(_DestinationContentPath)/App_Data - Hidden - $(VsSetAclPriority) - True - - - - - - - - - - - - - - - - - - - - - - $(BeforeWriteItemsToSourceManifest); - $(WriteItemsToSourceManifestDependsOn); - AddIisSettingAndFileContentsToSourceManifest; - - - - - - - - - - - - - - - - - - - - - - - $(BeforeAddDeclareParametersItems); - AddIisAndContentDeclareParametersItems; - AddDeclareParametersItemsForDatabaseScript; - - - - - <_PublishDefaultVDirectoryPath>$(RemoteSitePhysicalPath) - <_PublishDefaultVDirectoryPath Condition="'$(_PublishDefaultVDirectoryPath)'==''">$(_DestinationIisAppPhysicalPath) - - - - - - - - <_MSBuildReplaceRuleItemMSBuildProjectDirectory Include="$(WebPublishPipelineProjectDirectory)" /> - - - - - - - - - DestinationVirtualDirectory - .* - ^$(_EscapeRegExMSBuildProjectDirectory)$ - $(DeployParameterIISAppPhysicalPathDescription) - $(_DestinationIisAppPhysicalPath) - - $(_PublishDefaultVDirectoryPath) - PhysicalPath - $(VsDestinationVDirParametersPriority) - - - - - - - - - - - - - <_GatherParamsDependsOn> - $(_GatherParamsDependsOn); - GetProjectWebProperties; - ImportParametersFiles; - TransformWebConfig; - ProfileTransformWebConfig; - AutoParameterizationWebConfigConnectionStrings; - AddDeclareParametersItems; - ImportPublishingParameterValues; - - - - - - - - - - - - - - - - - - - - - - <_MSDeployDirPath Include="$(WPPAllFilesInSingleFolder)" /> - - - - - - - - - - - - - - - - - - - <_MSDeployDirPath_FullPath>@(_MSDeployDirPath->'%(FullPath)') - <_MSDeployIisAppPathIIS7>$(DeployIisAppPath) - <_MSDeployIisAppPathIIS6>$(DeployIisAppPath) - <_MSDeployIisAppPathIIS7 Condition="'$(_MSDeployIisAppPathIIS7)'==''">$(DefaultDeployIisAppPath) - <_MSDeployIisAppPathIIS6 Condition="'$(_MSDeployIisAppPathIIS6)'==''">$(DefaultDeployIisAppPath) - - - - <_MSDeploySourceManifest Include="$(PackageSourceManifest)" /> - <_MSDeployParametersFile Include="$(PackageParametersFile)" /> - <_MSDeploySampleParametersValue Condition="$(GenerateSampleDeployScript)" Include="$(GenerateSampleParametersValueLocation)" /> - <_MSDeployGenerateSampleDeployScriptReadMeLocation Condition="$(GenerateSampleDeployScript)" Include="$(GenerateSampleDeployScriptReadMeLocation)" /> - - - - - - - GenerateMsDeployManifestSettings; - - - - - - - - - - - - - - - - - - - - - - - - - - - - GenerateMsDeployManifestSettings; - CleanWebsitesPackageCore; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GenerateMsDeployManifestSettings; - - - - - - - - - - - - - - - - - - $(OnAfterGenerateMsdeployManifestFiles); - AddDeclareParametersItems; - CheckAndCleanMSDeployPackageIfNeeded; - - - $(GenerateMsdeployManifestFilesDependsOn); - PipelineCopyAllFilesToOneFolderForMsdeploy; - GenerateMsDeployManifestSettings; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - dirPath - $(_Escaped_WPPAllFilesInSingleFolder)\\App_Data$ - Source - - - - - dirPath - $(_Escaped_DestinationContentPath)\\App_Data$ - Destination - - - - - - - - - - - - $(OnBeforePackageUsingManifest); - $(PackageUsingManifestDependsOn); - GetMSDeployInstalledVersionPath; - GenerateMsDeployManifestSettings; - GenerateMsdeployManifestFiles; - GenerateSkipRuleForAppData; - - - - - - - - manifest - @(_MSDeploySourceManifest->'%(FullPath)') - - archiveDir - @(_MSDeployArchiveDir->'%(FullPath)') - package - @(_MSDeployPackageFile->'%(FullPath)') - True - - - - - - - - - $(PackageSourceRoot) - $(DeployEncryptKey) - $(IisServer_WebServerAppHostConfigDirectory) - $(IisServer_WebServerManifest) - $(IisServer_WebServerDirectory) - - - - $(PackageDestinationRoot) - $(DeployEncryptKey) - False - - - - - - - - - - - - - - - - <_VsPackageParametersFile> - <_VsPackageParametersFile Condition="$(UseDeclareParametersXMLInMsDeploy)">$(PackageParametersFile) - - - - <_Package_MsDeployDeclareParameters Include="@(MsDeployDeclareParameters)" Condition="!$(UseDeclareParametersXMLInMsDeploy)" /> - - - - - - - - - - - - - - - - - - - - - - - GetMSDeployInstalledVersionPath; - GenerateMsDeployManifestSettings; - GenerateMsdeployManifestFiles; - Package; - - - - - - - - - - - manifest - @(_MSDeploySourceManifest->'%(FullPath)') - package - @(_MSDeployPackageFile->'%(FullPath)') - archiveDir - @(_MSDeployArchiveDir->'%(FullPath)') - - auto - - - - - - - - $(TestDeployPackageToLocalSourceRoot) - $(DeployEncryptKey) - - - - $(TestDeployPackageToLocalDestinationRoot) - $(DeployEncryptKey) - False - - - - - - - - - - - - - - - - - - - true - Basic - - WMSVC - - GetProjectWebProperties; - ValidateGlobalSettings; - - - - - - <_UseWMSVC>false - <_UseWMSVC Condition="'$(MSDeployPublishMethod)'=='WMSVC'">true - <_UseRemoteAgent>false - <_UseRemoteAgent Condition="'$(MSDeployPublishMethod)'=='RemoteAgent'">true - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LinkExtensioninfo.xml - HttpCertConfigExtension;CertificateExtension;FrameworkConfigExtension - ContentExtension - - - - - - - - - false - - GenerateGlobalPublishSetting; - _CheckAzureNet46Support; - ValidateGlobalPackageSetting; - GenerateMsDeployManifestSettings; - GenerateMsdeployManifestFiles; - GenerateSkipRuleForAppData; - ImportPublishingParameterValues; - PipelineMsdeploySpecificTransformPhase; - Package; - - - - - - - - - - - - manifest - @(_MSDeploySourceManifest->'%(FullPath)') - package - @(_MSDeployPackageFile->'%(FullPath)') - archiveDir - @(_MSDeployArchiveDir->'%(FullPath)') - - - auto - - - - DoNotDeleteRule - - - - <_MSDeploySourceWebServerAppHostConfigDirectory>$(IisServer_WebServerAppHostConfigDirectory) - <_MSDeploySourceWebServerManifest>$(IisServer_WebServerManifest) - <_MSDeploySourceWebServerDirectory>$(IisServer_WebServerDirectory) - - - - - - - - - - - - <_PublishMsDeployServiceUrl>$(MsDeployServiceUrl) - <_PublishMsDeployServiceUrl Condition="('$(MSDeployPublishMethod)'=='INPROC')"> - - - - iisApp - contentPath - - - - - - $(MSDeployPublishSourceRoot) - $(DeployEncryptKey) - $(_MSDeploySourceWebServerAppHostConfigDirectory) - $(_MSDeploySourceWebServerManifest) - $(_MSDeploySourceWebServerDirectory) - - - - $(MSDeployPublishDestinationRoot) - $(_PublishMsDeployServiceUrl) - $(UserName) - $(Password) - $(DeployEncryptKey) - False - $(AuthType) - $(_MSDeployDestinationWebServerAppHostConfigDirectory) - $(_MSDeployDestinationWebServerManifest) - $(_MSDeployDestinationWebServerDirectory) - - - - - - - WebConfigEncryptProvider - $(MSDeployWebConfigEncryptProvider) - - - - - - - - - false - - - - - - - - - - - - <_VsPublishParametersFile> - <_VsPublishParametersFile Condition="$(UseDeclareParametersXMLInMsDeploy) and '$(_VsPublishParametersFile)'==''">$(PublishParametersFile) - - - - - - <_VsPublish_MsDeployDeclareParameters Include="@(MsDeployDeclareParameters)" Condition="!$(UseDeclareParametersXMLInMsDeploy) And !$(CreatePackageOnPublish)" /> - - - - - - - - <_EnableRuleList>$(MsDeployDoNotDeleteRule) - <_EnableRuleList Condition="'$(_EnableRuleList)'=='' and '$(EnableMSDeployAppOffline)'=='true'">AppOffline - <_EnableRuleList Condition="'$(_EnableRuleList)'!='' and '$(EnableMSDeployAppOffline)'=='true'">$(_EnableRuleList);AppOffline - <_EnableRuleList Condition="'$(_EnableRuleList)'=='' and '$(MSDeployEnableWebConfigEncryptRule)'=='true'">EncryptWebConfig - <_EnableRuleList Condition="'$(_EnableRuleList)'!='' and '$(MSDeployEnableWebConfigEncryptRule)'=='true'">$(_EnableRuleList);EncryptWebConfig - - - - - - - - - - - $(OnBeforeValidatePublishProfileSettings); - $(ValidatePublishProfileSettingsDependsOn); - - - - - - - - - - - - - - - - - - - - - - - - MSDeployPublish; - - - - - - - - - - - - Package; - - - - - - - - - - - - $(WebPublishDependsOn); - ValidatePublishProfileSettings; - - - $(WebPublishDependsOn); - Web$(WebPublishMethod)Publish; - - - - - - - - - - - - $(OnBeforePipelineDeployPhase); - $(PipelineDeployPhaseDependsOn); - $(DeployTarget); - - - $(PipelineDeployPhaseAfterTargets); - - - - - - - - - - - - - - - - - - $(DbDacFxPreviewDependsOn); - GetMSDeployInstalledVersionPath; - - - $(DbDacFxPreviewDependsOn); - LocalDbDacFxPreview; - - - $(DbDacFxPreviewDependsOn); - RemoteDbDacFxPreview; - - - - - - - - - - - - $(DbFullSqlPreviewDependsOn); - GetMSDeployInstalledVersionPath; - - - - - - - <_MsDeployDbFullSqlPreviewSourceNoPath Remove="@(_MsDeployDbFullSqlPreviewSourceNoPath)" /> - - - - - - - - <_MsDeployDbFullSqlPreviewSource Remove="@(_MsDeployDbFullSqlPreviewSource)" /> - <_MsDeployDbFullSqlPreviewSource Include="@(_MsDeployDbFullSqlPreviewSourceNoPath)"> - $(_MsDeployDBFullSqlPreviewSourceConnectionString) - - - <_MsDeployDbFullSqlPreviewDestination Remove="@(_MsDeployDbFullSqlPreviewDestination)" /> - <_MsDeployDbFullSqlPreviewDestination Include="DbFullSql"> - $(_MsDeployDbFullSqlPreviewOutputPath) - - - - - - - - - - - - - - - - $(ValidateDbDacFxPreviewSettingsDependsOn); - GetMSDeployInstalledVersionPath; - - - - - - - - - - - - - - - - - - - - - - - - - $(LocalDbDacFxPreviewDependsOn); - GetMSDeployInstalledVersionPath; - ValidateDbDacFxPreviewSettings; - - - - - - - <_MsDeployDbDacFxPreviewPreSourceOptions Remove="@(_MsDeployDbDacFxPreviewPreSourceOptions)" /> - <_MsDeployDbDacFxPreviewPreSourceOptions Include="DbDacFx"> - False - includeData - - - - - - - - - - <_MsDeployDbDacFxPreviewSource Remove="@(_MsDeployDbDacFxPreviewSource)" /> - <_MsDeployDbDacFxPreviewSource Include="DbDacFx"> - $([System.IO.Path]::GetFullPath($(_MsDeployDbDacFxPreviewDacpacFile))) - - - <_MsDeployDbDacFxPreviewDestination Remove="@(_MsDeployDbDacFxPreviewDestination)" /> - <_MsDeployDbDacFxPreviewDestination Include="DbDacFx"> - $(_MsDeployDbDacFxPreviewDestinationConnectionString) - Script - - - - - - - - - - - - - - - - $(RemoteDbDacFxPreviewDependsOn); - GetMSDeployInstalledVersionPath; - GenerateGlobalPublishSetting; - ValidateDbDacFxPreviewSettings; - _DetectDbDacFxProvider; - - - - - <_PublishMsDeployServiceUrl>$(MsDeployServiceUrl) - <_PublishMsDeployServiceUrl Condition="('$(MSDeployPublishMethod)'=='INPROC')"> - - - - - <_MsDeployDbDacFxPreviewPreSourceOptions Remove="@(_MsDeployDbDacFxPreviewPreSourceOptions)" /> - <_MsDeployDbDacFxPreviewPreSourceOptions Include="DbDacFx"> - False - includeData - - - - - - - - - - - - - - - <_MsDeployRemoteDbDacFxPreviewSource Remove="@(_MsDeployRemoteDbDacFxPreviewSource)" /> - <_MsDeployRemoteDbDacFxPreviewSource Include="DbDacFx"> - $([System.IO.Path]::GetFullPath($(_MsDeployDbDacFxPreviewDacpacFile))) - - - <_MsDeployRemoteDbDacFxPreviewDestination Remove="@(_MsDeployRemoteDbDacFxPreviewDestination)" /> - <_MsDeployRemoteDbDacFxPreviewDestination Include="DbDacFx"> - $(_MsDeployDbDacFxPreviewDestinationConnectionString) - $(_PublishMsDeployServiceUrl) - $(UserName) - $(Password) - $(AuthType) - $(_MSDeployDestinationWebServerAppHostConfigDirectory) - $(_MSDeployDestinationWebServerManifest) - $(_MSDeployDestinationWebServerDirectory) - Script - - - - - - - - - - - - - - - - - - - - - - - - <_PublishMsDeployServiceUrl>$(MsDeployServiceUrl) - <_PublishMsDeployServiceUrl Condition="('$(MSDeployPublishMethod)'=='INPROC')"> - <_MSDeployPublishSourceType>dbDacFx - - - - <_MsDeploySourceProviderSetting Remove="@(_MsDeploySourceProviderSetting)" /> - <_MsDeploySourceProviderSetting Include="$(_MSDeployPublishSourceType)"> - $(_PublishMsDeployServiceUrl) - $(UserName) - $(Password) - $(AuthType) - - <_DbDacFxDestinationPathesToPublish Include="$([MSBuild]::Escape($(_MsDeployDbDacFxPreviewDestinationConnectionString)))" /> - - - - - - - - - - - - - - - - - - - - - $(WebPublishPipelineProjectDirectory)\apiapp.json - - - - - - - - true - - - \ No newline at end of file diff --git a/eng/msbuild/web/Web/Microsoft.Web.Publishing/ImportAfter/Microsoft.Web.AzureAD.Publishing.targets b/eng/msbuild/web/Web/Microsoft.Web.Publishing/ImportAfter/Microsoft.Web.AzureAD.Publishing.targets deleted file mode 100644 index 3076855a..00000000 --- a/eng/msbuild/web/Web/Microsoft.Web.Publishing/ImportAfter/Microsoft.Web.AzureAD.Publishing.targets +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - $(PipelineTransformPhaseDependsOn);_TransformWebConfigForAzureAuthentication - - - - <_WebConfigTransformFolderForAzureAuthentication>$(_WPPDefaultIntermediateOutputPath)WebConfigTransformFolderForAzureAuthentication - - - <_WebConfigsToTransformForAzureAuthentication Include="@(FilesForPackagingFromProject)" - Condition="'%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ProjectConfigFileName)' - And !%(FilesForPackagingFromProject.Exclude) - And '%(DestinationRelativePath)' == '$(ProjectConfigFileName)'"> - $(_WebConfigTransformFolderForAzureAuthentication)\original - $(_WebConfigTransformFolderForAzureAuthentication)\assist - $(_WebConfigTransformFolderForAzureAuthentication)\transformed\%(DestinationRelativePath) - $([System.IO.Path]::GetFullPath($(WPPAllFilesInSingleFolder)\%(DestinationRelativePath))) - - <_WebConfigsToTransformForAzureAuthenticationOuputFiles Include="@(_WebConfigsToTransformForAzureAuthentication->'%(TransformOutputFile)')"> - - - - - <_WebConfigsToTransformForAzureAuthenticationOuputDirectories>@(_WebConfigsToTransformForAzureAuthenticationOuputFiles->'%(RootDir)%(Directory)') - <_WebConfigsToTransformForAzureAuthenticationOuput>@(_WebConfigsToTransformForAzureAuthentication->'%(TransformOutputFile)'); - - - - <_WebConfigsToTransformForAzureAuthenticationOuputDirectories Include="$(_WebConfigsToTransformForAzureAuthenticationOuputDirectories)" /> - - - - - - - - - - - - - - - - $(ADAppIDUri) - - - - - false - <_RemoveCertificateValidationTransform Condition="'$(RemoveCertValidationElement)' == 'true'"><certificateValidation certificateValidationMode="None" xdt:Transform="Remove" /> - <_RemoveExistingAudienceUrisTransform Condition="'$(PreserveExistingAudienceUris)' != 'true'"><add xdt:Transform="RemoveAll" /> - - - - <_ReplaceRealmAndAudienceUriAppSetting Condition="'$(ADWebAPIBased)'!='true' And '$(ADUsesOwinOrOpenIdConnect)'!='true'"> - <appSettings> - <add key="ida:AudienceUri" - value="{% parameter='AD_AudienceUriAppSetting' xpathlocator='key' description='AD Audience Uri App Setting' defaultValue='%24(value)' tags='AD_AudienceUriAppSetting' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - <add key="ida:Realm" - value="{% parameter='AD_RealmAppSetting' xpathlocator='key' description='AD Realm App Setting' defaultValue='%24(value)' tags='AD_RealmAppSetting' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - <add key="ida:FederationMetadataLocation" - value="{% parameter='AD_MetadataUrl' xpathlocator='key' description='AD MetadataUrl App Setting' defaultValue='%24(value)' tags='AD_MetadataUrlAppSetting' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADClientID Condition="'$(ADClientAPPID)'!='' And '$(ADUsesOwinOrOpenIdConnect)'!='true'"> - <appSettings> - <add key="ida:ClientID" - value="{% parameter='AD_ClientID' xpathlocator='key' description='AD Client Application ID' defaultValue='%24(value)' tags='AD_ClientAPPID' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADClientPassword Condition="'$(ADClientPassword)'!='' And '$(ADUsesOwinOrOpenIdConnect)'!='true'"> - <appSettings> - <add key="ida:Password" - value="{% parameter='AD_ClientPassword' xpathlocator='key' description='AD Client Password' defaultValue='%24(value)' tags='AD_Password' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADWebAPIAudienceAppSetting Condition="'$(ADWebAPIBased)'=='true' And '$(ADUsesOwinOrOpenIdConnect)'!='true'"> - <appSettings> - <add key="ida:Audience" - value="{% parameter='AD_WebAPI_Audience' xpathlocator='key' description='AD Web API Audience' defaultValue='%24(value)' tags='AD_WebAPI_Audience' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADWIFArtifacts Condition="'$(ADWebAPIBased)'!='true' And '$(ADUsesOwinOrOpenIdConnect)'!='true'"> - <system.identityModel> - <identityConfiguration> - $(_RemoveCertificateValidationTransform) - <audienceUris> - $(_RemoveExistingAudienceUrisTransform) - <add - value="APPIDUri" - xdt:Transform="Insert" xdt:SupressWarnings="True" /> - </audienceUris> - - <audienceUris> - <add - value="{% token='%24(value)' parameter='AD_%24(value)' xpathlocator='value' description='AD AppIDUri' defaultValue='%24(value)' tags='ADrealmUri' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" /> - </audienceUris> - - </identityConfiguration> - </system.identityModel> - <system.identityModel.services> - <federationConfiguration> - <wsFederation - realm="{% xpathlocator='requireHttps' parameter='AD_APPIDUri' description='AD AppIDUri' defaultValue='%24(realm)' tags='ADAPPIDUri' %}" - xdt:Transform="SetTokenizedAttributes(realm)" xdt:SupressWarnings="True" /> - <wsFederation - issuer="{% xpathlocator='requireHttps' parameter='AD_Issuer' description='AD Issuer' defaultValue='%24(issuer)' tags='ADISSUER' %}" - xdt:Transform="SetTokenizedAttributes(issuer)" xdt:SupressWarnings="True" /> - </federationConfiguration> - </system.identityModel.services> - - <_ReplaceADClientIDDev14 Condition="'$(ADClientAPPID)'!='' And '$(ADUsesOwinOrOpenIdConnect)'=='true'"> - <appSettings> - <add key="ida:ClientId" - value="{% parameter='AD_ClientID' xpathlocator='key' description='AD Client Application ID' defaultValue='%24(value)' tags='AD_ClientAPPID' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADClientPasswordDev14 Condition="'$(ADClientPassword)'!='' And '$(ADUsesOwinOrOpenIdConnect)'=='true'"> - <appSettings> - <add key="ida:ClientSecret" - value="{% parameter='AD_ClientPassword' xpathlocator='key' description='AD Client Password' defaultValue='%24(value)' tags='AD_Password' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADTenantIdDev14 Condition="'$(ADTenantId)'!='' And '$(ADUsesOwinOrOpenIdConnect)'=='true'"> - <appSettings> - <add key="ida:TenantId" - value="{% parameter='AD_TenantId' xpathlocator='key' description='AD Tenant Id' defaultValue='%24(value)' tags='AD_TenantId' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADDomainDev14 Condition="'$(ADDomain)'!='' And '$(ADUsesOwinOrOpenIdConnect)'=='true'"> - <appSettings> - <add key="ida:Domain" - value="{% parameter='AD_Domain' xpathlocator='key' description='AD Domain' defaultValue='%24(value)' tags='AD_Domain' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - <_ReplaceADPostLogoutRedirectUriDev14 Condition="'$(ADPostLogoutRedirectUri)'!='' And '$(ADUsesOwinOrOpenIdConnect)'=='true'"> - <appSettings> - <add key="ida:PostLogoutRedirectUri" - value="{% parameter='AD_PostLogoutRedirectUri' xpathlocator='key' description='AD PostLogoutRedirectUri' defaultValue='%24(value)' tags='AD_PostLogoutRedirectUri' %}" - xdt:Transform="SetTokenizedAttributes(value)" xdt:SupressWarnings="True" xdt:Locator="Match(key)"/> - </appSettings> - - - - - - $(ADClientAPPID) - - - $(ADIssuer) - - - https://login.windows.net/$(ADDomain)/FederationMetadata/2007-06/FederationMetadata.xml - - - $(ADClientPassword) - - - $(ADAppIDUri) - - - $(ADAppIDUri) - - - $(ADAppIDUri) - - - $(ADTenantId) - - - $(ADDomain) - - - $(ADPostLogoutRedirectUri) - - - - - - - - - <_WebConfigsToTransformForAzureAuthentication_Identity>%(_WebConfigsToTransformForAzureAuthentication.Identity) - <_WebConfigsToTransformForAzureAuthentication_TransformOutputFile>%(_WebConfigsToTransformForAzureAuthentication.TransformOutputFile) - <_WebConfigsToTransformForAzureAuthentication_TransformScope>%(_WebConfigsToTransformForAzureAuthentication.TransformScope) - - - - - - - - <_WebConfigsToTransformForAzureAuthenticationOutputFolder>$(_WPPDefaultIntermediateOutputPath)AzureAuthentication - <_WebConfigsToTransformForAzureAuthenticationOutputParametersFile>$(_WebConfigsToTransformForAzureAuthenticationOutputFolder)\TransformForAzureAuthentication.parameters.xml - - - - - - - - - - - - - %(_ImportAutoParameterizeAzureAuthenticationWebConfig.DefaultValue) - $(VsWebConfigAutoCsParametersPriority) - - - - - - - - - - - - - - - - - - <_TransformWebConfigForAzureAuthenticationDependsOn> - _TransformWebConfigForAzureAuthenticationCore; - _PostTransformWebConfigForAzureAuthentication; - - - - - - - - - - \ No newline at end of file diff --git a/eng/msbuild/web/Web/Microsoft.Web.XmlTransform.dll b/eng/msbuild/web/Web/Microsoft.Web.XmlTransform.dll deleted file mode 100644 index 95914431..00000000 Binary files a/eng/msbuild/web/Web/Microsoft.Web.XmlTransform.dll and /dev/null differ diff --git a/eng/msbuild/web/Web/Microsoft.WebSite.Publishing.targets b/eng/msbuild/web/Web/Microsoft.WebSite.Publishing.targets deleted file mode 100644 index 36e086a9..00000000 --- a/eng/msbuild/web/Web/Microsoft.WebSite.Publishing.targets +++ /dev/null @@ -1,530 +0,0 @@ - - - - - - - - - - - - - <_WebProjectType>WebSite - $([System.IO.Path]::GetTempPath())WebSitePublish\$([System.IO.Path]::GetFileName($(MSBuildProjectDirectory)))-$(MSBuildProjectDirectory.GetHashCode()) - $(OutputPath)\ - $(OutputPath) - - $(OutDir)\ - - - - $(OutputPath)obj\ - $(BaseIntermediateOutputPath)\ - - - - $(BaseIntermediateOutputPath)$(Configuration)\ - $(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\ - $(IntermediateOutputPath)\ - - - - - - - - - - - - $(OutDir) - $(IntermediateOutputPath)AspnetCompileMerge\source - <_WDPSourceWebPhysicalPath>$(SourceWebPhysicalPath) - $(IntermediateOutputPath)TempBuildDir - <_ExcludeAppOffline Condition="'$(_ExcludeAppOffline)' ==''">true - <_ExcludeWebInfo Condition="'$(_ExcludeWebInfo)' ==''">true - - - - <_SkipHiddenItems Condition="'$(_SkipHiddenItems)'==''">true - - - - - - - - - - - - True - $(SourceWebProjectPath) - - - - false - - - - - - <_WDOutputPathItem Condition="'$(WDOutDir)' != '' and !HasTrailingSlash('$(WDOutDir)')" Include="$(WDOutDir)\_PublishedWebsites\$(MSBuildProjectName)\"/> - <_WDOutputPathItem Condition="'$(WDOutDir)' != '' and HasTrailingSlash('$(WDOutDir)')" Include="$(WDOutDir)_PublishedWebsites\$(MSBuildProjectName)\"/> - <_WDOutputPathItem Condition="'$(WDOutDir)' == ''" Include="$(OutputPath)"/> - <_WDPSourceWebPathItem Include="$(_WDPSourceWebPhysicalPath)"/> - <_KeyFile Include="$(KeyFile)"/> - - - - - Any CPU - - - - $(WDOutDir)\_PublishedWebsites\$(MSBuildProjectName)\ - <_FullSourceWebDir>$(_WDPSourceWebPhysicalPath) - <_FullKeyFile Condition="'$(KeyFile)' != ''">@(_KeyFile->'%(FullPath)') - - - - - <_AspNetCompilerFixedNames Condition="'$(UseMerge)' != 'true'">$(UseFixedNames) - <_AspNetCompilerKeyContainer Condition="'$(UseMerge)' != 'true'">$(KeyContainer) - <_AspNetCompilerMetabasePath Condition="'$(UseMetabasePath)' == 'true'">$(SourceWebMetabasePath) - <_AspNetCompilerSourceWebPath Condition="'$(UseMetabasePath)' != 'true'">$(_FullSourceWebDir) - <_AspNetCompilerVirtualPath Condition="'$(UseMetabasePath)' != 'true'">$(SourceWebVirtualPath) - - - - true - - - - false - - - - $(MSBuildProjectDirectory) - $(MSBuildProjectDirectory)$(DefaultMsDeployAltSuffix) - AllFilesInProjectFolder - - True - False - $(OutputPath)\Parameters.xml - <_WDPDefaultIntermediateOutputPathPathRoot Condition="'$(_WPPDefaultIntermediateOutputPathPathRoot)' == ''">$(OutputPath)\ - - - - <_WDPDefaultIntermediateOutputPath>$(IntermediateOutputPath) - <_WDPDefaultIntermediateOutputPath Condition="!$([System.IO.path]::IsPathRooted($(IntermediateOutputPath)))">$(_WDPDefaultIntermediateOutputPathPathRoot)$(IntermediateOutputPath) - - - - - - - - - - - - $(PreTransformWebConfigDependsOn); - FixupTransformAssistFilesAsExclude; - - - - - <_AllExecutableUnderBin Include="$(SourceWebPhysicalPath)\Bin\*.dll;$(SourceWebPhysicalPath)\Bin\*.exe"/> - - - - - - <_WDP_IdentifyTransformAssistFile>web\.[^\\\.]*\.config$ - - - - - - - - - - - - - - - Web.config - - - - - - - - - $(WDTargetDir) - - - <_FullSourceWebDir>$(_FullSourceWebDir) - - - - - - - - <_WebFiles> - - False - Unknown - Run - Default - - - - - - - - - - - - - - - <_OriginalSourceWebPhysicalFullPath>$([System.IO.Path]::GetFullPath($(SourceWebPhysicalPath))) - <_OriginalSourceWebPhysicalFullPath Condition="!HasTrailingSlash('$(_OriginalSourceWebPhysicalFullPath)')">$(_OriginalSourceWebPhysicalFullPath)\ - - - - - <_WebFilesExclude Include="%(ExcludeFromBuild.Identity)"> - $([System.String]::new(%(ExcludeFromBuild.FullPath)).SubString($(_OriginalSourceWebPhysicalFullPath.Length))) - - <_WebFilesExclude Condition="'%(SourceRelativePath)'==''"> - %(Identity) - - <_WebFilesNoMetadata Remove="%(_WebFilesExclude.SourceRelativePath)" Condition="'%(_WebFilesExclude.SourceRelativePath)' != ''"/> - - - - - - - - <_WebFiles Include="$([System.IO.Path]::Combine($(_WDPSourceWebPhysicalPath), %(_WebFilesNoMetadata.Identity)))" > - %(_WebFilesNoMetadata.Identity) - - - - - - <_WebFiles Remove="@(ExcludeFromBuild)" /> - - - - - - - - - - - <_WDPAllExtraFilesUnderTempFolder Condition="'$(CopyBeforeBuildTargetPath)' != ''" Include="$(CopyBeforeBuildTargetPath)\**" /> - <_WDPAllExtraFilesUnderTempFolder - Remove="@(FilesForPackagingFromProject->'$(CopyBeforeBuildTargetPath)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - <_AspNetCompilerSourceWebPath>$(CopyBeforeBuildTargetPath) - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _PrepareForBuild; - ResolveProjectReferences; - _ResolveAssemblyReferencesWithRefreshFile; - ResolveReferences; - _CopyBeforeBuild; - - _CopyBeforeBuild - - - - - - - <_WDPOutputFiles> - - False - Unknown - Run - Default - - - - - - <_TempDirFullPath>$(MSBuildProjectDirectory)\$(TempBuildDir) - - - - - - - - - - - - - - <_WDPOutputFiles Include="@(_WDPOutputFilesNoMetadata)" > - %(_WDPOutputFilesNoMetadata.Identity) - - - - - - - - - <_CopyToOutputDirDependsOn> - $(_CopyToOutputDirDependsOn); - CoreCopyToOutputDir; - CleanTempBuildDir - - - - - - - - - <_WDPAllExtraFilesUnderTargetDir Condition="'$(WDTargetDir)' != ''" Include="$(WDTargetDir)\**" /> - <_WDPAllExtraFilesUnderTargetDir - Remove="@(_WDPOutputFiles->'$(WDTargetDir)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - - - - - - - - - <_BuiltProjectOutputGroupOutput Include="$(WDTargetDir)**\*.*"/> - - %(_BuiltProjectOutputGroupOutput.SubFolder)%(_BuiltProjectOutputGroupOutput.RecursiveDir)%(Filename)%(Extension) - - - - - diff --git a/eng/msbuild/web/Web/Powershell/1.0.1/default-publish.ps1 b/eng/msbuild/web/Web/Powershell/1.0.1/default-publish.ps1 deleted file mode 100644 index 1f720165..00000000 --- a/eng/msbuild/web/Web/Powershell/1.0.1/default-publish.ps1 +++ /dev/null @@ -1,101 +0,0 @@ -[cmdletbinding(SupportsShouldProcess=$true)] -param($publishProperties, $packOutput, $nugetUrl) - -# to learn more about this file visit http://go.microsoft.com/fwlink/?LinkId=524327 -$publishModuleVersion = '1.0.1' -function Get-VisualStudio2015InstallPath{ - [cmdletbinding()] - param() - process{ - $keysToCheck = @('hklm:\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0', - 'hklm:\SOFTWARE\Microsoft\VisualStudio\14.0', - 'hklm:\SOFTWARE\Wow6432Node\Microsoft\VWDExpress\14.0', - 'hklm:\SOFTWARE\Microsoft\VWDExpress\14.0' - ) - [string]$vsInstallPath=$null - - foreach($keyToCheck in $keysToCheck){ - if(Test-Path $keyToCheck){ - $vsInstallPath = (Get-itemproperty $keyToCheck -Name InstallDir -ErrorAction SilentlyContinue | select -ExpandProperty InstallDir -ErrorAction SilentlyContinue) - } - - if($vsInstallPath){ - break; - } - } - - $vsInstallPath - } -} - -$vsInstallPath = Get-VisualStudio2015InstallPath -$publishModulePath = "{0}Extensions\Microsoft\Web Tools\Publish\Scripts\{1}\" -f $vsInstallPath,'1.0.1' - -if(!(Test-Path $publishModulePath)){ - $publishModulePath = "{0}VWDExpressExtensions\Microsoft\Web Tools\Publish\Scripts\{1}\" -f $vsInstallPath,'1.0.1' -} - -$defaultPublishSettings = New-Object psobject -Property @{ - LocalInstallDir = $publishModulePath -} - -function Enable-PackageDownloader{ - [cmdletbinding()] - param( - $toolsDir = "$env:LOCALAPPDATA\Microsoft\Web Tools\Publish\package-downloader-$publishModuleVersion\", - $pkgDownloaderDownloadUrl = 'http://go.microsoft.com/fwlink/?LinkId=524325') # package-downloader.psm1 - process{ - if(get-module package-downloader){ - remove-module package-downloader | Out-Null - } - - if(!(get-module package-downloader)){ - if(!(Test-Path $toolsDir)){ New-Item -Path $toolsDir -ItemType Directory -WhatIf:$false } - - $expectedPath = (Join-Path ($toolsDir) 'package-downloader.psm1') - if(!(Test-Path $expectedPath)){ - 'Downloading [{0}] to [{1}]' -f $pkgDownloaderDownloadUrl,$expectedPath | Write-Verbose - (New-Object System.Net.WebClient).DownloadFile($pkgDownloaderDownloadUrl, $expectedPath) - } - - if(!$expectedPath){throw ('Unable to download package-downloader.psm1')} - - 'importing module [{0}]' -f $expectedPath | Write-Output - Import-Module $expectedPath -DisableNameChecking -Force - } - } -} - -function Enable-PublishModule{ - [cmdletbinding()] - param() - process{ - if(get-module publish-module){ - remove-module publish-module | Out-Null - } - - if(!(get-module publish-module)){ - $localpublishmodulepath = Join-Path $defaultPublishSettings.LocalInstallDir 'publish-module.psm1' - if(Test-Path $localpublishmodulepath){ - 'importing module [publish-module="{0}"] from local install dir' -f $localpublishmodulepath | Write-Verbose - Import-Module $localpublishmodulepath -DisableNameChecking -Force - $true - } - } - } -} - -try{ - - if (!(Enable-PublishModule)){ - Enable-PackageDownloader - Enable-NuGetModule -name 'publish-module' -version $publishModuleVersion -nugetUrl $nugetUrl - } - - 'Calling Publish-AspNet' | Write-Verbose - # call Publish-AspNet to perform the publish operation - Publish-AspNet -publishProperties $publishProperties -packOutput $packOutput -} -catch{ - "An error occurred during publish.`n{0}" -f $_.Exception.Message | Write-Error -} \ No newline at end of file diff --git a/eng/msbuild/web/Web/Powershell/1.0.1/filesystem.pubxml b/eng/msbuild/web/Web/Powershell/1.0.1/filesystem.pubxml deleted file mode 100644 index 16003111..00000000 --- a/eng/msbuild/web/Web/Powershell/1.0.1/filesystem.pubxml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - FileSystem - wwwroot - $(OutDir)\$(Configuration)\PublishOutput - False - - \ No newline at end of file diff --git a/eng/msbuild/web/Web/Powershell/1.0.1/package.pubxml b/eng/msbuild/web/Web/Powershell/1.0.1/package.pubxml deleted file mode 100644 index cb3cab5e..00000000 --- a/eng/msbuild/web/Web/Powershell/1.0.1/package.pubxml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Package - wwwroot - $(OutDir)\$(Configuration)\MSDeployPackage\$(MSBuildProjectName).zip - Default Web Site - - \ No newline at end of file diff --git a/eng/msbuild/web/Web/Powershell/1.0.1/publish-module.psm1 b/eng/msbuild/web/Web/Powershell/1.0.1/publish-module.psm1 deleted file mode 100644 index ba97dc69..00000000 --- a/eng/msbuild/web/Web/Powershell/1.0.1/publish-module.psm1 +++ /dev/null @@ -1,658 +0,0 @@ -[cmdletbinding(SupportsShouldProcess=$true)] -param() - -$script:AspNetPublishHandlers = @{} - -$global:AspNetPublishSettings = New-Object -TypeName PSCustomObject @{ - MsdeployDefaultProperties = @{ - 'MSDeployUseChecksum'=$false - 'WebRoot'='wwwroot' - 'SkipExtraFilesOnServer'=$true - 'retryAttempts' = 2 - 'EnableMSDeployBackup' = $false - 'DeleteExistingFiles' = $false - 'MSDeployPackageContentFoldername'='website\' - } -} - -function Register-AspnetPublishHandler{ - [cmdletbinding()] - param( - [Parameter(Mandatory=$true,Position=0)] - $name, - [Parameter(Mandatory=$true,Position=1)] - [ScriptBlock]$handler, - [switch]$force - ) - process{ - if(!($script:AspNetPublishHandlers[$name]) -or $force ){ - 'Adding handler for [{0}]' -f $name | Write-Verbose - $script:AspNetPublishHandlers[$name] = $handler - } - elseif(!($force)){ - 'Ignoring call to Register-AspnetPublishHandler for [name={0}], because a handler with that name exists and -force was not passed.' -f $name | Write-Verbose - } - } -} - -function Get-AspnetPublishHandler{ - [cmdletbinding()] - param( - [Parameter(Mandatory=$true,Position=0)] - $name - ) - process{ - $foundHandler = $script:AspNetPublishHandlers[$name] - - if(!$foundHandler){ - throw ('AspnetPublishHandler with name "{0}" was not found' -f $name) - } - - $foundHandler - } -} - -function GetInternal-ExcludeFilesArg{ - [cmdletbinding()] - param( - $publishProperties - ) - process{ - $excludeFiles = $publishProperties['ExcludeFiles'] - foreach($exclude in $excludeFiles){ - if($exclude){ - [string]$objName = $exclude['objectname'] - - if([string]::IsNullOrEmpty($objName)){ - $objName = 'filePath' - } - - $excludePath = $exclude['absolutepath'] - - # output the result to the return list - ('-skip:objectName={0},absolutePath={1}' -f $objName, $excludePath) - } - } - } -} - -function GetInternal-ReplacementsMSDeployArgs{ - [cmdletbinding()] - param( - $publishProperties - ) - process{ - foreach($replace in ($publishProperties['Replacements'])){ - if($replace){ - $typeValue = $replace['type'] - if(!$typeValue){ $typeValue = 'TextFile' } - - $file = $replace['file'] - $match = $replace['match'] - $newValue = $replace['newValue'] - - if($file -and $match -and $newValue){ - $setParam = ('-setParam:type={0},scope={1},match={2},value={3}' -f $typeValue,$file, $match,$newValue) - 'Adding setparam [{0}]' -f $setParam | Write-Verbose - - # return it - $setParam - } - else{ - 'Skipping replacement because its missing a required value.[file="{0}",match="{1}",newValue="{2}"]' -f $file,$match,$newValue | Write-Verbose - } - } - } - } -} - -<# -.SYNOPSIS -Returns an array of msdeploy arguments that are used across different providers. -For example this wil handle useChecksum, appOffline, etc. -This will also add default properties if they are missing. -#> -function GetInternal-SharedMSDeployParametersFrom{ - [cmdletbinding()] - param( - [Parameter(Mandatory=$true,Position=0)] - $publishProperties - ) - process{ - $sharedArgs = New-Object psobject -Property @{ - ExtraArgs = @() - DestFragment = '' - } - - # add default properties if they are missing - foreach($propName in $global:AspNetPublishSettings.MsdeployDefaultProperties.Keys){ - if($publishProperties["$propName"] -eq $null){ - $defValue = $global:AspNetPublishSettings.MsdeployDefaultProperties["$propName"] - 'Adding default property to publishProperties ["{0}"="{1}"]' -f $propName,$defValue | Write-Verbose - $publishProperties["$propName"] = $defValue - } - } - - if($publishProperties['MSDeployUseChecksum'] -eq $true){ - $sharedArgs.ExtraArgs += '-usechecksum' - } - - if($publishProperties['WebPublishMethod'] -eq 'MSDeploy'){ - $offlineArgs = GetInternal-PublishAppOfflineProperties -publishProperties $publishProperties - $sharedArgs.ExtraArgs += $offlineArgs.AdditionalArguments - $sharedArgs.DestFragment += $offlineArgs.DestFragment - - if($publishProperties['SkipExtraFilesOnServer'] -eq $true){ - $sharedArgs.ExtraArgs += '-enableRule:DoNotDeleteRule' - } - } - - if($publishProperties['WebPublishMethod'] -eq 'FileSystem'){ - if($publishProperties['DeleteExistingFiles'] -eq $false){ - $sharedArgs.ExtraArgs += '-enableRule:DoNotDeleteRule' - } - } - - if($publishProperties['retryAttempts']){ - $sharedArgs.ExtraArgs += ('-retryAttempts:{0}' -f ([int]$publishProperties['retryAttempts'])) - } - - if($publishProperties['EncryptWebConfig'] -eq $true){ - $sharedArgs.ExtraArgs += '-EnableRule:EncryptWebConfig' - } - - if($publishProperties['EnableMSDeployBackup'] -eq $false){ - $sharedArgs.ExtraArgs += '-disablerule:BackupRule' - } - - # add excludes - $sharedArgs.ExtraArgs += (GetInternal-ExcludeFilesArg -publishProperties $publishProperties) - # add replacements - $sharedArgs.ExtraArgs += (GetInternal-ReplacementsMSDeployArgs -publishProperties $publishProperties) - - # return the args - $sharedArgs - } -} - -<# -.SYNOPSIS -This will publish the folder based on the properties in $publishProperties - -.EXAMPLE - Publish-AspNet -packOutput $packOutput -publishProperties @{ - 'WebPublishMethod'='MSDeploy' - 'MSDeployServiceURL'='contoso.scm.azurewebsites.net:443';` - 'DeployIisAppPath'='contoso';'Username'='$contoso';'Password'="$env:PublishPwd"} - -.EXAMPLE -Publish-AspNet -packOutput $packOutput -publishProperties @{ - 'WebPublishMethod'='FileSystem' - 'publishUrl'="$publishDest" - } - -.EXAMPLE -Publish-AspNet -packOutput $packOutput -publishProperties @{ - 'WebPublishMethod'='MSDeploy' - 'MSDeployServiceURL'='contoso.scm.azurewebsites.net:443';` -'DeployIisAppPath'='contoso';'Username'='$contoso';'Password'="$env:PublishPwd" - 'ExcludeFiles'=@( - @{'absolutepath'='wwwroot\\test.txt'}, - @{'absolutepath'='wwwroot\\_references.js'} -)} - -.EXAMPLE -Publish-AspNet -packOutput $packOutput -publishProperties @{ - 'WebPublishMethod'='FileSystem' - 'publishUrl'="$publishDest" - 'ExcludeFiles'=@( - @{'absolutepath'='wwwroot\\test.txt'}, - @{'absolutepath'='wwwroot\\_references.js'}) - 'Replacements' = @( - @{'file'='test.txt$';'match'='REPLACEME';'newValue'='updatedValue'}) - } - -Publish-AspNet -packOutput $packOutput -publishProperties @{ - 'WebPublishMethod'='FileSystem' - 'publishUrl'="$publishDest" - 'ExcludeFiles'=@( - @{'absolutepath'='wwwroot\\test.txt'}, - @{'absolutepath'='c:\\full\\path\\ok\\as\\well\\_references.js'}) - 'Replacements' = @( - @{'file'='test.txt$';'match'='REPLACEME';'newValue'='updatedValue'}) - } - -.EXAMPLE -Publish-AspNet -packOutput $packOutput -publishProperties @{ - 'WebPublishMethod'='FileSystem' - 'publishUrl'="$publishDest" - 'EnableMSDeployAppOffline'='true' - 'AppOfflineTemplate'='offline-template.html' - 'MSDeployUseChecksum'='true' -} -#> -function Publish-AspNet{ - [cmdletbinding(SupportsShouldProcess=$true)] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - process{ - if($publishProperties['WebPublishMethodOverride']){ - 'Overriding publish method from $publishProperties[''WebPublishMethodOverride''] to [{0}]' -f ($publishProperties['WebPublishMethodOverride']) | Write-Verbose - $publishProperties['WebPublishMethod'] = $publishProperties['WebPublishMethodOverride'] - } - - if(!([System.IO.Path]::IsPathRooted($packOutput))){ - $packOutput = [System.IO.Path]::GetFullPath((Join-Path $pwd $packOutput)) - } - - $pubMethod = $publishProperties['WebPublishMethod'] - 'Publishing with publish method [{0}]' -f $pubMethod | Write-Output - - # get the handler based on WebPublishMethod, and call it. - &(Get-AspnetPublishHandler -name $pubMethod) $publishProperties $packOutput - } -} - -function Publish-AspNetMSDeploy{ - [cmdletbinding(SupportsShouldProcess=$true)] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - process{ - if($publishProperties){ - $publishPwd = $publishProperties['Password'] - - <# - "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" - -source:IisApp='C:\Users\contoso\AppData\Local\Temp\AspNetPublish\WebApplication1\wwwroot' - -dest:IisApp='vramak4',ComputerName='https://contoso.scm.azurewebsites.net/msdeploy.axd',UserName='$contoso',Password='',IncludeAcls='False',AuthType='Basic' - -verb:sync - -enableRule:DoNotDeleteRule - -enableLink:contentLibExtension - -retryAttempts=2 - -userAgent="VS14.0:PublishDialog:WTE14.0.51027.0" - #> - - $sharedArgs = GetInternal-SharedMSDeployParametersFrom -publishProperties $publishProperties - - # WebRoot is a required property which has a default - $webroot = $publishProperties['WebRoot'] - - $webrootOutputFolder = (get-item (Join-Path $packOutput $webroot)).FullName - $publishArgs = @() - $publishArgs += ('-source:IisApp=''{0}''' -f "$webrootOutputFolder") - $publishArgs += ('-dest:IisApp=''{0}'',ComputerName=''{1}'',UserName=''{2}'',Password=''{3}'',IncludeAcls=''False'',AuthType=''Basic''{4}' -f - $publishProperties['DeployIisAppPath'], - (Get-MSDeployFullUrlFor -msdeployServiceUrl $publishProperties['MSDeployServiceURL']), - $publishProperties['UserName'], - $publishPwd, - $sharedArgs.DestFragment) - $publishArgs += '-verb:sync' - $publishArgs += '-enableLink:contentLibExtension' - $publishArgs += $sharedArgs.ExtraArgs - - $command = '"{0}" {1}' -f (Get-MSDeploy),($publishArgs -join ' ') - - if (! [String]::IsNullOrEmpty($publishPwd)) { - $command.Replace($publishPwd,'{PASSWORD-REMOVED-FROM-LOG}') | Print-CommandString - } - Execute-Command -exePath (Get-MSDeploy) -arguments ($publishArgs -join ' ') - } - else{ - throw 'publishProperties is empty, cannot publish' - } - } -} - -function Escape-TextForRegularExpressions{ - [cmdletbinding()] - param( - [Parameter(Position=0,Mandatory=$true)] - [string]$text - ) - process{ - # TODO: Get code from EscapeTextForRegularExpressions task - $text.Replace('\','\\') - } -} - -function Publish-AspNetMSDeployPackage{ - [cmdletbinding(SupportsShouldProcess=$true)] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - process{ - if($publishProperties){ - $packageDestFilepah = $publishProperties['DesktopBuildPackageLocation'] - - if(!$packageDestFilepah){ - throw ('The package destination property (DesktopBuildPackageLocation) was not found in the publish properties') - } - - if(!([System.IO.Path]::IsPathRooted($packageDestFilepah))){ - $packageDestFilepah = [System.IO.Path]::GetFullPath((Join-Path $pwd $packageDestFilepah)) - } - - # if the dir doesn't exist create it - $pkgDir = ((new-object -typename System.IO.FileInfo($packageDestFilepah)).Directory) - if(!($pkgDir.Exists)) { - $pkgDir.Create() | Out-Null - } - - <# - "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" - -source:IisApp='C:\Users\contoso\AppData\Local\Temp\AspNetPublish\WebApplication1\wwwroot' - -dest:package=c:\temp\path\contosoweb.zip - -verb:sync - -enableRule:DoNotDeleteRule - -enableLink:contentLibExtension - -retryAttempts=2 - #> - - $sharedArgs = GetInternal-SharedMSDeployParametersFrom -publishProperties $publishProperties - - # WebRoot is a required property which has a default - $webroot = $publishProperties['WebRoot'] - - $webrootOutputFolder = (get-item (Join-Path $packOutput $webroot)).FullName - $publishArgs = @() - $publishArgs += ('-source:IisApp=''{0}''' -f "$webrootOutputFolder") - $publishArgs += ('-dest:package=''{0}''' -f $packageDestFilepah) - $publishArgs += '-verb:sync' - $publishArgs += '-enableLink:contentLibExtension' - $packageContentFolder = $publishProperties['MSDeployPackageContentFoldername'] - if(!$packageContentFolder){ $packageContentFolder = 'website' } - $publishArgs += ('-replace:match=''{0}'',replace=''{1}''' -f (Escape-TextForRegularExpressions $packOutput), $packageContentFolder ) - $publishArgs += $sharedArgs.ExtraArgs - - $command = '"{0}" {1}' -f (Get-MSDeploy),($publishArgs -join ' ') - $command | Print-CommandString - Execute-Command -exePath (Get-MSDeploy) -arguments ($publishArgs -join ' ') - } - else{ - throw 'publishProperties is empty, cannot publish' - } - } -} - -<# -.SYNOPSIS -If the passed in $publishProperties has values for appOffline the -needed arguments will be in the return object. If there is no such configuraion -then nothing is returned. -#> -function GetInternal-PublishAppOfflineProperties{ - [cmdletbinding()] - param( - [Parameter(Mandatory=$true,Position=0)] - $publishProperties - ) - process{ - $extraArg = ''; - $destFragment = '' - if($publishProperties['EnableMSDeployAppOffline'] -eq $true){ - $extraArg = '-enablerule:AppOffline' - - $appOfflineTemplate = $publishProperties['AppOfflineTemplate'] - if($appOfflineTemplate){ - $destFragment = (',appOfflineTemplate="{0}"' -f $appOfflineTemplate) - } - } - # return an object with both the properties that need to be in the command. - New-Object psobject -Property @{ - AdditionalArguments = $extraArg - DestFragment = $destFragment - } - } -} - -function Publish-AspNetFileSystem{ - [cmdletbinding(SupportsShouldProcess=$true)] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - process{ - $pubOut = $publishProperties['publishUrl'] - - if([string]::IsNullOrWhiteSpace($pubOut)){ - throw ('publishUrl is a required property for FileSystem publish but it was empty.') - } - - # if it's a relative path then update it to a full path - if(!([System.IO.Path]::IsPathRooted($pubOut))){ - $pubOut = [System.IO.Path]::GetFullPath((Join-Path $pwd $pubOut)) - $publishProperties['publishUrl'] = "$pubOut" - } - - 'Publishing files to {0}' -f $pubOut | Write-Output - - # we use msdeploy.exe because it supports incremental publish/skips/replacements/etc - # msdeploy.exe -verb:sync -source:contentPath='C:\srcpath' -dest:contentPath='c:\destpath' - - $sharedArgs = GetInternal-SharedMSDeployParametersFrom -publishProperties $publishProperties - - $publishArgs = @() - $publishArgs += ('-source:contentPath=''{0}''' -f "$packOutput") - $publishArgs += ('-dest:contentPath=''{0}''{1}' -f "$pubOut",$sharedArgs.DestFragment) - $publishArgs += '-verb:sync' - $publishArgs += $sharedArgs.ExtraArgs - - $command = '"{0}" {1}' -f (Get-MSDeploy),($publishArgs -join ' ') - $command | Print-CommandString - Execute-Command -exePath (Get-MSDeploy) -arguments ($publishArgs -join ' ') - } -} - - -function Print-CommandString{ - [cmdletbinding()] - param( - [Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)] - $command - ) - process{ - 'Executing command [{0}]' -f $command | Write-Output - } -} - -function Execute-CommandString{ - [cmdletbinding()] - param( - [Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)] - [string[]]$command, - - [switch] - $useInvokeExpression, - - [switch] - $ignoreErrors - ) - process{ - foreach($cmdToExec in $command){ - 'Executing command [{0}]' -f $cmdToExec | Write-Verbose - if($useInvokeExpression){ - try { - Invoke-Expression -Command $cmdToExec - } - catch { - if(-not $ignoreErrors){ - $msg = ('The command [{0}] exited with exception [{1}]' -f $cmdToExec, $_.ToString()) - throw $msg - } - } - } - else { - cmd.exe /D /C $cmdToExec - - if(-not $ignoreErrors -and ($LASTEXITCODE -ne 0)){ - $msg = ('The command [{0}] exited with code [{1}]' -f $cmdToExec, $LASTEXITCODE) - throw $msg - } - } - } - } -} - -function Execute-Command { - [cmdletbinding()] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - [String]$exePath, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - [String]$arguments - ) - process{ - $psi = New-Object -TypeName System.Diagnostics.ProcessStartInfo - $psi.CreateNoWindow = $true - $psi.UseShellExecute = $false - $psi.RedirectStandardOutput = $true - $psi.RedirectStandardError=$true - $psi.FileName = $exePath - $psi.Arguments = $arguments - - $process = New-Object -TypeName System.Diagnostics.Process - $process.StartInfo = $psi - $process.EnableRaisingEvents=$true - - # Register the event handler for error - $stdErrEvent = Register-ObjectEvent -InputObject $process -EventName 'ErrorDataReceived' -Action { - if (! [String]::IsNullOrEmpty($EventArgs.Data)) { - $EventArgs.Data | Write-Error - } - } - - # Starting process. - [Void]$process.Start() - $process.BeginErrorReadLine() - $output = $process.StandardOutput.ReadToEnd() - [Void]$process.WaitForExit() - $output | Write-Output - - # UnRegister the event handler for error - Unregister-Event -SourceIdentifier $stdErrEvent.Name - } -} - - -function Get-MSDeploy{ - [cmdletbinding()] - param() - process{ - $installPath = $env:msdeployinstallpath - - if(!$installPath){ - $keysToCheck = @('hklm:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3','hklm:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\2','hklm:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1') - - foreach($keyToCheck in $keysToCheck){ - if(Test-Path $keyToCheck){ - $installPath = (Get-itemproperty $keyToCheck -Name InstallPath -ErrorAction SilentlyContinue | select -ExpandProperty InstallPath -ErrorAction SilentlyContinue) - } - - if($installPath){ - break; - } - } - } - - if(!$installPath){ - throw "Unable to find msdeploy.exe, please install it and try again" - } - - [string]$msdInstallLoc = (join-path $installPath 'msdeploy.exe') - - "Found msdeploy.exe at [{0}]" -f $msdInstallLoc | Write-Verbose - - $msdInstallLoc - } -} - -function Get-MSDeployFullUrlFor{ - [cmdletbinding()] - param($msdeployServiceUrl) - process{ - # Convert contoso.scm.azurewebsites.net:443 to https://contoso.scm.azurewebsites.net/msdeploy.axd - # TODO: This needs to be improved, it only works with Azure Websites currently. - 'https://{0}/msdeploy.axd' -f $msdeployServiceUrl.TrimEnd(':443') - } -} - -function InternalRegister-AspNetKnownPublishHandlers{ - [cmdletbinding()] - param() - process{ - 'Registering MSDeploy handler' | Write-Verbose - Register-AspnetPublishHandler -name 'MSDeploy' -force -handler { - [cmdletbinding()] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - - Publish-AspNetMSDeploy -publishProperties $publishProperties -packOutput $packOutput - } - - 'Registering MSDeploy package handler' | Write-Verbose - Register-AspnetPublishHandler -name 'Package' -force -handler { - [cmdletbinding()] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - - Publish-AspNetMSDeployPackage -publishProperties $publishProperties -packOutput $packOutput - } - - 'Registering FileSystem handler' | Write-Verbose - Register-AspnetPublishHandler -name 'FileSystem' -force -handler { - [cmdletbinding()] - param( - [Parameter(Mandatory = $true,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - $publishProperties, - [Parameter(Mandatory = $true,Position=1,ValueFromPipelineByPropertyName=$true)] - $packOutput - ) - - Publish-AspNetFileSystem -publishProperties $publishProperties -packOutput $packOutput - } - } -} - -<# -.SYNOPSIS - Used for testing purposes only. -#> -function InternalReset-AspNetPublishHandlers{ - [cmdletbinding()] - param() - process{ - $script:AspNetPublishHandlers = @{} - InternalRegister-AspNetKnownPublishHandlers - } -} - -Export-ModuleMember -function Get-*,Publish-*,Register-*,Enable-* -if($env:IsDeveloperMachine){ - # you can set the env var to expose all functions to importer. easy for development. - # this is required for executing pester test cases, it's set by build.ps1 - Export-ModuleMember -function * -} - -# register the handlers so that Publish-AspNet can be called -InternalRegister-AspNetKnownPublishHandlers \ No newline at end of file diff --git a/eng/msbuild/web/Web/Transform/Microsoft.Web.Publishing.AspNetCompileMerge.targets b/eng/msbuild/web/Web/Transform/Microsoft.Web.Publishing.AspNetCompileMerge.targets deleted file mode 100644 index b150e252..00000000 --- a/eng/msbuild/web/Web/Transform/Microsoft.Web.Publishing.AspNetCompileMerge.targets +++ /dev/null @@ -1,774 +0,0 @@ - - - - - - - - - - - - - - true - - - - - True - - - - - - - - <_AspnetCompileMergePrecompiledOutput> - - False - AspNetCompilerMergePhase - Run - Default - - - - - - $(IntermediateOutputPath)AspnetCompileMerge\ - $(IntermediateOutputPath)AssemblyInfo\ - $(AspnetCompileMergeIntermediateOutputPath)Source - $(AspnetCompileMergeIntermediateOutputPath)TempBuildDir - - - - <_AspNetCompilerFixedNames Condition="'$(_AspNetCompilerFixedNames)' == ''">$(UseFixedNames) - - - - <_AspNetCompilerMetabasePath Condition ="'$(_AspNetCompilerMetabasePath)' == ''">$(SourceWebMetabasePath) - - - <_AspNetCompilerSourceWebPath Condition="'$(_AspNetCompilerSourceWebPath)' != ''">$(WebPublishPipelineProjectDirectory) - <_AspNetCompilerVirtualPath Condition="'$(_AspNetCompilerVirtualPath)' != ''">$(SourceWebVirtualPath) - - - - <_WPPCurrentBuildInfo>$(_WPPCurrentBuildInfo);PrecompileBeforePublish=$(PrecompileBeforePublish);WDPMergeOption=$(WDPMergeOption);_AspNetCompilerFixedNames=$(_AspNetCompilerFixedNames);_AspNetCompilerMetabasePath=$(_AspNetCompilerMetabasePath);Microsoft_Web_Publishing_AspNetCompileMerge_targets_Imported=$(Microsoft_Web_Publishing_AspNetCompileMerge_targets_Imported) - - - - - - - <_WPPCleanTargets> - $(_WPPCleanTargets); - CleanAspNetCompileMergeTempDirectories; - - - - - - - - - - - - - - - - - - - - - - - - - - GetFrameworkPaths; - - - - - aspnet_merge.exe - $(TargetFrameworkSDKToolsDirectory) - - - - - - - - - - - - - $(OnBeforeGenerateAssemblyInfoFromAssemblyAttributes); - $(GenerateAssemblyInfoFromAssemblyAttributesDependsOn); - GetFrameworkPaths; - GetAspNetMergePath; - - - - - - - <_AssemblyInfoSource Condition="'$(_AssemblyInfoSource)' == ''" >$(IntermediateOutputPath)AssemblyInfo\AssemblyInfo.cs - <_AssemblyInfoSourceDirectory>$([System.IO.Path]::GetDirectoryName($(_AssemblyInfoSource))) - $([System.IO.Path]::GetDirectoryName($(_AssemblyInfoSource)))\AssemblyInfo.dll - <_AssemblyInfoDllDirectory>$([System.IO.Path]::GetDirectoryName($(AssemblyInfoDll))) - - - - - - - - <_GenerateAssemblyInfoDll>false - <_GenerateAssemblyInfoDll Condition="'$(_AssemblyInfoSourceIsUpdated)' == 'true' or !Exists($(AssemblyInfoDll))">True - - - - - - - - - - - - - - - $(OnBeforeGenerateAssemblyInfoFromExistingAssembleInfo); - $(GenerateAssemblyInfoFromExistingAssembleInfoDependsOn); - GetFrameworkPaths; - GetAspNetMergePath; - GenerateAssemblyInfoFromAssemblyAttributes; - - - - - - - - - - <_AspNetCompile_AssemblyInfo Include="$(_AssemblyInfoSource)" /> - - - - <_AssemblyInfoDllDirectory>$(IntermediateOutputPath)AssemblyInfo - $(_AssemblyInfoDllDirectory)\AssemblyInfo.dll - - - - - - - <_GenerateAssemblyInfoDll>False - <_GenerateAssemblyInfoDll Condition="'$(AssemblyInfoDll)' == '' Or !Exists($(AssemblyInfoDll))">True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforeGenerateAssemblyInfo); - $(GenerateAssemblyInfoDependsOn); - GetFrameworkPaths; - GetAspNetMergePath; - GenerateAssemblyInfoFromAssemblyAttributes; - GenerateAssemblyInfoFromExistingAssembleInfo; - - - - - - - - - - - - - $(OnBeforeGetAspNetPreCompileSourceVirtualPath); - $(GetAspNetPreCompileSourceVirtualPathDependsOn); - - - - - - <__AspNetPreCompileSourceVirtualPathName Include ="DevelopmentServerVPath" /> - <__AspNetPreCompileSourceVirtualPathValue /> - - - - - - - - - <_AspNetCompilerVirtualPath>%(__AspNetPreCompileSourceVirtualPathValue.Value) - <_AspNetCompilerVirtualPath Condition="'$(_AspNetCompilerVirtualPath)' == '' ">\ - - - - - - - - - - $(OnBeforeConfigureForAspNetPreCompileMerge); - $(ConfigureForAspNetPreCompileMergeDependsOn); - GetFrameworkPaths; - GetAspNetMergePath; - GetAspNetPreCompileSourceVirtualPath; - ResolveKeySource; - - - - - - - <_WDPFrameworkLowerThan4>False - <_WDPFrameworkLowerThan4 Condition="'$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'">True - - - - - $(windir)\Microsoft.NET\Framework64\v2.0.50727 - $(Framework20Dir) - - - $(windir)\Microsoft.NET\Framework64\v4.0.30319 - - - $(Framework40Dir) - - - - - - <_AspNetCompileMergeKeyFile Condition="'$(_AspNetCompileMergeKeyFile)' == ''">$(KeyOriginatorFile) - - - - <_AspNetCompileMergeKeyContainer Condition="'$(_AspNetCompileMergeKeyContainer)' == ''">$(KeyContainerName) - - - - - - - - - - - - $(OnBeforeAspNetPreCompile); - $(AspNetPreCompileDependsOn); - CopyAllFilesToSingleFolderForAspNetCompileMerge; - GetReferenceAssemblyPaths; - ResolveReferences; - ResolveKeySource; - ConfigureForAspNetPreCompileMerge; - - - - - - - <_PreAspnetCompileMergeSingleTargetFolderFullPath> - <_AspNetCompilerVirtualPath> - - - <_PreAspnetCompileMergeSingleTargetFolderFullPath>$([System.IO.Path]::GetFullPath($(_PreAspnetCompileMergeSingleTargetFolder))) - - - - <_PostAspnetCompileMergeSingleTargetFolderFullPath>$([System.IO.Path]::GetFullPath($(_PostAspnetCompileMergeSingleTargetFolder))) - - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforeAspNetMerge); - CopyAllFilesToSingleFolderForAspNetCompileMerge; - $(AspNetMergeDependsOn); - ConfigureForAspNetPreCompileMerge; - AspNetPreCompile; - GenerateAssemblyInfo; - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforeConfigureFoldersForAspNetCompileMerge); - $(ConfigureFoldersForAspNetCompileMergeDependsOn); - - - - - - - - - - <_PreAspnetCompileMergeSingleTargetFolder>$(CopyBeforeAspnetCompileMergeTargetPath) - <_PostAspnetCompileMergeSingleTargetFolder>$(AspnetCompileMerge_TempBuildDir) - - - - - - - - - - - - - - - - $(OnBeforeCopyAllFilesToSingleFolderForAspNetCompileMerge); - ConfigureFoldersForAspNetCompileMerge; - $(CopyAllFilesToSingleFolderForAspNetCompileMergeDependsOn); - - - - - - - <_AllExtraFilesUnder_PreAspnetCompileMergeSingleTargetFolder Include="$(_PreAspnetCompileMergeSingleTargetFolder)\**" /> - <_AllExtraFilesUnder_PreAspnetCompileMergeSingleTargetFolder - Remove="@(FilesForPackagingFromProject->'$(_PreAspnetCompileMergeSingleTargetFolder)\%(DestinationRelativePath)')" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforePostAspNetCompileMergeCollectFiles); - $(PostAspNetCompileMergeCollectFilesDependsOn); - AspNetMerge; - - - - - - - - - <_AspnetCompileMergePrecompiledOutput Include="@(_AspnetCompileMergePrecompiledOutputNoMetadata->'$(_PostAspnetCompileMergeSingleTargetFolder)\%(Identity)')"> - %(_AspnetCompileMergePrecompiledOutputNoMetadata.Identity) - - - - - - - - - - - - <_AspnetCompileMergePrecompiledOutput Remove="@(_FilesForPackagingFromProject_in_AspnetCompileMergePrecompiledOutput->'%(FilterItemSpec)')" /> - <_AspnetCompileMergePrecompiledOutput Include="@(_FilesForPackagingFromProject_in_AspnetCompileMergePrecompiledOutput->'%(FilterItemSpec)')" /> - - - - - - - - - - - - - - - - - - - - - - - $(OnBeforeCleanPostAspNetCompileMergeFolder); - $(CleanPostAspNetCompileMergeFolderDependsOn); - ConfigureFoldersForAspNetCompileMerge; - - - - - - - - - - - - - - - - $(OnBeforePipelineAspNetCompileMergePhase); - $(PipelineAspNetCompileMergePhaseDependsOn); - CleanPostAspNetCompileMergeFolder; - CopyAllFilesToSingleFolderForAspNetCompileMerge; - AspNetPreCompile; - AspNetMerge; - PostAspNetCompileMergeCollectFiles; - - - PipelineTransformPhase; - - - - - - - - - - - - - - - - - true - - - diff --git a/eng/msbuild/web/WebApplications/Microsoft.WebApplication.Build.Tasks.Dll b/eng/msbuild/web/WebApplications/Microsoft.WebApplication.Build.Tasks.Dll deleted file mode 100644 index a86cb69d..00000000 Binary files a/eng/msbuild/web/WebApplications/Microsoft.WebApplication.Build.Tasks.Dll and /dev/null differ diff --git a/eng/msbuild/web/WebApplications/Microsoft.WebApplication.targets b/eng/msbuild/web/WebApplications/Microsoft.WebApplication.targets deleted file mode 100644 index 5888831b..00000000 --- a/eng/msbuild/web/WebApplications/Microsoft.WebApplication.targets +++ /dev/null @@ -1,396 +0,0 @@ - - - - - - - False - True - False - $(WebProjectOutputDirInsideProjectDefault) - False - False - False - True - False - - - - - $(MSBuildProjectDirectory) - $(OutDir)_PublishedWebsites\$(MSBuildProjectName) - - - - - $(PrepareForRunDependsOn); - CopySilverlightApplications; - _CopyBinDeployableAssemblies; - - - $(PrepareForRunDependsOn); - _CopyWebApplication; - _BuiltWebOutputGroupOutput - - - - - - - - - $(CleanDependsOn); - CleanWebProjectOutputDir; - - - - - - - - - - - - - - - - - - - - - - _CopyWebApplicationLegacy; - - - _WPPCopyWebApplication; - - - $(OnBefore_CopyWebApplicationDefault); - - - - - - <_CopyWebApplicationDependsOn Condition="'$(_CopyWebApplicationDependsOn)'==''"> - $(OnBefore_CopyWebApplication); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_SilverlightApplications Include="@(_AllSilverlightApplications)" Condition="Exists('%(Identity)')"/> - <_SilverlightApplicationsNotExist Include="@(_AllSilverlightApplications)" Condition="!Exists('%(Identity)')"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _bin_deployableAssemblies\ - $([System.IO.Path]::GetFullPath($(BinDeployableFolder))) - - - - - - - - - - <_binDeployableAssemblies Include ="@(__binDeployableAssemblies)" Condition="'@(__binDeployableAssemblies)' != ''"> - $([System.String]::Concat($([System.IO.Path]::GetDirectoryName($([System.String]::new('%(__binDeployableAssemblies.FullPath)')))),'\').SubString($(BinDeployableFolderFullPath.Length))) - - - - - - - - - - - - - - - $(MSBuildThisFileDirectory)..\Web\ - - - - - - - - $(OnBeforePipelineCollectFilesPhase); - CopySilverlightApplications; - - - - - - false - $(ProjectConfigFileName) - - diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddict.Client.WebIntegration.Generators.csproj b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddict.Client.WebIntegration.Generators.csproj index 0357ce00..8ab1b3c9 100644 --- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddict.Client.WebIntegration.Generators.csproj +++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddict.Client.WebIntegration.Generators.csproj @@ -9,22 +9,12 @@ false - - - - - - - - - - $(GetTargetPathDependsOn);GetDependencyTargetPaths diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs index a9ad6b06..f5e1a812 100644 --- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs +++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs @@ -492,7 +492,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder throw new ArgumentException(SR.GetResourceString(SR.ID0346), nameof(key)); } - var algorithm = OpenIddictHelpers.CreateEcdsaKey(); + var algorithm = ECDsa.Create(); try { @@ -580,14 +580,10 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder [Obsolete(""This option is no longer supported and will be removed in a future version."")] {{~ end ~}} public {{ provider.name }} Set{{ setting.property_name }}(Assembly assembly, string resource, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => Set{{ setting.property_name }}(assembly, resource, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => Set{{ setting.property_name }}(assembly, resource, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Configures {{ setting.description }}. @@ -623,14 +619,10 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder [Obsolete(""This option is no longer supported and will be removed in a future version."")] {{~ end ~}} public {{ provider.name }} Set{{ setting.property_name }}(Stream stream, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => Set{{ setting.property_name }}(stream, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => Set{{ setting.property_name }}(stream, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Configures {{ setting.description }}. @@ -649,16 +641,13 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder using var buffer = new MemoryStream(); stream.CopyTo(buffer); -#if SUPPORTS_CERTIFICATE_LOADER var certificate = X509Certificate2.GetCertContentType(buffer.ToArray()) switch { X509ContentType.Pkcs12 => X509CertificateLoader.LoadPkcs12(buffer.ToArray(), password, flags), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0454)) }; -#else - var certificate = new X509Certificate2(buffer.ToArray(), password, flags); -#endif + return Set{{ setting.property_name }}(certificate); } @@ -1178,7 +1167,6 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration registration.SigningCredentials.Add(new SigningCredentials(key, SecurityAlgorithms.HmacSha256)); } -#if SUPPORTS_ECDSA // Note: ECDSA algorithms are bound to specific curves and must be treated separately. else if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { @@ -1194,14 +1182,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration { registration.SigningCredentials.Add(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha512)); } -#else - else if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256) || - key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384) || - key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha512)) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0069)); - } -#endif + else { throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); @@ -1230,7 +1211,6 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration registration.SigningCredentials.Add(new SigningCredentials(settings.{{ setting.property_name }}, SecurityAlgorithms.HmacSha256)); } -#if SUPPORTS_ECDSA // Note: ECDSA algorithms are bound to specific curves and must be treated separately. else if (settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { @@ -1246,14 +1226,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration { registration.SigningCredentials.Add(new SigningCredentials(settings.{{ setting.property_name }}, SecurityAlgorithms.EcdsaSha512)); } -#else - else if (settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256) || - settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384) || - settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha512)) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0069)); - } -#endif + else { throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); @@ -1311,7 +1284,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration { Count: > 0 } types => types.Select(static type => (string?) type.Attribute("Value")).ToList(), // If no explicit grant type was set, assume the provider only supports the code flow. - _ => [GrantTypes.AuthorizationCode] + _ => ["authorization_code"] }, ResponseModesSupported = configuration.Elements("ResponseMode").ToList() switch @@ -1319,7 +1292,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration { Count: > 0 } modes => modes.Select(static type => (string?) type.Attribute("Value")).ToList(), // If no explicit response mode was set, assume the provider only supports the query response mode. - _ => [ResponseModes.Query] + _ => ["query"] }, ResponseTypesSupported = configuration.Elements("ResponseType").ToList() switch @@ -1327,7 +1300,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration { Count: > 0 } types => types.Select(static type => (string?) type.Attribute("Value")).ToList(), // If no explicit response type was set, assume the provider only supports the code flow. - _ => [ResponseTypes.Code] + _ => ["code"] }, ScopesSupported = configuration.Elements("Scope").ToList() switch @@ -1343,7 +1316,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration // If no explicit client authentication method was set, assume the provider only supports // flowing the client credentials as part of the device authorization request payload. - _ => [ClientAuthenticationMethods.ClientSecretPost] + _ => ["client_secret_post"] }, IntrospectionEndpointAuthMethodsSupported = configuration.Elements("IntrospectionEndpointAuthMethod").ToList() switch @@ -1352,7 +1325,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration // If no explicit client authentication method was set, assume the provider only // supports flowing the client credentials as part of the introspection request payload. - _ => [ClientAuthenticationMethods.ClientSecretPost] + _ => ["client_secret_post"] }, RevocationEndpointAuthMethodsSupported = configuration.Elements("RevocationEndpointAuthMethod").ToList() switch @@ -1361,7 +1334,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration // If no explicit client authentication method was set, assume the provider only // supports flowing the client credentials as part of the revocation request payload. - _ => [ClientAuthenticationMethods.ClientSecretPost] + _ => ["client_secret_post"] }, TokenEndpointAuthMethodsSupported = configuration.Elements("TokenEndpointAuthMethod").ToList() switch @@ -1370,7 +1343,7 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration // If no explicit client authentication method was set, assume the provider only // supports flowing the client credentials as part of the token request payload. - _ => [ClientAuthenticationMethods.ClientSecretPost] + _ => ["client_secret_post"] } }, diff --git a/global.json b/global.json index 1ddd4558..f19ad123 100644 --- a/global.json +++ b/global.json @@ -6,20 +6,12 @@ }, "tools": { - "dotnet": "10.0.203", - - "runtimes": { - "aspnetcore": [ - "8.0.26", - "9.0.15" - ] - } + "dotnet": "10.0.203" }, "msbuild-sdks": { "Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25562.108", "Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25562.108", - "MSBuild.Sdk.Extras": "3.0.44", "MSBuild.SDK.SystemWeb": "4.0.97" } } diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj b/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj index 63106125..bf3c88ad 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj +++ b/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj @@ -4,6 +4,7 @@ net48 Web.config Overwrite + $(NuGetPackageRoot)msbuild.microsoft.visualstudio.web.targets\14.0.0.3\tools\VSToolsPath false disable CA3147 @@ -30,7 +31,9 @@ + + diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Client/Web.config b/sandbox/OpenIddict.Sandbox.AspNet.Client/Web.config index 5884defb..e9f072fa 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Client/Web.config +++ b/sandbox/OpenIddict.Sandbox.AspNet.Client/Web.config @@ -43,13 +43,13 @@ - + - - + + @@ -73,7 +73,7 @@ - + @@ -91,13 +91,13 @@ - + - - + + @@ -133,7 +133,7 @@ - + @@ -156,8 +156,8 @@ - - + + @@ -192,44 +192,44 @@ - - + + - - + + - + - + - + - - + + - - + + diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj b/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj index decf5a59..743babf6 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj +++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj @@ -4,6 +4,7 @@ net48 Web.config Overwrite + $(NuGetPackageRoot)msbuild.microsoft.visualstudio.web.targets\14.0.0.3\tools\VSToolsPath false disable CA3147 @@ -34,7 +35,9 @@ + + diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/Web.config b/sandbox/OpenIddict.Sandbox.AspNet.Server/Web.config index 5b3af713..a0680100 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Server/Web.config +++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/Web.config @@ -49,13 +49,13 @@ - + - - + + @@ -97,7 +97,7 @@ - + @@ -115,13 +115,13 @@ - + - - + + @@ -180,8 +180,8 @@ - - + + @@ -204,38 +204,38 @@ - - + + - + - + - - + + - - + + - - + + diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs index 70b170ae..91491bb5 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs @@ -228,19 +228,12 @@ public class AuthenticationController : Controller OpenIddictClientAspNetCoreConstants.Tokens.BackchannelIdentityToken or OpenIddictClientAspNetCoreConstants.Tokens.RefreshToken)); -#if SUPPORTS_REDIRECTION_ON_SIGN_IN // Ask the default sign-in handler to return a new cookie and redirect the // user agent to the return URL stored in the authentication properties. // // For scenarios where the default sign-in handler configured in the ASP.NET Core // authentication options shouldn't be used, a specific scheme can be specified here. return SignIn(new ClaimsPrincipal(identity), properties); -#else - // Note: "return SignIn(...)" cannot be directly used as-is on ASP.NET Core <7.0, as the cookies handler - // doesn't allow redirecting from an endpoint that doesn't match the path set in the cookie options. - await HttpContext.SignInAsync(new ClaimsPrincipal(identity), properties); - return Redirect(properties.RedirectUri ?? "/"); -#endif } // Note: this controller uses the same callback action for all providers diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/HomeController.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/HomeController.cs index 5c1efcda..715be7a3 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/HomeController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/HomeController.cs @@ -1,5 +1,4 @@ -using System.Net.Http; -using System.Net.Http.Headers; +using System.Net.Http.Headers; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/OpenIddict.Sandbox.AspNetCore.Client.csproj b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/OpenIddict.Sandbox.AspNetCore.Client.csproj index f871dffe..04c251da 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/OpenIddict.Sandbox.AspNetCore.Client.csproj +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/OpenIddict.Sandbox.AspNetCore.Client.csproj @@ -1,7 +1,7 @@  - net48;net10.0 + net10.0 @@ -15,17 +15,4 @@ - - - - - - - - - - diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Program.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Program.cs index d1ba3810..74a87152 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Program.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Program.cs @@ -1,17 +1,209 @@ -using Microsoft.AspNetCore; -using OpenIddict.Sandbox.AspNetCore.Client; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.EntityFrameworkCore; +using Microsoft.IdentityModel.Tokens; +using OpenIddict.Client; +using OpenIddict.Client.WebIntegration; using OpenIddict.Sandbox.AspNetCore.Client.Models; +using Quartz; +using static OpenIddict.Abstractions.OpenIddictConstants; -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST -var builder = Host.CreateDefaultBuilder(args); -builder.ConfigureWebHostDefaults(builder => builder.UseStartup()); -#else -var builder = WebHost.CreateDefaultBuilder(args); -builder.UseStartup(); -#endif +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddDbContext(options => +{ + options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-client.sqlite3")}"); + options.UseOpenIddict(); +}); + +builder.Services.AddAuthentication(options => +{ + options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; +}) + +.AddCookie(options => +{ + options.LoginPath = "/login"; + options.LogoutPath = "/logout"; + options.ExpireTimeSpan = TimeSpan.FromMinutes(50); + options.SlidingExpiration = false; +}); + +// OpenIddict offers native integration with Quartz.NET to perform scheduled tasks +// (like pruning orphaned authorizations from the database) at regular intervals. +builder.Services.AddQuartz(options => +{ + options.UseSimpleTypeLoader(); + options.UseInMemoryStore(); +}); + +// Register the Quartz.NET service and configure it to block shutdown until jobs are complete. +builder.Services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); + +builder.Services.AddOpenIddict() + + // Register the OpenIddict core components. + .AddCore(options => + { + // Configure OpenIddict to use the Entity Framework Core stores and models. + options.UseEntityFrameworkCore() + .UseDbContext(); + + // Developers who prefer using MongoDB can remove the previous lines + // and configure OpenIddict to use the specified MongoDB database: + // options.UseMongoDb() + // .UseDatabase(new MongoClient().GetDatabase("openiddict")); + + // Enable Quartz.NET integration. + options.UseQuartz(); + }) + + // Register the OpenIddict client components. + .AddClient(options => + { + // Note: this sample uses the authorization code and refresh token + // flows, but you can enable the other flows if necessary. + options.AllowAuthorizationCodeFlow() + .AllowRefreshTokenFlow(); + + // Register the signing and encryption credentials used to protect + // sensitive data like the state tokens produced by OpenIddict. + options.AddDevelopmentEncryptionCertificate() + .AddDevelopmentSigningCertificate(); + + // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. + options.UseAspNetCore() + .EnableStatusCodePagesIntegration() + .EnableRedirectionEndpointPassthrough() + .EnablePostLogoutRedirectionEndpointPassthrough(); + + // Register the System.Net.Http integration and use the identity of the current + // assembly as a more specific user agent, which can be useful when dealing with + // providers that use the user agent as a way to throttle requests (e.g Reddit). + options.UseSystemNetHttp() + .SetProductInformation(typeof(Program).Assembly); + + // Add a client registration matching the client application definition in the server project. + options.AddRegistration(new OpenIddictClientRegistration + { + Issuer = new Uri("https://localhost:44395/", UriKind.Absolute), + ProviderName = "Local", + ProviderDisplayName = "Local OIDC server", + + ClientId = "mvc", + Scopes = { Scopes.Email, Scopes.Profile, Scopes.OfflineAccess, "demo_api" }, + + RedirectUri = new Uri("callback/login/local", UriKind.Relative), + PostLogoutRedirectUri = new Uri("callback/logout/local", UriKind.Relative), + + // On supported platforms, this application can authenticate using 3 different client + // authentication methods that all offer a higher security level than shared client secrets: + // + // 1) tls_client_auth (PKI-based mutual TLS authentication): while it requires + // setting up a proper Public Key Infrastructure, this method offers a very + // high level of security, as the authorization server never has access to the + // private key used by the client to authenticate itself and can dynamically check + // the revocation status of the client certificate using standard PKI mechanisms. + // + // 2) self_signed_tls_client_auth (self-signed certificate-based mutual TLS authentication): + // this method is easier to deploy than PKI-based mutual TLS authentication, while + // still offering a high level of security. Unlike PKI-based mutual TLS authentication, + // the revocation status of the client certificate is never checked but certificates can + // be "revoked" by being removed from the JSON Web Key Set associated with the client. + // + // 3) private_key_jwt (JWT client assertions signed with a private key): while this + // method doesn't offer the same security guarantees as mutual TLS authentication, + // it is more secure than shared secrets and doesn't have the operational constraints + // required by the two mutual TLS methods described above (such as TLS configuration). + // + // The actual client authentication method used by the OpenIddict client is automatically + // selected based on the registered credentials and the methods supported by the server: + // when supported by the server, mutual TLS authentication methods are always preferred. + // + // In all cases, no client secret is necessary but the client needs to be able to access the + // private key of the certificate/key to be able to generate and sign the client assertions. + + SigningCredentials = + { + // Note: this certificate can be used with either tls_client_auth or private_key_jwt, + // depending on the server configuration (and the client authentication methods explicitly + // configured via OpenIddictClientRegistration.ClientAuthenticationMethods, if applicable). + // + GetPublicKeyInfrastructureCertificate(), + + // Note: this certificate can be used with either self_signed_tls_client_auth or private_key_jwt, + // depending on the server configuration (and the client authentication methods explicitly + // configured via OpenIddictClientRegistration.ClientAuthenticationMethods, if applicable): + // + // GetSelfSignedCertificate(), + + // Note: this key can only be used with private_key_jwt as raw keys cannot be used with TLS. + // GetSigningKey() + } + }); + + // Register the Web providers integrations. + // + // Note: to mitigate mix-up attacks, it's recommended to use a unique redirection endpoint + // URI per provider, unless all the registered providers support returning a special "iss" + // parameter containing their URL as part of authorization responses. For more information, + // see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-4.4. + options.UseWebProviders() + .AddGitHub(options => + { + options.SetClientId("c4ade52327b01ddacff3") + .SetClientSecret("da6bed851b75e317bf6b2cb67013679d9467c122") + .SetRedirectUri("callback/login/github"); + }) + .AddGoogle(options => + { + options.SetClientId("1016114395689-kgtgq2p6dj27d7v6e2kjkoj54dgrrckh.apps.googleusercontent.com") + .SetClientSecret("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") + .SetRedirectUri("callback/login/google") + .SetAccessType(OpenIddictClientWebIntegrationConstants.Google.AccessTypes.Offline) + .AddScopes(Scopes.Profile); + }) + .AddReddit(options => + { + options.SetClientId("vDLNqhrkwrvqHgnoBWF3og") + .SetClientSecret("Tpab28Dz0upyZLqn7AN3GFD1O-zaAw") + .SetRedirectUri("callback/login/reddit") + .SetDuration(OpenIddictClientWebIntegrationConstants.Reddit.Durations.Permanent); + }); + }); + +// Register a named HTTP client that will be used to call the demo resource API. +// +// Note: since the authorization server is configured to issue certificate-bound +// access tokens, the client certificate MUST be attached to outgoing HTTP requests +// and the mTLS subdomain (for which TLS client authentication is enabled) MUST be used. +builder.Services.AddHttpClient("ApiClient") + .AddAsKeyed() + .ConfigureHttpClient(static client => client.BaseAddress = new Uri("https://mtls.dev.localhost:44395/")) + .ConfigurePrimaryHttpMessageHandler(static () => new HttpClientHandler + { + ClientCertificateOptions = ClientCertificateOption.Manual, + ClientCertificates = { GetPublicKeyInfrastructureCertificate().Certificate } + }); + +builder.Services.AddMvc(); var app = builder.Build(); +app.UseDeveloperExceptionPage(); + +app.UseStaticFiles(); + +app.UseStatusCodePagesWithReExecute("/error"); +app.UseRouting(); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.MapControllers(); +app.MapDefaultControllerRoute(); + // Before starting the host, create the database used to store the application data. // // Note: in a real world application, this step should be part of a setup script. @@ -22,3 +214,179 @@ await using (var scope = app.Services.CreateAsyncScope()) } await app.RunAsync(); + +static X509SigningCredentials GetPublicKeyInfrastructureCertificate() +{ + // Note: OpenIddict only negotiates PKI-based or self-signed mutual + // TLS authentication if the certificate explicitly contains the + // "digitalSignature" key usage and the "clientAuth" extended key usage. + var certificate = X509Certificate2.CreateFromPem( + certPem: $""" + -----BEGIN CERTIFICATE----- + MIIEezCCAmOgAwIBAgIRALTZE9ezjPCWDFr38cp6AMAwDQYJKoZIhvcNAQELBQAw + GjEYMBYGA1UEAxMPSW50ZXJtZWRpYXRlIENBMCAXDTI2MDIwMTE0MTQ0M1oYDzIx + MjYwMjAyMTQxNDQzWjAaMRgwFgYDVQQDEw9FbmQgY2VydGlmaWNhdGUwggEiMA0G + CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMs9spnvKeKw6VwPbpB47ikC6bL0Cn + S+K19Fp8dJg8b4dA1J1Y8dA2gi2nU/+ntOMYp1A6EvMZ8UpbgnSmhUN/2JQFU5Hc + PP0/IMjZAl2Iseh2yiK3Ril4Agbng6YW7e9P5YtMV+6i/stYujwNTXsUMr/+QSUI + Nze7856XSIl9gRjWEKJ17Jk/tJpun/zdpl4hXcptrsxxLU/E03bC3LcjiXzg8/Zl + 3/oEHqcHfv9C8RTdIBBw66zJAYzGfxwV31cJ9QQ2udlipi2l+ZR6jFWzzJI4XmiC + FzdwZRvhMLJsyK5miVIl0qPp3zJ2IyEb/2pLA0bc/ylZwVq6Z49k2xhZAgMBAAGj + gbkwgbYwDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww + CgYIKwYBBQUHAwIwHQYDVR0OBBYEFHPamNF/deBBv5JpDwiiRctPw4ziMEkGA1Ud + IwRCMECAFOEWwW18w3rZ6/5iIwAB12592OlHoRakFDASMRAwDgYDVQQDEwdSb290 + IENBghBvqw/xqI/LNgVfSURP9ck7MBQGA1UdEQQNMAuCCWxvY2FsaG9zdDANBgkq + hkiG9w0BAQsFAAOCAgEAbBq73JzDpK11hoRUxHq7LvplQEe/FNuD/slvn9Crfm2d + jJj0HsQQZpMgxP7SZ9FNvFqCo+/dm9PchIlwqwSjWtTxgYmcMOXw0Rzst85Ug4U1 + I2PG6iPxJ4WLSW2gzo//jFPa7MD1AnqDYwcCQTVsQW6aJavY3mFD31SJKsvSKqsV + 6xTXsajLRetCSXGe5qFgfyLC9tOhtTWXsCed/ISoQ9bljhOSqT6pxkpOVu0AHHMB + 1CMZay/B5ecjb66mwSoRcAPweMlAYJkjU5HXHSi7kB3gRQTsb1ZymEn67Q4C5cpI + Lq6UFK5bWZf1A0kFbYJBmn3oHsWxMQqv0F6QE7r4Mg6pfk9swzYZ8WqcgjiGHQET + pVU7ZKkUsg2JREXxRnhh5+Q+vGsF/DjhzQ6NrfPm8sqs+X+LzUN2cne8ZPclfyW2 + VKCHTPZ6o8mELiAlIPdBYUYsgUEOsfmUWbx4wfx5IB7vnenrenInLLyGOOCxR33d + o/gDMLFdeKHXK2ISsbDCk+zwEF8kztn1cXWK+K6H9cr8oJjDi1OJwTkqz9msar+9 + mjZ1CPAF0X+mLgrhVnNYqd5oqeeLerXKkAvpC2TgvlWJRGyDILhjva3J+2fQAYXZ + +OKFHNPf3n8Co4s5TMr1eiGVtS1etH6hPxnn5Jwnes9JZWFRLcjeTmPLSRWFucg= + -----END CERTIFICATE----- + """, + keyPem: $""" + -----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEAzLPbKZ7ynisOlcD26QeO4pAumy9Ap0vitfRafHSYPG+HQNSd + WPHQNoItp1P/p7TjGKdQOhLzGfFKW4J0poVDf9iUBVOR3Dz9PyDI2QJdiLHodsoi + t0YpeAIG54OmFu3vT+WLTFfuov7LWLo8DU17FDK//kElCDc3u/Oel0iJfYEY1hCi + deyZP7Sabp/83aZeIV3Kba7McS1PxNN2wty3I4l84PP2Zd/6BB6nB37/QvEU3SAQ + cOusyQGMxn8cFd9XCfUENrnZYqYtpfmUeoxVs8ySOF5oghc3cGUb4TCybMiuZolS + JdKj6d8ydiMhG/9qSwNG3P8pWcFaumePZNsYWQIDAQABAoIBACorfyHC4d5dpmKJ + XxRAf1oDM+a6REpyoqCzVxS+fEIvA6ECa+vP3QHtrXQEJO2qoQIKLcfY8YXNpHDX + nipT18T1nADA55KEafNgUKAMEbLAW9Bk8ePpq09Ss5NsFoIwwBUoh5rRnpKrhL6h + lw9yf8F4dv7s8rEPlwa8OFaYFeLpoBLsPaX3nMu45CKb25dFZzSv9ORVs28LALrS + oK9MbtNFkmf/4EmpYA+nblkZd2bu4BomOF7C2F4bwtikN29vl4NPMhlbZGTy1hm9 + jzMOOvO1DwvIjHRVcfHKMDZ7cw1Pj5TmeApToSs6ygu1lce0GQcNVm+KV2qZMjNQ + Al6cdFUCgYEA7HZ6wvZU/WA7ei+jIwrJdyQQ3jU/LAu7GGhXiMU3z2RSR/vieY5R + 4IjQOgUkLBuQcy9uoQcSLpH/SNLIi6qhlMBvZuHq9QKF60t68tuW0PFSoa+SKaEn + DCZ70bnxo4OSRUtrzxikYHnwOvRGEli4EAOENETaQBKJUUygov/pOWMCgYEA3Z2a + TJlptRq75G6LHZvbBBzZdG9Mr04O6zvh5TGsJW86b6ov9BTAGz6Z37KWR1yUDfyH + dqNf90kJ8hs1eO6gGDQyGaH9yerrlULukANQfvpC0rEeJ7DfXSc1iLa3Q6+AOt5v + 9TkQY7s/47iOPoCmblZ4FeVcIMx88ms2mBRXshMCgYAN9pkdNiqio7Ifbvy1Lwfi + jzCnzoEierbbpB23J9450vTA53DiOLNBDRMuuer+58nJ430m6SH7ugdXJ4tMJBFS + lWJ+ssyLF1ENKfHisXDgeb+laJa6+pcxsnwRUGeifjx+9wswuYXLZKf48z/ICZEk + 8PA3nfE9Y1rUgC/kMDR3fQKBgQCyQRRdTICUJV7ATJIlTLmLw1C9sNBzqUuitlXq + rluS+LZ+HtvXbeFfiKjoH5N07ug/n8GuEZcdJmiTjoMiNH4dOc6ag4vJH+ZB9sZA + nAnhOJcLNV/V+RSQrvsGbkFWdhGkSEqxaibesTyghFAVwhEcavzIT+Yck55ktwwA + o0wudQKBgQDR0hyl/cf6MBgZ3gce6dOcznLKoa2icypmmfNkA6sqwXwW20/WfDGb + ZNdaL4U3xReSN1mzrs0yStq0UrAChwrwqJc6T7uhGR/lDjvJCeZP9zO2yCSBvtul + LWFkJnofc7NUYkhVSGaAMeT14xUY/XlFbkXp0jZOqKMRo7PeeeXZaQ== + -----END RSA PRIVATE KEY----- + """); + + // On Windows, a certificate loaded from PEM-encoded material is ephemeral and + // cannot be directly used with TLS, as Schannel cannot access it in this case. + // + // To work this limitation, the certificate is exported and re-imported from a + // PFX blob to ensure the private key is persisted in a way that Schannel can use. + // + // In a real world application, the certificate wouldn't be embedded in the source code + // and would be installed in the certificate store, making this workaround unnecessary. + if (OperatingSystem.IsWindows()) + { + certificate = X509CertificateLoader.LoadPkcs12( + data: certificate.Export(X509ContentType.Pfx, string.Empty), + password: string.Empty, + keyStorageFlags: X509KeyStorageFlags.DefaultKeySet); + } + + return new X509SigningCredentials(certificate); +} + +#pragma warning disable CS8321 +static X509SigningCredentials GetSelfSignedCertificate() +{ + // Note: OpenIddict only negotiates PKI-based or self-signed mutual + // TLS authentication if the certificate explicitly contains the + // "digitalSignature" key usage and the "clientAuth" extended key usage. + var certificate = X509Certificate2.CreateFromPem( + certPem: $""" + -----BEGIN CERTIFICATE----- + MIIC8zCCAdugAwIBAgIJAIZ9BN3TUnZQMA0GCSqGSIb3DQEBCwUAMCIxIDAeBgNV + BAMTF1NlbGYtc2lnbmVkIGNlcnRpZmljYXRlMCAXDTI2MDIwMjE0MzM0OVoYDzIx + MjYwMjAyMTQzMzQ5WjAiMSAwHgYDVQQDExdTZWxmLXNpZ25lZCBjZXJ0aWZpY2F0 + ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOtfKVPM7ghVFh4U/sz4 + sTrpaNJGQ2NORqawYxAHwluhr101yIOW7rWvFlFncA64Lkq9SAbFFCVSAbo28c6B + 2Mi41jyC4LHQU11jhv08K/3FUuckCuzEpzTnXUhxJHWxrRDVEuvKINGPs1VgVtTT + ra8rjP8s1YRAzCYnByxSx+8GXNGHprylLh0agpWKb2+2FYwDqY5ME2g3xTL9FTUu + FYWTcyspsvN0U1Eo1vlCeOxSYGPRct0MK0AS6eXEGBv+3kCYI7a5+UhQok0WvErF + pjIVo7USISDgKhW9GhTsWN+WywwdG4Kx4V6SB8ZLAHFSBSR3gjWS3TGOyqAWoBXc + znkCAwEAAaMqMCgwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsGAQUF + BwMCMA0GCSqGSIb3DQEBCwUAA4IBAQBf5i/S7shmNalVxMuP8/Mk8cOhRRZjnAXd + zz3eOuXu0CH8iY/DwCgss04O2NTxuz87rKiuNKOrtY0oN/G4aFjWPvbgoQ+N1XP1 + zvbhqbyo3fQr07FyjWkrIUoHYFQ3JRfL+GPGjWizJsgdpdCRJSK6G9VX8eU3Akjv + YhMRLmbkrH5etOURqFtLpZlxNmLzCpqWIvzRiYyyj74iOipA2I0acgcvkakWn6rE + Wio7luBAZ3dXlukEfHTOg+ft4k0nOlRXPTtASOmyFQBOs6iYJeztHDz6MQnknAPe + +W53US8kLWktspcOQmxhVVH1g1/T4ynl9iX7tzqvUbdYwZNi92+x + -----END CERTIFICATE----- + """, + keyPem: $""" + -----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEA618pU8zuCFUWHhT+zPixOulo0kZDY05GprBjEAfCW6GvXTXI + g5buta8WUWdwDrguSr1IBsUUJVIBujbxzoHYyLjWPILgsdBTXWOG/Twr/cVS5yQK + 7MSnNOddSHEkdbGtENUS68og0Y+zVWBW1NOtryuM/yzVhEDMJicHLFLH7wZc0Yem + vKUuHRqClYpvb7YVjAOpjkwTaDfFMv0VNS4VhZNzKymy83RTUSjW+UJ47FJgY9Fy + 3QwrQBLp5cQYG/7eQJgjtrn5SFCiTRa8SsWmMhWjtRIhIOAqFb0aFOxY35bLDB0b + grHhXpIHxksAcVIFJHeCNZLdMY7KoBagFdzOeQIDAQABAoIBAQDgBOqov9uuQo2S + hBkfrXPBxnXl7MomslG8RRWEJF5wKCtoY9A8rmL0uXhccj7NQ6+LoyvyhZDvFGZg + ffsXua5DHOmLHmYN12IA+MF6NNMJ7c1CAaQERgd+6tZ2JHm3Kyy1YJdppDAoRMVC + 9Tavyej9WE4ScPGntqSXi33gScnRTEGuuC0HydomT/rmguSWx8oPumeWelSTCh9c + vZ9Q1NOnRlW/VrNbYyyByiaWEgdrM2E/z3p+MFgrIsYxnIGQ/Ql1FbT0LxbeIYzc + 9MT4cbOlMrD0SZVk9lyxnCs/c1pN7pXDHutmDg6JzSj0xW5AYKzKSvXKjy7+uQay + YVyYh/QhAoGBAPKL1cZJMqwdQBzHMaHChth5cMh8/IkU6m3U7Ll75dztmaLFce+Y + Ova6te/D5Cm/l9pxx+vL5fuAafc2/FTesmKkE2DEERvy4EOQqB1Uho6XEoBBfnJT + 0xmNY5Jvh0TfyquS23KvzezT7+epFYNhZDQwgWPnx2z+jwa/zn8Ows/nAoGBAPht + crkmXBMncO7CXzFzFbDghIitW9cZnqBTzKwr2k9lVsbioTIYDbGruvABwI5sN2b4 + gJqcvnkun7dmooRPAGX/nMl5UxeGhdSlYGVzHchZz/310MdEg/JThIV219sHR5fd + pBlrydWDyfDTkiGZHDiYUzuZ6hCyOjf+MUgGlyKfAoGBAKYblF1G9hgftC/BT8Fb + quQIT3BPANiU5XQwtarWKndilax/EmenVwJwnndFLjZVS5dEA0n+i1Px/yBanPc2 + yO57NfY4cQs2C9bZ8/iaUcjHt9j0gbekptdCGKZKEVbe+TsFyZrCwgHmp8984gnn + IiwH6CVWsCJ6N9PEepRTtKGTAoGAV/wTdKW0WIhQhA9NPas/1GxAJFQZwd3uA2SK + ibPiVtpSWJAtfRttxi5HP/eu5gJHwO1kRt4ay7qKkJ8GEgwU3Qsh0W1p01wui/ii + YmvZ8Xp1osFr1xdaD/oqZkaH/qfeYFf8ZZB6ZGePnv6fs8yRZS311JcXgiBNZEVf + 2N2Uq4sCgYAoVe3zkP37MjIH6nykFiR396den5ZyMflR42QtO0Z2QJuQKs6yZ7ii + cqQy4r1Z2i6bdtUlesyGF5U7BPvcers/Mczax0u81Y2S9PdIsv8cw8sr8M6HHiS3 + IWBJpVJNyoHKLusRTYVqti+b5EHXQ55FZ9EJggvceGbcBamZ+ynYrg== + -----END RSA PRIVATE KEY----- + """); + + // On Windows, a certificate loaded from PEM-encoded material is ephemeral and + // cannot be directly used with TLS, as Schannel cannot access it in this case. + // + // To work this limitation, the certificate is exported and re-imported from a + // PFX blob to ensure the private key is persisted in a way that Schannel can use. + // + // In a real world application, the certificate wouldn't be embedded in the source code + // and would be installed in the certificate store, making this workaround unnecessary. + if (OperatingSystem.IsWindows()) + { + certificate = X509CertificateLoader.LoadPkcs12( + data: certificate.Export(X509ContentType.Pfx, string.Empty), + password: string.Empty, + keyStorageFlags: X509KeyStorageFlags.DefaultKeySet); + } + + return new X509SigningCredentials(certificate); +} + +static SigningCredentials GetSigningKey() +{ + var algorithm = ECDsa.Create(); + algorithm.ImportFromPem($""" + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIMGxf/eMzKuW2F8KKWPJo3bwlrO68rK5+xCeO1atwja2oAoGCCqGSM49 + AwEHoUQDQgAEI23kaVsRRAWIez/pqEZOByJFmlXda6iSQ4QqcH23Ir8aYPPX5lsV + nBsExNsl7SOYOiIhgTaX6+PTS7yxTnmvSw== + -----END EC PRIVATE KEY----- + """); + + var key = new ECDsaSecurityKey(algorithm); + + return new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256, SecurityAlgorithms.Sha256); +} +#pragma warning restore CS8321 diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Startup.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Startup.cs deleted file mode 100644 index 002f08f0..00000000 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Startup.cs +++ /dev/null @@ -1,432 +0,0 @@ -using System.Net.Http; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.EntityFrameworkCore; -using Microsoft.IdentityModel.Tokens; -using OpenIddict.Client; -using OpenIddict.Client.WebIntegration; -using OpenIddict.Sandbox.AspNetCore.Client.Models; -using Quartz; -using static OpenIddict.Abstractions.OpenIddictConstants; - -namespace OpenIddict.Sandbox.AspNetCore.Client; - -public class Startup -{ - public Startup(IConfiguration configuration) - => Configuration = configuration; - - public IConfiguration Configuration { get; } - - public void ConfigureServices(IServiceCollection services) - { - services.AddDbContext(options => - { - // Configure the context to use Microsoft SQL Server. - options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-client.sqlite3")}"); - - // Register the entity sets needed by OpenIddict. - // Note: use the generic overload if you need - // to replace the default OpenIddict entities. - options.UseOpenIddict(); - }); - - services.AddAuthentication(options => - { - options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }) - - .AddCookie(options => - { - options.LoginPath = "/login"; - options.LogoutPath = "/logout"; - options.ExpireTimeSpan = TimeSpan.FromMinutes(50); - options.SlidingExpiration = false; - }); - - // OpenIddict offers native integration with Quartz.NET to perform scheduled tasks - // (like pruning orphaned authorizations from the database) at regular intervals. - services.AddQuartz(options => - { - options.UseSimpleTypeLoader(); - options.UseInMemoryStore(); - }); - - // Register the Quartz.NET service and configure it to block shutdown until jobs are complete. - services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); - - services.AddOpenIddict() - - // Register the OpenIddict core components. - .AddCore(options => - { - // Configure OpenIddict to use the Entity Framework Core stores and models. - // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. - options.UseEntityFrameworkCore() - .UseDbContext(); - - // Developers who prefer using MongoDB can remove the previous lines - // and configure OpenIddict to use the specified MongoDB database: - // options.UseMongoDb() - // .UseDatabase(new MongoClient().GetDatabase("openiddict")); - - // Enable Quartz.NET integration. - options.UseQuartz(); - }) - - // Register the OpenIddict client components. - .AddClient(options => - { - // Note: this sample uses the authorization code and refresh token - // flows, but you can enable the other flows if necessary. - options.AllowAuthorizationCodeFlow() - .AllowRefreshTokenFlow(); - - // Register the signing and encryption credentials used to protect - // sensitive data like the state tokens produced by OpenIddict. - options.AddDevelopmentEncryptionCertificate() - .AddDevelopmentSigningCertificate(); - - // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. - options.UseAspNetCore() - .EnableStatusCodePagesIntegration() - .EnableRedirectionEndpointPassthrough() - .EnablePostLogoutRedirectionEndpointPassthrough(); - - // Register the System.Net.Http integration and use the identity of the current - // assembly as a more specific user agent, which can be useful when dealing with - // providers that use the user agent as a way to throttle requests (e.g Reddit). - options.UseSystemNetHttp() - .SetProductInformation(typeof(Startup).Assembly); - - // Add a client registration matching the client application definition in the server project. - options.AddRegistration(new OpenIddictClientRegistration - { - Issuer = new Uri("https://localhost:44395/", UriKind.Absolute), - ProviderName = "Local", - ProviderDisplayName = "Local OIDC server", - - ClientId = "mvc", - Scopes = { Scopes.Email, Scopes.Profile, Scopes.OfflineAccess, "demo_api" }, - - RedirectUri = new Uri("callback/login/local", UriKind.Relative), - PostLogoutRedirectUri = new Uri("callback/logout/local", UriKind.Relative), - -#if SUPPORTS_PEM_ENCODED_KEY_IMPORT - // On supported platforms, this application can authenticate using 3 different client - // authentication methods that all offer a higher security level than shared client secrets: - // - // 1) tls_client_auth (PKI-based mutual TLS authentication): while it requires - // setting up a proper Public Key Infrastructure, this method offers a very - // high level of security, as the authorization server never has access to the - // private key used by the client to authenticate itself and can dynamically check - // the revocation status of the client certificate using standard PKI mechanisms. - // - // 2) self_signed_tls_client_auth (self-signed certificate-based mutual TLS authentication): - // this method is easier to deploy than PKI-based mutual TLS authentication, while - // still offering a high level of security. Unlike PKI-based mutual TLS authentication, - // the revocation status of the client certificate is never checked but certificates can - // be "revoked" by being removed from the JSON Web Key Set associated with the client. - // - // 3) private_key_jwt (JWT client assertions signed with a private key): while this - // method doesn't offer the same security guarantees as mutual TLS authentication, - // it is more secure than shared secrets and doesn't have the operational constraints - // required by the two mutual TLS methods described above (such as TLS configuration). - // - // The actual client authentication method used by the OpenIddict client is automatically - // selected based on the registered credentials and the methods supported by the server: - // when supported by the server, mutual TLS authentication methods are always preferred. - // - // In all cases, no client secret is necessary but the client needs to be able to access the - // private key of the certificate/key to be able to generate and sign the client assertions. - - SigningCredentials = - { - // Note: this certificate can be used with either tls_client_auth or private_key_jwt, - // depending on the server configuration (and the client authentication methods explicitly - // configured via OpenIddictClientRegistration.ClientAuthenticationMethods, if applicable). - // - GetPublicKeyInfrastructureCertificate(), - - // Note: this certificate can be used with either self_signed_tls_client_auth or private_key_jwt, - // depending on the server configuration (and the client authentication methods explicitly - // configured via OpenIddictClientRegistration.ClientAuthenticationMethods, if applicable): - // - // GetSelfSignedCertificate(), - - // Note: this key can only be used with private_key_jwt as raw keys cannot be used with TLS. - // GetSigningKey() - }, -#else - ClientSecret = "emCimpdc9SeOaZzN5jzm4_eek-STF6VenfVlKO1_qt0" -#endif - }); - - // Register the Web providers integrations. - // - // Note: to mitigate mix-up attacks, it's recommended to use a unique redirection endpoint - // URI per provider, unless all the registered providers support returning a special "iss" - // parameter containing their URL as part of authorization responses. For more information, - // see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-4.4. - options.UseWebProviders() - .AddGitHub(options => - { - options.SetClientId("c4ade52327b01ddacff3") - .SetClientSecret("da6bed851b75e317bf6b2cb67013679d9467c122") - .SetRedirectUri("callback/login/github"); - }) - .AddGoogle(options => - { - options.SetClientId("1016114395689-kgtgq2p6dj27d7v6e2kjkoj54dgrrckh.apps.googleusercontent.com") - .SetClientSecret("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") - .SetRedirectUri("callback/login/google") - .SetAccessType(OpenIddictClientWebIntegrationConstants.Google.AccessTypes.Offline) - .AddScopes(Scopes.Profile); - }) - .AddReddit(options => - { - options.SetClientId("vDLNqhrkwrvqHgnoBWF3og") - .SetClientSecret("Tpab28Dz0upyZLqn7AN3GFD1O-zaAw") - .SetRedirectUri("callback/login/reddit") - .SetDuration(OpenIddictClientWebIntegrationConstants.Reddit.Durations.Permanent); - }); - }); - - // Register a named HTTP client that will be used to call the demo resource API. - // - // Note: since the authorization server is configured to issue certificate-bound - // access tokens, the client certificate MUST be attached to outgoing HTTP requests - // and the mTLS subdomain (for which TLS client authentication is enabled) MUST be used. - services.AddHttpClient("ApiClient") -#if SUPPORTS_KEYED_HTTP_CLIENT_RESOLUTION - .AddAsKeyed() -#endif -#if SUPPORTS_PEM_ENCODED_KEY_IMPORT - .ConfigureHttpClient(static client => client.BaseAddress = new Uri("https://mtls.dev.localhost:44395/")) - .ConfigurePrimaryHttpMessageHandler(static () => new HttpClientHandler - { - ClientCertificateOptions = ClientCertificateOption.Manual, - ClientCertificates = { GetPublicKeyInfrastructureCertificate().Certificate } - }); -#else - .ConfigureHttpClient(static client => client.BaseAddress = new Uri("https://localhost:44395/")); -#endif - -#if !SUPPORTS_KEYED_HTTP_CLIENT_RESOLUTION - services.AddKeyedScoped("ApiClient", static (provider, name) => - { - var factory = provider.GetRequiredService(); - return factory.CreateClient((string) name!); - }); -#endif - - services.AddMvc(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseDeveloperExceptionPage(); - - app.UseStaticFiles(); - - app.UseStatusCodePagesWithReExecute("/error"); - -#if SUPPORTS_ENDPOINT_ROUTING - app.UseRouting(); -#endif - app.UseAuthentication(); - -#if SUPPORTS_AUTHORIZATION_MIDDLEWARE - app.UseAuthorization(); -#endif - -#if SUPPORTS_ENDPOINT_ROUTING - app.UseEndpoints(options => - { - options.MapControllers(); - options.MapDefaultControllerRoute(); - }); -#else - app.UseMvcWithDefaultRoute(); -#endif - } - -#if SUPPORTS_PEM_ENCODED_KEY_IMPORT -#pragma warning disable CS8321 - static X509SigningCredentials GetPublicKeyInfrastructureCertificate() - { - // Note: OpenIddict only negotiates PKI-based or self-signed mutual - // TLS authentication if the certificate explicitly contains the - // "digitalSignature" key usage and the "clientAuth" extended key usage. - var certificate = X509Certificate2.CreateFromPem( - certPem: $""" - -----BEGIN CERTIFICATE----- - MIIEezCCAmOgAwIBAgIRALTZE9ezjPCWDFr38cp6AMAwDQYJKoZIhvcNAQELBQAw - GjEYMBYGA1UEAxMPSW50ZXJtZWRpYXRlIENBMCAXDTI2MDIwMTE0MTQ0M1oYDzIx - MjYwMjAyMTQxNDQzWjAaMRgwFgYDVQQDEw9FbmQgY2VydGlmaWNhdGUwggEiMA0G - CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMs9spnvKeKw6VwPbpB47ikC6bL0Cn - S+K19Fp8dJg8b4dA1J1Y8dA2gi2nU/+ntOMYp1A6EvMZ8UpbgnSmhUN/2JQFU5Hc - PP0/IMjZAl2Iseh2yiK3Ril4Agbng6YW7e9P5YtMV+6i/stYujwNTXsUMr/+QSUI - Nze7856XSIl9gRjWEKJ17Jk/tJpun/zdpl4hXcptrsxxLU/E03bC3LcjiXzg8/Zl - 3/oEHqcHfv9C8RTdIBBw66zJAYzGfxwV31cJ9QQ2udlipi2l+ZR6jFWzzJI4XmiC - FzdwZRvhMLJsyK5miVIl0qPp3zJ2IyEb/2pLA0bc/ylZwVq6Z49k2xhZAgMBAAGj - gbkwgbYwDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww - CgYIKwYBBQUHAwIwHQYDVR0OBBYEFHPamNF/deBBv5JpDwiiRctPw4ziMEkGA1Ud - IwRCMECAFOEWwW18w3rZ6/5iIwAB12592OlHoRakFDASMRAwDgYDVQQDEwdSb290 - IENBghBvqw/xqI/LNgVfSURP9ck7MBQGA1UdEQQNMAuCCWxvY2FsaG9zdDANBgkq - hkiG9w0BAQsFAAOCAgEAbBq73JzDpK11hoRUxHq7LvplQEe/FNuD/slvn9Crfm2d - jJj0HsQQZpMgxP7SZ9FNvFqCo+/dm9PchIlwqwSjWtTxgYmcMOXw0Rzst85Ug4U1 - I2PG6iPxJ4WLSW2gzo//jFPa7MD1AnqDYwcCQTVsQW6aJavY3mFD31SJKsvSKqsV - 6xTXsajLRetCSXGe5qFgfyLC9tOhtTWXsCed/ISoQ9bljhOSqT6pxkpOVu0AHHMB - 1CMZay/B5ecjb66mwSoRcAPweMlAYJkjU5HXHSi7kB3gRQTsb1ZymEn67Q4C5cpI - Lq6UFK5bWZf1A0kFbYJBmn3oHsWxMQqv0F6QE7r4Mg6pfk9swzYZ8WqcgjiGHQET - pVU7ZKkUsg2JREXxRnhh5+Q+vGsF/DjhzQ6NrfPm8sqs+X+LzUN2cne8ZPclfyW2 - VKCHTPZ6o8mELiAlIPdBYUYsgUEOsfmUWbx4wfx5IB7vnenrenInLLyGOOCxR33d - o/gDMLFdeKHXK2ISsbDCk+zwEF8kztn1cXWK+K6H9cr8oJjDi1OJwTkqz9msar+9 - mjZ1CPAF0X+mLgrhVnNYqd5oqeeLerXKkAvpC2TgvlWJRGyDILhjva3J+2fQAYXZ - +OKFHNPf3n8Co4s5TMr1eiGVtS1etH6hPxnn5Jwnes9JZWFRLcjeTmPLSRWFucg= - -----END CERTIFICATE----- - """, - keyPem: $""" - -----BEGIN RSA PRIVATE KEY----- - MIIEpAIBAAKCAQEAzLPbKZ7ynisOlcD26QeO4pAumy9Ap0vitfRafHSYPG+HQNSd - WPHQNoItp1P/p7TjGKdQOhLzGfFKW4J0poVDf9iUBVOR3Dz9PyDI2QJdiLHodsoi - t0YpeAIG54OmFu3vT+WLTFfuov7LWLo8DU17FDK//kElCDc3u/Oel0iJfYEY1hCi - deyZP7Sabp/83aZeIV3Kba7McS1PxNN2wty3I4l84PP2Zd/6BB6nB37/QvEU3SAQ - cOusyQGMxn8cFd9XCfUENrnZYqYtpfmUeoxVs8ySOF5oghc3cGUb4TCybMiuZolS - JdKj6d8ydiMhG/9qSwNG3P8pWcFaumePZNsYWQIDAQABAoIBACorfyHC4d5dpmKJ - XxRAf1oDM+a6REpyoqCzVxS+fEIvA6ECa+vP3QHtrXQEJO2qoQIKLcfY8YXNpHDX - nipT18T1nADA55KEafNgUKAMEbLAW9Bk8ePpq09Ss5NsFoIwwBUoh5rRnpKrhL6h - lw9yf8F4dv7s8rEPlwa8OFaYFeLpoBLsPaX3nMu45CKb25dFZzSv9ORVs28LALrS - oK9MbtNFkmf/4EmpYA+nblkZd2bu4BomOF7C2F4bwtikN29vl4NPMhlbZGTy1hm9 - jzMOOvO1DwvIjHRVcfHKMDZ7cw1Pj5TmeApToSs6ygu1lce0GQcNVm+KV2qZMjNQ - Al6cdFUCgYEA7HZ6wvZU/WA7ei+jIwrJdyQQ3jU/LAu7GGhXiMU3z2RSR/vieY5R - 4IjQOgUkLBuQcy9uoQcSLpH/SNLIi6qhlMBvZuHq9QKF60t68tuW0PFSoa+SKaEn - DCZ70bnxo4OSRUtrzxikYHnwOvRGEli4EAOENETaQBKJUUygov/pOWMCgYEA3Z2a - TJlptRq75G6LHZvbBBzZdG9Mr04O6zvh5TGsJW86b6ov9BTAGz6Z37KWR1yUDfyH - dqNf90kJ8hs1eO6gGDQyGaH9yerrlULukANQfvpC0rEeJ7DfXSc1iLa3Q6+AOt5v - 9TkQY7s/47iOPoCmblZ4FeVcIMx88ms2mBRXshMCgYAN9pkdNiqio7Ifbvy1Lwfi - jzCnzoEierbbpB23J9450vTA53DiOLNBDRMuuer+58nJ430m6SH7ugdXJ4tMJBFS - lWJ+ssyLF1ENKfHisXDgeb+laJa6+pcxsnwRUGeifjx+9wswuYXLZKf48z/ICZEk - 8PA3nfE9Y1rUgC/kMDR3fQKBgQCyQRRdTICUJV7ATJIlTLmLw1C9sNBzqUuitlXq - rluS+LZ+HtvXbeFfiKjoH5N07ug/n8GuEZcdJmiTjoMiNH4dOc6ag4vJH+ZB9sZA - nAnhOJcLNV/V+RSQrvsGbkFWdhGkSEqxaibesTyghFAVwhEcavzIT+Yck55ktwwA - o0wudQKBgQDR0hyl/cf6MBgZ3gce6dOcznLKoa2icypmmfNkA6sqwXwW20/WfDGb - ZNdaL4U3xReSN1mzrs0yStq0UrAChwrwqJc6T7uhGR/lDjvJCeZP9zO2yCSBvtul - LWFkJnofc7NUYkhVSGaAMeT14xUY/XlFbkXp0jZOqKMRo7PeeeXZaQ== - -----END RSA PRIVATE KEY----- - """); - - // On Windows, a certificate loaded from PEM-encoded material is ephemeral and - // cannot be directly used with TLS, as Schannel cannot access it in this case. - // - // To work this limitation, the certificate is exported and re-imported from a - // PFX blob to ensure the private key is persisted in a way that Schannel can use. - // - // In a real world application, the certificate wouldn't be embedded in the source code - // and would be installed in the certificate store, making this workaround unnecessary. - if (OperatingSystem.IsWindows()) - { - certificate = X509CertificateLoader.LoadPkcs12( - data: certificate.Export(X509ContentType.Pfx, string.Empty), - password: string.Empty, - keyStorageFlags: X509KeyStorageFlags.DefaultKeySet); - } - - return new X509SigningCredentials(certificate); - } - - static X509SigningCredentials GetSelfSignedCertificate() - { - // Note: OpenIddict only negotiates PKI-based or self-signed mutual - // TLS authentication if the certificate explicitly contains the - // "digitalSignature" key usage and the "clientAuth" extended key usage. - var certificate = X509Certificate2.CreateFromPem( - certPem: $""" - -----BEGIN CERTIFICATE----- - MIIC8zCCAdugAwIBAgIJAIZ9BN3TUnZQMA0GCSqGSIb3DQEBCwUAMCIxIDAeBgNV - BAMTF1NlbGYtc2lnbmVkIGNlcnRpZmljYXRlMCAXDTI2MDIwMjE0MzM0OVoYDzIx - MjYwMjAyMTQzMzQ5WjAiMSAwHgYDVQQDExdTZWxmLXNpZ25lZCBjZXJ0aWZpY2F0 - ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOtfKVPM7ghVFh4U/sz4 - sTrpaNJGQ2NORqawYxAHwluhr101yIOW7rWvFlFncA64Lkq9SAbFFCVSAbo28c6B - 2Mi41jyC4LHQU11jhv08K/3FUuckCuzEpzTnXUhxJHWxrRDVEuvKINGPs1VgVtTT - ra8rjP8s1YRAzCYnByxSx+8GXNGHprylLh0agpWKb2+2FYwDqY5ME2g3xTL9FTUu - FYWTcyspsvN0U1Eo1vlCeOxSYGPRct0MK0AS6eXEGBv+3kCYI7a5+UhQok0WvErF - pjIVo7USISDgKhW9GhTsWN+WywwdG4Kx4V6SB8ZLAHFSBSR3gjWS3TGOyqAWoBXc - znkCAwEAAaMqMCgwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsGAQUF - BwMCMA0GCSqGSIb3DQEBCwUAA4IBAQBf5i/S7shmNalVxMuP8/Mk8cOhRRZjnAXd - zz3eOuXu0CH8iY/DwCgss04O2NTxuz87rKiuNKOrtY0oN/G4aFjWPvbgoQ+N1XP1 - zvbhqbyo3fQr07FyjWkrIUoHYFQ3JRfL+GPGjWizJsgdpdCRJSK6G9VX8eU3Akjv - YhMRLmbkrH5etOURqFtLpZlxNmLzCpqWIvzRiYyyj74iOipA2I0acgcvkakWn6rE - Wio7luBAZ3dXlukEfHTOg+ft4k0nOlRXPTtASOmyFQBOs6iYJeztHDz6MQnknAPe - +W53US8kLWktspcOQmxhVVH1g1/T4ynl9iX7tzqvUbdYwZNi92+x - -----END CERTIFICATE----- - """, - keyPem: $""" - -----BEGIN RSA PRIVATE KEY----- - MIIEpAIBAAKCAQEA618pU8zuCFUWHhT+zPixOulo0kZDY05GprBjEAfCW6GvXTXI - g5buta8WUWdwDrguSr1IBsUUJVIBujbxzoHYyLjWPILgsdBTXWOG/Twr/cVS5yQK - 7MSnNOddSHEkdbGtENUS68og0Y+zVWBW1NOtryuM/yzVhEDMJicHLFLH7wZc0Yem - vKUuHRqClYpvb7YVjAOpjkwTaDfFMv0VNS4VhZNzKymy83RTUSjW+UJ47FJgY9Fy - 3QwrQBLp5cQYG/7eQJgjtrn5SFCiTRa8SsWmMhWjtRIhIOAqFb0aFOxY35bLDB0b - grHhXpIHxksAcVIFJHeCNZLdMY7KoBagFdzOeQIDAQABAoIBAQDgBOqov9uuQo2S - hBkfrXPBxnXl7MomslG8RRWEJF5wKCtoY9A8rmL0uXhccj7NQ6+LoyvyhZDvFGZg - ffsXua5DHOmLHmYN12IA+MF6NNMJ7c1CAaQERgd+6tZ2JHm3Kyy1YJdppDAoRMVC - 9Tavyej9WE4ScPGntqSXi33gScnRTEGuuC0HydomT/rmguSWx8oPumeWelSTCh9c - vZ9Q1NOnRlW/VrNbYyyByiaWEgdrM2E/z3p+MFgrIsYxnIGQ/Ql1FbT0LxbeIYzc - 9MT4cbOlMrD0SZVk9lyxnCs/c1pN7pXDHutmDg6JzSj0xW5AYKzKSvXKjy7+uQay - YVyYh/QhAoGBAPKL1cZJMqwdQBzHMaHChth5cMh8/IkU6m3U7Ll75dztmaLFce+Y - Ova6te/D5Cm/l9pxx+vL5fuAafc2/FTesmKkE2DEERvy4EOQqB1Uho6XEoBBfnJT - 0xmNY5Jvh0TfyquS23KvzezT7+epFYNhZDQwgWPnx2z+jwa/zn8Ows/nAoGBAPht - crkmXBMncO7CXzFzFbDghIitW9cZnqBTzKwr2k9lVsbioTIYDbGruvABwI5sN2b4 - gJqcvnkun7dmooRPAGX/nMl5UxeGhdSlYGVzHchZz/310MdEg/JThIV219sHR5fd - pBlrydWDyfDTkiGZHDiYUzuZ6hCyOjf+MUgGlyKfAoGBAKYblF1G9hgftC/BT8Fb - quQIT3BPANiU5XQwtarWKndilax/EmenVwJwnndFLjZVS5dEA0n+i1Px/yBanPc2 - yO57NfY4cQs2C9bZ8/iaUcjHt9j0gbekptdCGKZKEVbe+TsFyZrCwgHmp8984gnn - IiwH6CVWsCJ6N9PEepRTtKGTAoGAV/wTdKW0WIhQhA9NPas/1GxAJFQZwd3uA2SK - ibPiVtpSWJAtfRttxi5HP/eu5gJHwO1kRt4ay7qKkJ8GEgwU3Qsh0W1p01wui/ii - YmvZ8Xp1osFr1xdaD/oqZkaH/qfeYFf8ZZB6ZGePnv6fs8yRZS311JcXgiBNZEVf - 2N2Uq4sCgYAoVe3zkP37MjIH6nykFiR396den5ZyMflR42QtO0Z2QJuQKs6yZ7ii - cqQy4r1Z2i6bdtUlesyGF5U7BPvcers/Mczax0u81Y2S9PdIsv8cw8sr8M6HHiS3 - IWBJpVJNyoHKLusRTYVqti+b5EHXQ55FZ9EJggvceGbcBamZ+ynYrg== - -----END RSA PRIVATE KEY----- - """); - - // On Windows, a certificate loaded from PEM-encoded material is ephemeral and - // cannot be directly used with TLS, as Schannel cannot access it in this case. - // - // To work this limitation, the certificate is exported and re-imported from a - // PFX blob to ensure the private key is persisted in a way that Schannel can use. - // - // In a real world application, the certificate wouldn't be embedded in the source code - // and would be installed in the certificate store, making this workaround unnecessary. - if (OperatingSystem.IsWindows()) - { - certificate = X509CertificateLoader.LoadPkcs12( - data: certificate.Export(X509ContentType.Pfx, string.Empty), - password: string.Empty, - keyStorageFlags: X509KeyStorageFlags.DefaultKeySet); - } - - return new X509SigningCredentials(certificate); - } - - static SigningCredentials GetSigningKey() - { - var algorithm = ECDsa.Create(); - algorithm.ImportFromPem($""" - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIMGxf/eMzKuW2F8KKWPJo3bwlrO68rK5+xCeO1atwja2oAoGCCqGSM49 - AwEHoUQDQgAEI23kaVsRRAWIez/pqEZOByJFmlXda6iSQ4QqcH23Ir8aYPPX5lsV - nBsExNsl7SOYOiIhgTaX6+PTS7yxTnmvSw== - -----END EC PRIVATE KEY----- - """); - - var key = new ECDsaSecurityKey(algorithm); - - return new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256, SecurityAlgorithms.Sha256); - } -#pragma warning restore CS8321 -#endif -} diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs index c9f36220..2c042402 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs @@ -117,18 +117,11 @@ public class AuthenticationController : Controller OpenIddictClientAspNetCoreConstants.Tokens.BackchannelAccessToken or OpenIddictClientAspNetCoreConstants.Tokens.RefreshToken)); -#if SUPPORTS_REDIRECTION_ON_SIGN_IN // Ask the default sign-in handler to return a new cookie and redirect the // user agent to the return URL stored in the authentication properties. // // For scenarios where the default sign-in handler configured in the ASP.NET Core // authentication options shouldn't be used, a specific scheme can be specified here. return SignIn(new ClaimsPrincipal(identity), properties); -#else - // Note: "return SignIn(...)" cannot be directly used as-is on ASP.NET Core <7.0, as the cookies handler - // doesn't allow redirecting from an endpoint that doesn't match the path set in the cookie options. - await HttpContext.SignInAsync(new ClaimsPrincipal(identity), properties); - return Redirect(properties.RedirectUri ?? "/"); -#endif } } diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Helpers/AsyncEnumerableExtensions.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Helpers/AsyncEnumerableExtensions.cs deleted file mode 100644 index 01adf0ee..00000000 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Helpers/AsyncEnumerableExtensions.cs +++ /dev/null @@ -1,28 +0,0 @@ -#if !SUPPORTS_ASYNC_LINQ -namespace OpenIddict.Sandbox.AspNetCore.Server.Helpers; - -public static class AsyncEnumerableExtensions -{ - public static Task> ToListAsync(this IAsyncEnumerable source) - { - if (source is null) - { - throw new ArgumentNullException(nameof(source)); - } - - return ExecuteAsync(); - - async Task> ExecuteAsync() - { - var list = new List(); - - await foreach (var element in source) - { - list.Add(element); - } - - return list; - } - } -} -#endif diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/OpenIddict.Sandbox.AspNetCore.Server.csproj b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/OpenIddict.Sandbox.AspNetCore.Server.csproj index b7311c4e..0fa209a0 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/OpenIddict.Sandbox.AspNetCore.Server.csproj +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/OpenIddict.Sandbox.AspNetCore.Server.csproj @@ -1,7 +1,7 @@  - net48;net10.0 + net10.0 false @@ -18,17 +18,4 @@ - - - - - - - - - - diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs index 844e42c7..6e983dbf 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs @@ -1,23 +1,384 @@ using System.Globalization; +using System.Net.Security; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.AspNetCore.Server.Kestrel.Https; +using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using OpenIddict.Abstractions; -using OpenIddict.Sandbox.AspNetCore.Server; using OpenIddict.Sandbox.AspNetCore.Server.Models; +using OpenIddict.Sandbox.AspNetCore.Server.Services; +using Quartz; using static OpenIddict.Abstractions.OpenIddictConstants; -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST -var builder = Host.CreateDefaultBuilder(args); -builder.ConfigureWebHostDefaults(builder => builder.UseStartup()); -#else -var builder = WebHost.CreateDefaultBuilder(args); -builder.UseStartup(); -#endif +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddMvc(); + +builder.Services.AddDbContext(options => +{ + options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-server.sqlite3")}"); + options.UseOpenIddict(); +}); + +// Register the Identity builder.Services. +builder.Services.AddIdentity() + .AddEntityFrameworkStores() + .AddDefaultTokenProviders(); + +// OpenIddict offers native integration with Quartz.NET to perform scheduled tasks +// (like pruning orphaned authorizations/tokens from the database) at regular intervals. +builder.Services.AddQuartz(options => +{ + options.UseSimpleTypeLoader(); + options.UseInMemoryStore(); +}); + +// Register the Quartz.NET service and configure it to block shutdown until jobs are complete. +builder.Services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); + +builder.Services.AddOpenIddict() + + // Register the OpenIddict core components. + .AddCore(options => + { + // Configure OpenIddict to use the Entity Framework Core stores and models. + options.UseEntityFrameworkCore() + .UseDbContext(); + + // Developers who prefer using MongoDB can remove the previous lines + // and configure OpenIddict to use the specified MongoDB database: + // options.UseMongoDb() + // .UseDatabase(new MongoClient().GetDatabase("openiddict")); + + // Enable Quartz.NET integration. + options.UseQuartz(); + }) + + // Register the OpenIddict client components. + .AddClient(options => + { + // Note: this sample uses the code flow, but you can enable the other flows if necessary. + options.AllowAuthorizationCodeFlow(); + + // Register the signing and encryption credentials used to protect + // sensitive data like the state tokens produced by OpenIddict. + options.AddDevelopmentEncryptionCertificate() + .AddDevelopmentSigningCertificate(); + + // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. + options.UseAspNetCore() + .EnableStatusCodePagesIntegration() + .EnableRedirectionEndpointPassthrough(); + + // Register the System.Net.Http integration and use the identity of the current + // assembly as a more specific user agent, which can be useful when dealing with + // providers that use the user agent as a way to throttle requests (e.g Reddit). + options.UseSystemNetHttp() + .SetProductInformation(typeof(Program).Assembly); + + // Register the Web providers integrations. + // + // Note: to mitigate mix-up attacks, it's recommended to use a unique redirection endpoint + // URI per provider, unless all the registered providers support returning a special "iss" + // parameter containing their URL as part of authorization responses. For more information, + // see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-4.4. + options.UseWebProviders() + .AddGitHub(options => + { + options.SetClientId("c4ade52327b01ddacff3") + .SetClientSecret("da6bed851b75e317bf6b2cb67013679d9467c122") + .SetRedirectUri("callback/login/github"); + }); + }) + + // Register the OpenIddict server components. + .AddServer(options => + { + // Enable the endpoints that will be used by the client applications. + options.SetAuthorizationEndpointUris("connect/authorize") + .SetDeviceAuthorizationEndpointUris("connect/device") + .SetEndSessionEndpointUris("connect/endsession") + .SetEndUserVerificationEndpointUris("connect/verify") + .SetIntrospectionEndpointUris("connect/introspect") + .SetPushedAuthorizationEndpointUris("connect/par") + .SetRevocationEndpointUris("connect/revoke") + .SetTokenEndpointUris("connect/token") + .SetUserInfoEndpointUris("connect/userinfo"); + + // Enable the flows that will be used by the client applications. + options.AllowAuthorizationCodeFlow() + .AllowDeviceAuthorizationFlow() + .AllowHybridFlow() + .AllowImplicitFlow() + .AllowNoneFlow() + .AllowPasswordFlow() + .AllowRefreshTokenFlow() + .AllowTokenExchangeFlow(); + + // Register the public scopes that will be exposed by the configuration endpoint. + options.RegisterScopes(Scopes.Email, Scopes.Profile, Scopes.Roles, "demo_api"); + + // Register the signing and encryption credentials. + options.AddDevelopmentEncryptionCertificate() + .AddDevelopmentSigningCertificate(); + + // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. + options.UseAspNetCore() + .EnableStatusCodePagesIntegration() + .EnableAuthorizationEndpointPassthrough() + .EnableEndSessionEndpointPassthrough() + .EnableEndUserVerificationEndpointPassthrough() + .EnableTokenEndpointPassthrough() + .EnableUserInfoEndpointPassthrough(); + + // Note: if you don't want to specify a client_id when sending + // a token or revocation request, uncomment the following line: + // + // options.AcceptAnonymousClients(); + + // Note: if you want to process authorization and token requests + // that specify non-registered scopes, uncomment the following line: + // + // options.DisableScopeValidation(); + + // Note: if you don't want to use permissions, you can disable + // permission enforcement by uncommenting the following lines: + // + // options.IgnoreEndpointPermissions() + // .IgnoreGrantTypePermissions() + // .IgnoreResponseTypePermissions() + // .IgnoreScopePermissions(); + + // Note: when issuing access tokens used by third-party APIs + // you don't own, you can disable access token encryption: + // + // options.DisableAccessTokenEncryption(); + + // Enable both tls_client_auth and self_signed_tls_client_auth to allow clients + // to authenticate using either PKI certificates or self-signed certificates. + // + // Note: PKI and self-signed certificate authentication can be enabled independently. + options.EnablePublicKeyInfrastructureTlsClientAuthentication( + [ + // Root certificate: + X509Certificate2.CreateFromPem($""" + -----BEGIN CERTIFICATE----- + MIIE7jCCAtagAwIBAgIJAN+SZB+xc7usMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV + BAMTB1Jvb3QgQ0EwIBcNMjYwMjAxMTQxNDQzWhgPMjEyNjAyMDIxNDE0NDNaMBIx + EDAOBgNVBAMTB1Jvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC + AQC68DOD6IvsJM0mc7n8bYeNaVe8e0ytJCJozdMPNXAe80vMPP4cVUPFvJ/tbSjX + yhREJ9xz2dYgQAhWCaTnEHY4AaE1Tj2rYqotenDQxs18qqaqoZlcaFfkRUPHRH3Q + iS8D8gbxzlYkjxNsfDJRi0cXFxr4wb4FmSP4ES2DFWWAWbN9wt7Tb2uDiHkjSefZ + Pni5F6fN6nE7wgGMYrdrCiiwJf7jEZiIZ60bsiUnJ5VUX6g4ob469CLocH/q/9Yr + Dad9/+YYp6SuHZilsPmW4X0fziuF/RvtsRLw4bw5jwj69KH3Y0jqUMQoyzz2CIJz + cDMB/MLREgcT9jTVB/M5Pl61DCzR/0d4t6RENpkNqpAIVM0Unp0nDuHPwjoeEZn3 + vSvUiGpiYY355GaSl05OE3SOKoRHt4lBXvY43y8fRBMOwlNHYn4eO3ZDuzZYzhfs + 68ywK4zUy47Qyn1BgNNqc/KC7kzxeLFxqTg2VJgBeXuJfucwzhOFqkOSfpeIGDK9 + 8MODFlA3usf5LXxQ7DJhkeBgPkW56BUlYVkenm9ORWe77GnoXL95p2HQUEXATHir + unXFPVcHET6hyegvc9AzSTZFQL4RMO3ZV5ESs+JF/YY4ycBc1+WYy2kAuP5sfsGn + mpeKf2Dv9MGFcDxU7iimeM92n7t5lbCRlX8NUaYeQ8jKgQIDAQABo0UwQzASBgNV + HRMBAf8ECDAGAQH/AgEBMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUyHIqQnw/ + x6e92OuJ+y+e0LSKSqQwDQYJKoZIhvcNAQELBQADggIBACCOjX4+RyoZt9tVoKdT + uGFoEJUGBUfcYaMdqiDstuSoNrqZXHnilzj33ZbNqj6X6rS1w5qVnkj7ZY4Wu8MP + Sj85Wp9cq0jMv3NfPZfKmJd2K7favGQKvgSPptSl9VgcIrpRam9BG2db1IP053tf + ydBB3w/yI7MTb4fkPqLWtKcuPPM8t9SsxAlKhEm+gbNEsqDX9ZIfxolHEpL2zLOi + a4v7+SlJdVBfo4mj+iLUeZXFRPglAnPQ3CZngfbPsjEklpOCU1v8TnhHwV8jyCgl + oLAceLjdlXHWVfhKU+N0jdAt8V2NPxq+yJ/gPX+J3YOrYRCHMdQZ/OFEUhmkxHNp + UUPkL1VJ9c8ZW2/gszFPyvsh7GHwl43y7bN8doiQVOSj6jZ7uCkQl1oz731fl97b + FqKVyGGx6UUEi57YS7mWsY02qNvYSObOxhSNusX/Ct06XbXS1Pn+co/3FMGMcEVf + IwzboV61sMqRu4l3YD0Z1AxdhXFERMlHBYyyj8CQYIXtnCUoeT40IIR3aFmEG5u8 + /lwehTnV4slDDMJMFSW54aENpT1XP4b8m46kioNhxN+7ukdcWnYoapePuiDRboA3 + GwRExwFUDiGO8zpnyvV4JTIGu9MZi51O3RbSlIDDhyzFsdQW3PeztwGjZWZAXD+7 + qIoAaBbG/12cvNeZH7L9Mcpo + -----END CERTIFICATE----- + """), + + // Intermediate certificate (optional): + X509Certificate2.CreateFromPem($""" + -----BEGIN CERTIFICATE----- + MIIFQzCCAyugAwIBAgIQb6sP8aiPyzYFX0lET/XJOzANBgkqhkiG9w0BAQsFADAS + MRAwDgYDVQQDEwdSb290IENBMCAXDTI2MDIwMTE0MTQ0M1oYDzIxMjYwMjAyMTQx + NDQzWjAaMRgwFgYDVQQDEw9JbnRlcm1lZGlhdGUgQ0EwggIiMA0GCSqGSIb3DQEB + AQUAA4ICDwAwggIKAoICAQCfObzu9v5dfio8kCCKpb0vLXUrilcOM6FGVx50rPtc + MjlHNG4GpghoLXjJxrUIsoeGdsCI6W+K3R+5PRlEsbCT3l/0n2/ixW3rN9rO3FOt + VGOHYrE2wI+i1aWP1/w/0bcCbH1J6PLKPv5syzhWWdkoTy2K72gye5Kx3zXkFQoC + uBFMvj3HBgmTngaDRTT1QGsRSlhuvoEiHHAvgoTfYt7bgbRhM5I5upEbXB0cucj7 + Ghzws5R2/4qsr/QorwA8l6aNeb1dm0uB+FlMVlGelYMZ76+SjBs1rOxD0qt82h13 + BYPBR4gLvNFafOEskFndeP3OkNaQ6kPm+uClj5OxwONnBcy7neJPqZGMtxpApLK3 + reK3IZ/ieg1nY9zZ7OkqIzQDt1CeCBQWU3RkpEtVojkRDLCmg+pKSjHtLxUUGiQ3 + UHrXO2Yrej8Qpx4JHdKGUfku25r4SSaj2YF61ZIvsDxlOMROfJUFbpQdyAtQPCCq + zpfkVKaCeCiTlifI6AZODngc9c8U+s7vLxjucz/Q4gNHwcgg/mASbjh8A2hYsbW6 + qeg7lE9k5t6Lv820FudjfgFiq7k+zIbNsDNy3Y7CSsgBHQQSyNFngg25PPQOon9c + yd3PiFK36OzktnRkcTs98i3fwO2+3pp6qgOSk1Sdx877egszMjBPFzxrBX9CXIpM + yQIDAQABo4GKMIGHMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEG + MB0GA1UdDgQWBBThFsFtfMN62ev+YiMAAddufdjpRzBCBgNVHSMEOzA5gBTIcipC + fD/Hp73Y64n7L57QtIpKpKEWpBQwEjEQMA4GA1UEAxMHUm9vdCBDQYIJAN+SZB+x + c7usMA0GCSqGSIb3DQEBCwUAA4ICAQA6sBGs28FWhKgh6TxZ6U8Lc+iCdc4c9PeM + L5pQQosHekT0oBJK8WdvyXZS95Fz2ddJaKiiQyUKSP4XHpxE+6tBt8OOV0LJJxnx + yKTBZtcSiOFssu2j6aqx3oMotRZJrhuI/5ChExaPwFT1W7aQDIY6lN2KcQ/xndbX + Nts/2nwCvlplfiOGM7XrRMU8b4X+AVWXSksvLXiByrDh9W6WGDsBHyu+FKQVnwmW + QVnshKpwxIsW25JDOhFE8+VHn6yciUKUTqnCFt5HjZpZh00q8hhmlhrNBEdkxA8N + OF7S1uWWftJywqq23qG6pGIDQ1r1dwNzgaeNhmW6QKm2zBXUmuOW//Xt+1wtHrly + bDjXKKSa/zhR9plYPdvGe9PopXwTw/fQWRYcxML6aH+WbWY9AgCHFgY56YCJYZd9 + eUIfrvPVJLn8fqwLmsWQtIY+XkAS/YQ4wTQs0zZS3+bdxeGQ6oHIMgxCDiBK8Qcc + RHf+RvYHiBllOJmaRaJHdsauMk9IlYYYpxPPwuWGti9B5HI4JO6bIqmR5Q8x3L/g + tFGMPzvWDTA2+dQcrh7WKULDH9Ngnnoodc6Hb9Iv1yCGYahcS6ARt9BzRyG1+6d9 + bq/zCH8KQCjryiTn3ZEpsln/iXtp5nHiLegUc1OoXldrUKAz9V93l61GHUw1kdhD + V+KJceDj3Q== + -----END CERTIFICATE----- + """) + ]); + + options.EnableSelfSignedTlsClientAuthentication(); + + // Note: setting a static issuer is mandatory when using mTLS aliases to ensure it not + // dynamically computed based on the request URI, as this would result in two different + // issuers being used (one pointing to the mTLS domain and one pointing to the regular one). + options.SetIssuer("https://localhost:44395/"); + + // Configure the mTLS endpoint aliases that will be used by client applications opting + // for TLS-based client authentication to communicate with the authorization server: + // the configured URIs MUST point to a domain for which the HTTPS server is configured + // to require the use of client certificates when receiving TLS handshakes from clients. + // + // Using mTLS endpoint aliases is not mandatory but is strongly recommended to avoid + // severely degrading the experience of users of browser-based clients, as TLS client + // authentication can only be enforced globally and not per-client, which would result + // in certificate selection prompts being systematically displayed by browsers. + options.SetMtlsDeviceAuthorizationEndpointAliasUri("https://mtls.dev.localhost:44395/connect/device") + .SetMtlsIntrospectionEndpointAliasUri("https://mtls.dev.localhost:44395/connect/introspect") + .SetMtlsPushedAuthorizationEndpointAliasUri("https://mtls.dev.localhost:44395/connect/par") + .SetMtlsRevocationEndpointAliasUri("https://mtls.dev.localhost:44395/connect/revoke") + .SetMtlsTokenEndpointAliasUri("https://mtls.dev.localhost:44395/connect/token") + .SetMtlsUserInfoEndpointAliasUri("https://mtls.dev.localhost:44395/connect/userinfo"); + + // While public client applications cannot use mTLS for client authentication, they can use + // mTLS purely as a token binding mechanism: in this case, the refresh tokens issued to + // public clients sending a client certificate are automatically bound to the certificate, + // which requires sending the same certificate when using them to get new access tokens. + options.UseClientCertificateBoundRefreshTokens(); + + // Optionally, the server stack can be configured to issue client certificate-bound access tokens. + // + // When doing so, the standard "cnf" claim is automatically added to access tokens to inform + // resource servers that a proof of possession derived from the certificate must be provided. + options.UseClientCertificateBoundAccessTokens(); + }) + + // Register the OpenIddict validation components. + .AddValidation(options => + { + // Configure the audience accepted by this resource server. + // The value MUST match the audience associated with the + // "demo_api" scope, which is used by ResourceController. + options.AddAudiences("resource_server"); + + // Import the configuration from the local OpenIddict server instance. + options.UseLocalServer(); + + // Instead of validating the token locally by reading it directly, + // introspection can be used to ask a remote authorization server + // to validate the token (and its attached database entry). + // + // options.UseIntrospection() + // .SetIssuer("https://localhost:44395/") + // .SetClientId("resource_server") + // .SetClientSecret("vVQ-yjr42sXP5VHj6AswkXuS7MU1i2gFjvJjY0TdGMk"); + // + // When introspection is used, the System.Net.Http integration must be enabled. + // + // options.UseSystemNetHttp(); + + // Register the ASP.NET Core host. + options.UseAspNetCore(); + + // For applications that need immediate access token or authorization + // revocation, the database entry of the received tokens and their + // associated authorizations can be validated for each API call. + // Enabling these options may have a negative impact on performance. + // + // options.EnableAuthorizationEntryValidation(); + // options.EnableTokenEntryValidation(); + }); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +// Configure Kestrel to listen on the 44395 port and configure it to enforce mTLS. +// +// Note: depending on the operating system, the mtls.dev.localhost +// subdomain MAY have to be manually mapped to 127.0.0.1 or ::1. +builder.Services.Configure(options => options.ListenAnyIP(44395, options => +{ + options.UseHttps(new TlsHandshakeCallbackOptions + { + OnConnection = GetServerAuthenticationOptionsAsync + }); + + static ValueTask GetServerAuthenticationOptionsAsync(TlsHandshakeCallbackContext context) + { + using var store = new X509Store(StoreName.My, StoreLocation.CurrentUser); + store.Open(OpenFlags.ReadOnly); + + return ValueTask.FromResult(new SslServerAuthenticationOptions + { + // Require a client certificate for all the requests pointing to the mTLS subdomain. + ClientCertificateRequired = string.Equals(context.ClientHelloInfo.ServerName, + "mtls.dev.localhost", StringComparison.OrdinalIgnoreCase), + + // Ignore all the client certificate errors for requests pointing to + // the mTLS-specific domain, even if they indicate that the chain is + // invalid: this is necessary to allow OpenIddict to validate the PKI + // and self-signed certificates using its own per-client chain policies. + RemoteCertificateValidationCallback = (sender, certificate, chain, errors) => + { + if (string.Equals(context.ClientHelloInfo.ServerName, + "mtls.dev.localhost", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + return errors is SslPolicyErrors.None or SslPolicyErrors.RemoteCertificateNotAvailable; + }, + + // Use the development certificate generated and stored by ASP.NET Core in the user store. + ServerCertificate = store.Certificates + .Find(X509FindType.FindByExtension, "1.3.6.1.4.1.311.84.1.1", validOnly: false) + .Cast() + .Where(static certificate => certificate.NotBefore < TimeProvider.System.GetLocalNow()) + .Where(static certificate => certificate.NotAfter > TimeProvider.System.GetLocalNow()) + .OrderByDescending(static certificate => certificate.NotAfter) + .FirstOrDefault() ?? + throw new InvalidOperationException("The ASP.NET Core HTTPS development certificate was not found.") + }); + } +})); var app = builder.Build(); +app.UseDeveloperExceptionPage(); + +app.UseStaticFiles(); + +app.UseStatusCodePagesWithReExecute("/error"); +app.UseRouting(); + +app.UseRequestLocalization(options => +{ + options.AddSupportedCultures("en-US", "fr-FR"); + options.AddSupportedUICultures("en-US", "fr-FR"); + options.SetDefaultCulture("en-US"); +}); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.MapControllers(); +app.MapDefaultControllerRoute(); + // Before starting the host, create the database used to store the application data. // // Note: in a real world application, this step should be part of a setup script. @@ -161,7 +522,6 @@ static async Task RegisterApplicationsAsync(IServiceProvider provider) { [CultureInfo.GetCultureInfo("fr-FR")] = "Application cliente MVC" }, -#if SUPPORTS_PEM_ENCODED_KEY_IMPORT JsonWebKeySet = new JsonWebKeySet { Keys = @@ -207,7 +567,6 @@ static async Task RegisterApplicationsAsync(IServiceProvider provider) """)) } }, -#endif RedirectUris = { new Uri("https://localhost:44381/callback/login/local") @@ -396,7 +755,6 @@ static async Task RegisterApplicationsAsync(IServiceProvider provider) await manager.CreateAsync(descriptor); } -#if SUPPORTS_PEM_ENCODED_KEY_IMPORT static ECDsaSecurityKey GetECDsaSigningKey(ReadOnlySpan key) { var algorithm = ECDsa.Create(); @@ -404,7 +762,6 @@ static async Task RegisterApplicationsAsync(IServiceProvider provider) return new ECDsaSecurityKey(algorithm); } -#endif } static async Task RegisterScopesAsync(IServiceProvider provider) diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Startup.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Startup.cs deleted file mode 100644 index ecb61f04..00000000 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Startup.cs +++ /dev/null @@ -1,405 +0,0 @@ -using System.Net.Security; -using System.Security.Cryptography.X509Certificates; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.AspNetCore.Server.Kestrel.Https; -using Microsoft.EntityFrameworkCore; -using OpenIddict.Sandbox.AspNetCore.Server.Models; -using OpenIddict.Sandbox.AspNetCore.Server.Services; -using Quartz; -using static OpenIddict.Abstractions.OpenIddictConstants; - -namespace OpenIddict.Sandbox.AspNetCore.Server; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(); - - services.AddDbContext(options => - { - // Configure the context to use Microsoft SQL Server. - options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-server.sqlite3")}"); - - // Register the entity sets needed by OpenIddict. - // Note: use the generic overload if you need - // to replace the default OpenIddict entities. - options.UseOpenIddict(); - }); - - // Register the Identity services. - services.AddIdentity() - .AddEntityFrameworkStores() - .AddDefaultTokenProviders(); - - // OpenIddict offers native integration with Quartz.NET to perform scheduled tasks - // (like pruning orphaned authorizations/tokens from the database) at regular intervals. - services.AddQuartz(options => - { - options.UseSimpleTypeLoader(); - options.UseInMemoryStore(); - }); - - // Register the Quartz.NET service and configure it to block shutdown until jobs are complete. - services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); - - services.AddOpenIddict() - - // Register the OpenIddict core components. - .AddCore(options => - { - // Configure OpenIddict to use the Entity Framework Core stores and models. - // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. - options.UseEntityFrameworkCore() - .UseDbContext(); - - // Developers who prefer using MongoDB can remove the previous lines - // and configure OpenIddict to use the specified MongoDB database: - // options.UseMongoDb() - // .UseDatabase(new MongoClient().GetDatabase("openiddict")); - - // Enable Quartz.NET integration. - options.UseQuartz(); - }) - - // Register the OpenIddict client components. - .AddClient(options => - { - // Note: this sample uses the code flow, but you can enable the other flows if necessary. - options.AllowAuthorizationCodeFlow(); - - // Register the signing and encryption credentials used to protect - // sensitive data like the state tokens produced by OpenIddict. - options.AddDevelopmentEncryptionCertificate() - .AddDevelopmentSigningCertificate(); - - // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. - options.UseAspNetCore() - .EnableStatusCodePagesIntegration() - .EnableRedirectionEndpointPassthrough(); - - // Register the System.Net.Http integration and use the identity of the current - // assembly as a more specific user agent, which can be useful when dealing with - // providers that use the user agent as a way to throttle requests (e.g Reddit). - options.UseSystemNetHttp() - .SetProductInformation(typeof(Startup).Assembly); - - // Register the Web providers integrations. - // - // Note: to mitigate mix-up attacks, it's recommended to use a unique redirection endpoint - // URI per provider, unless all the registered providers support returning a special "iss" - // parameter containing their URL as part of authorization responses. For more information, - // see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-4.4. - options.UseWebProviders() - .AddGitHub(options => - { - options.SetClientId("c4ade52327b01ddacff3") - .SetClientSecret("da6bed851b75e317bf6b2cb67013679d9467c122") - .SetRedirectUri("callback/login/github"); - }); - }) - - // Register the OpenIddict server components. - .AddServer(options => - { - // Enable the endpoints that will be used by the client applications. - options.SetAuthorizationEndpointUris("connect/authorize") - .SetDeviceAuthorizationEndpointUris("connect/device") - .SetEndSessionEndpointUris("connect/endsession") - .SetEndUserVerificationEndpointUris("connect/verify") - .SetIntrospectionEndpointUris("connect/introspect") - .SetPushedAuthorizationEndpointUris("connect/par") - .SetRevocationEndpointUris("connect/revoke") - .SetTokenEndpointUris("connect/token") - .SetUserInfoEndpointUris("connect/userinfo"); - - // Enable the flows that will be used by the client applications. - options.AllowAuthorizationCodeFlow() - .AllowDeviceAuthorizationFlow() - .AllowHybridFlow() - .AllowImplicitFlow() - .AllowNoneFlow() - .AllowPasswordFlow() - .AllowRefreshTokenFlow() - .AllowTokenExchangeFlow(); - - // Register the public scopes that will be exposed by the configuration endpoint. - options.RegisterScopes(Scopes.Email, Scopes.Profile, Scopes.Roles, "demo_api"); - - // Register the signing and encryption credentials. - options.AddDevelopmentEncryptionCertificate() - .AddDevelopmentSigningCertificate(); - - // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. - options.UseAspNetCore() - .EnableStatusCodePagesIntegration() - .EnableAuthorizationEndpointPassthrough() - .EnableEndSessionEndpointPassthrough() - .EnableEndUserVerificationEndpointPassthrough() - .EnableTokenEndpointPassthrough() - .EnableUserInfoEndpointPassthrough(); - - // Note: if you don't want to specify a client_id when sending - // a token or revocation request, uncomment the following line: - // - // options.AcceptAnonymousClients(); - - // Note: if you want to process authorization and token requests - // that specify non-registered scopes, uncomment the following line: - // - // options.DisableScopeValidation(); - - // Note: if you don't want to use permissions, you can disable - // permission enforcement by uncommenting the following lines: - // - // options.IgnoreEndpointPermissions() - // .IgnoreGrantTypePermissions() - // .IgnoreResponseTypePermissions() - // .IgnoreScopePermissions(); - - // Note: when issuing access tokens used by third-party APIs - // you don't own, you can disable access token encryption: - // - // options.DisableAccessTokenEncryption(); - -#if SUPPORTS_KESTREL_TLS_HANDSHAKE_CALLBACK_OPTIONS - // Enable both tls_client_auth and self_signed_tls_client_auth to allow clients - // to authenticate using either PKI certificates or self-signed certificates. - // - // Note: PKI and self-signed certificate authentication can be enabled independently. - options.EnablePublicKeyInfrastructureTlsClientAuthentication( - [ - // Root certificate: - X509Certificate2.CreateFromPem($""" - -----BEGIN CERTIFICATE----- - MIIE7jCCAtagAwIBAgIJAN+SZB+xc7usMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV - BAMTB1Jvb3QgQ0EwIBcNMjYwMjAxMTQxNDQzWhgPMjEyNjAyMDIxNDE0NDNaMBIx - EDAOBgNVBAMTB1Jvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC - AQC68DOD6IvsJM0mc7n8bYeNaVe8e0ytJCJozdMPNXAe80vMPP4cVUPFvJ/tbSjX - yhREJ9xz2dYgQAhWCaTnEHY4AaE1Tj2rYqotenDQxs18qqaqoZlcaFfkRUPHRH3Q - iS8D8gbxzlYkjxNsfDJRi0cXFxr4wb4FmSP4ES2DFWWAWbN9wt7Tb2uDiHkjSefZ - Pni5F6fN6nE7wgGMYrdrCiiwJf7jEZiIZ60bsiUnJ5VUX6g4ob469CLocH/q/9Yr - Dad9/+YYp6SuHZilsPmW4X0fziuF/RvtsRLw4bw5jwj69KH3Y0jqUMQoyzz2CIJz - cDMB/MLREgcT9jTVB/M5Pl61DCzR/0d4t6RENpkNqpAIVM0Unp0nDuHPwjoeEZn3 - vSvUiGpiYY355GaSl05OE3SOKoRHt4lBXvY43y8fRBMOwlNHYn4eO3ZDuzZYzhfs - 68ywK4zUy47Qyn1BgNNqc/KC7kzxeLFxqTg2VJgBeXuJfucwzhOFqkOSfpeIGDK9 - 8MODFlA3usf5LXxQ7DJhkeBgPkW56BUlYVkenm9ORWe77GnoXL95p2HQUEXATHir - unXFPVcHET6hyegvc9AzSTZFQL4RMO3ZV5ESs+JF/YY4ycBc1+WYy2kAuP5sfsGn - mpeKf2Dv9MGFcDxU7iimeM92n7t5lbCRlX8NUaYeQ8jKgQIDAQABo0UwQzASBgNV - HRMBAf8ECDAGAQH/AgEBMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUyHIqQnw/ - x6e92OuJ+y+e0LSKSqQwDQYJKoZIhvcNAQELBQADggIBACCOjX4+RyoZt9tVoKdT - uGFoEJUGBUfcYaMdqiDstuSoNrqZXHnilzj33ZbNqj6X6rS1w5qVnkj7ZY4Wu8MP - Sj85Wp9cq0jMv3NfPZfKmJd2K7favGQKvgSPptSl9VgcIrpRam9BG2db1IP053tf - ydBB3w/yI7MTb4fkPqLWtKcuPPM8t9SsxAlKhEm+gbNEsqDX9ZIfxolHEpL2zLOi - a4v7+SlJdVBfo4mj+iLUeZXFRPglAnPQ3CZngfbPsjEklpOCU1v8TnhHwV8jyCgl - oLAceLjdlXHWVfhKU+N0jdAt8V2NPxq+yJ/gPX+J3YOrYRCHMdQZ/OFEUhmkxHNp - UUPkL1VJ9c8ZW2/gszFPyvsh7GHwl43y7bN8doiQVOSj6jZ7uCkQl1oz731fl97b - FqKVyGGx6UUEi57YS7mWsY02qNvYSObOxhSNusX/Ct06XbXS1Pn+co/3FMGMcEVf - IwzboV61sMqRu4l3YD0Z1AxdhXFERMlHBYyyj8CQYIXtnCUoeT40IIR3aFmEG5u8 - /lwehTnV4slDDMJMFSW54aENpT1XP4b8m46kioNhxN+7ukdcWnYoapePuiDRboA3 - GwRExwFUDiGO8zpnyvV4JTIGu9MZi51O3RbSlIDDhyzFsdQW3PeztwGjZWZAXD+7 - qIoAaBbG/12cvNeZH7L9Mcpo - -----END CERTIFICATE----- - """), - - // Intermediate certificate (optional): - X509Certificate2.CreateFromPem($""" - -----BEGIN CERTIFICATE----- - MIIFQzCCAyugAwIBAgIQb6sP8aiPyzYFX0lET/XJOzANBgkqhkiG9w0BAQsFADAS - MRAwDgYDVQQDEwdSb290IENBMCAXDTI2MDIwMTE0MTQ0M1oYDzIxMjYwMjAyMTQx - NDQzWjAaMRgwFgYDVQQDEw9JbnRlcm1lZGlhdGUgQ0EwggIiMA0GCSqGSIb3DQEB - AQUAA4ICDwAwggIKAoICAQCfObzu9v5dfio8kCCKpb0vLXUrilcOM6FGVx50rPtc - MjlHNG4GpghoLXjJxrUIsoeGdsCI6W+K3R+5PRlEsbCT3l/0n2/ixW3rN9rO3FOt - VGOHYrE2wI+i1aWP1/w/0bcCbH1J6PLKPv5syzhWWdkoTy2K72gye5Kx3zXkFQoC - uBFMvj3HBgmTngaDRTT1QGsRSlhuvoEiHHAvgoTfYt7bgbRhM5I5upEbXB0cucj7 - Ghzws5R2/4qsr/QorwA8l6aNeb1dm0uB+FlMVlGelYMZ76+SjBs1rOxD0qt82h13 - BYPBR4gLvNFafOEskFndeP3OkNaQ6kPm+uClj5OxwONnBcy7neJPqZGMtxpApLK3 - reK3IZ/ieg1nY9zZ7OkqIzQDt1CeCBQWU3RkpEtVojkRDLCmg+pKSjHtLxUUGiQ3 - UHrXO2Yrej8Qpx4JHdKGUfku25r4SSaj2YF61ZIvsDxlOMROfJUFbpQdyAtQPCCq - zpfkVKaCeCiTlifI6AZODngc9c8U+s7vLxjucz/Q4gNHwcgg/mASbjh8A2hYsbW6 - qeg7lE9k5t6Lv820FudjfgFiq7k+zIbNsDNy3Y7CSsgBHQQSyNFngg25PPQOon9c - yd3PiFK36OzktnRkcTs98i3fwO2+3pp6qgOSk1Sdx877egszMjBPFzxrBX9CXIpM - yQIDAQABo4GKMIGHMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEG - MB0GA1UdDgQWBBThFsFtfMN62ev+YiMAAddufdjpRzBCBgNVHSMEOzA5gBTIcipC - fD/Hp73Y64n7L57QtIpKpKEWpBQwEjEQMA4GA1UEAxMHUm9vdCBDQYIJAN+SZB+x - c7usMA0GCSqGSIb3DQEBCwUAA4ICAQA6sBGs28FWhKgh6TxZ6U8Lc+iCdc4c9PeM - L5pQQosHekT0oBJK8WdvyXZS95Fz2ddJaKiiQyUKSP4XHpxE+6tBt8OOV0LJJxnx - yKTBZtcSiOFssu2j6aqx3oMotRZJrhuI/5ChExaPwFT1W7aQDIY6lN2KcQ/xndbX - Nts/2nwCvlplfiOGM7XrRMU8b4X+AVWXSksvLXiByrDh9W6WGDsBHyu+FKQVnwmW - QVnshKpwxIsW25JDOhFE8+VHn6yciUKUTqnCFt5HjZpZh00q8hhmlhrNBEdkxA8N - OF7S1uWWftJywqq23qG6pGIDQ1r1dwNzgaeNhmW6QKm2zBXUmuOW//Xt+1wtHrly - bDjXKKSa/zhR9plYPdvGe9PopXwTw/fQWRYcxML6aH+WbWY9AgCHFgY56YCJYZd9 - eUIfrvPVJLn8fqwLmsWQtIY+XkAS/YQ4wTQs0zZS3+bdxeGQ6oHIMgxCDiBK8Qcc - RHf+RvYHiBllOJmaRaJHdsauMk9IlYYYpxPPwuWGti9B5HI4JO6bIqmR5Q8x3L/g - tFGMPzvWDTA2+dQcrh7WKULDH9Ngnnoodc6Hb9Iv1yCGYahcS6ARt9BzRyG1+6d9 - bq/zCH8KQCjryiTn3ZEpsln/iXtp5nHiLegUc1OoXldrUKAz9V93l61GHUw1kdhD - V+KJceDj3Q== - -----END CERTIFICATE----- - """) - ]); - - options.EnableSelfSignedTlsClientAuthentication(); - - // Note: setting a static issuer is mandatory when using mTLS aliases to ensure it not - // dynamically computed based on the request URI, as this would result in two different - // issuers being used (one pointing to the mTLS domain and one pointing to the regular one). - options.SetIssuer("https://localhost:44395/"); - - // Configure the mTLS endpoint aliases that will be used by client applications opting - // for TLS-based client authentication to communicate with the authorization server: - // the configured URIs MUST point to a domain for which the HTTPS server is configured - // to require the use of client certificates when receiving TLS handshakes from clients. - // - // Using mTLS endpoint aliases is not mandatory but is strongly recommended to avoid - // severely degrading the experience of users of browser-based clients, as TLS client - // authentication can only be enforced globally and not per-client, which would result - // in certificate selection prompts being systematically displayed by browsers. - options.SetMtlsDeviceAuthorizationEndpointAliasUri("https://mtls.dev.localhost:44395/connect/device") - .SetMtlsIntrospectionEndpointAliasUri("https://mtls.dev.localhost:44395/connect/introspect") - .SetMtlsPushedAuthorizationEndpointAliasUri("https://mtls.dev.localhost:44395/connect/par") - .SetMtlsRevocationEndpointAliasUri("https://mtls.dev.localhost:44395/connect/revoke") - .SetMtlsTokenEndpointAliasUri("https://mtls.dev.localhost:44395/connect/token") - .SetMtlsUserInfoEndpointAliasUri("https://mtls.dev.localhost:44395/connect/userinfo"); - - // While public client applications cannot use mTLS for client authentication, they can use - // mTLS purely as a token binding mechanism: in this case, the refresh tokens issued to - // public clients sending a client certificate are automatically bound to the certificate, - // which requires sending the same certificate when using them to get new access tokens. - options.UseClientCertificateBoundRefreshTokens(); - - // Optionally, the server stack can be configured to issue client certificate-bound access tokens. - // - // When doing so, the standard "cnf" claim is automatically added to access tokens to inform - // resource servers that a proof of possession derived from the certificate must be provided. - options.UseClientCertificateBoundAccessTokens(); -#endif - }) - - // Register the OpenIddict validation components. - .AddValidation(options => - { - // Configure the audience accepted by this resource server. - // The value MUST match the audience associated with the - // "demo_api" scope, which is used by ResourceController. - options.AddAudiences("resource_server"); - - // Import the configuration from the local OpenIddict server instance. - options.UseLocalServer(); - - // Instead of validating the token locally by reading it directly, - // introspection can be used to ask a remote authorization server - // to validate the token (and its attached database entry). - // - // options.UseIntrospection() - // .SetIssuer("https://localhost:44395/") - // .SetClientId("resource_server") - // .SetClientSecret("vVQ-yjr42sXP5VHj6AswkXuS7MU1i2gFjvJjY0TdGMk"); - // - // When introspection is used, the System.Net.Http integration must be enabled. - // - // options.UseSystemNetHttp(); - - // Register the ASP.NET Core host. - options.UseAspNetCore(); - - // For applications that need immediate access token or authorization - // revocation, the database entry of the received tokens and their - // associated authorizations can be validated for each API call. - // Enabling these options may have a negative impact on performance. - // - // options.EnableAuthorizationEntryValidation(); - // options.EnableTokenEntryValidation(); - }); - - services.AddTransient(); - services.AddTransient(); - -#if SUPPORTS_KESTREL_TLS_HANDSHAKE_CALLBACK_OPTIONS - // Configure Kestrel to listen on the 44395 port and configure it to enforce mTLS. - // - // Note: depending on the operating system, the mtls.dev.localhost - // subdomain MAY have to be manually mapped to 127.0.0.1 or ::1. - services.Configure(options => options.ListenAnyIP(44395, options => - { - options.UseHttps(new TlsHandshakeCallbackOptions - { - OnConnection = GetServerAuthenticationOptionsAsync - }); - })); - - static ValueTask GetServerAuthenticationOptionsAsync(TlsHandshakeCallbackContext context) - { - using var store = new X509Store(StoreName.My, StoreLocation.CurrentUser); - store.Open(OpenFlags.ReadOnly); - - return ValueTask.FromResult(new SslServerAuthenticationOptions - { - // Require a client certificate for all the requests pointing to the mTLS subdomain. - ClientCertificateRequired = string.Equals(context.ClientHelloInfo.ServerName, - "mtls.dev.localhost", StringComparison.OrdinalIgnoreCase), - - // Ignore all the client certificate errors for requests pointing to - // the mTLS-specific domain, even if they indicate that the chain is - // invalid: this is necessary to allow OpenIddict to validate the PKI - // and self-signed certificates using its own per-client chain policies. - RemoteCertificateValidationCallback = (sender, certificate, chain, errors) => - { - if (string.Equals(context.ClientHelloInfo.ServerName, - "mtls.dev.localhost", StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - return errors is SslPolicyErrors.None or SslPolicyErrors.RemoteCertificateNotAvailable; - }, - - // Use the development certificate generated and stored by ASP.NET Core in the user store. - ServerCertificate = store.Certificates - .Find(X509FindType.FindByExtension, "1.3.6.1.4.1.311.84.1.1", validOnly: false) - .Cast() - .Where(static certificate => certificate.NotBefore < TimeProvider.System.GetLocalNow()) - .Where(static certificate => certificate.NotAfter > TimeProvider.System.GetLocalNow()) - .OrderByDescending(static certificate => certificate.NotAfter) - .FirstOrDefault() ?? - throw new InvalidOperationException("The ASP.NET Core HTTPS development certificate was not found.") - }); - } -#endif - } - - public void Configure(IApplicationBuilder app) - { - app.UseDeveloperExceptionPage(); - - app.UseStaticFiles(); - - app.UseStatusCodePagesWithReExecute("/error"); - -#if SUPPORTS_ENDPOINT_ROUTING - app.UseRouting(); -#endif - app.UseRequestLocalization(options => - { - options.AddSupportedCultures("en-US", "fr-FR"); - options.AddSupportedUICultures("en-US", "fr-FR"); - options.SetDefaultCulture("en-US"); - }); - - app.UseAuthentication(); - -#if SUPPORTS_AUTHORIZATION_MIDDLEWARE - app.UseAuthorization(); -#endif - -#if SUPPORTS_ENDPOINT_ROUTING - app.UseEndpoints(options => - { - options.MapControllers(); - options.MapDefaultControllerRoute(); - }); -#else - app.UseMvcWithDefaultRoute(); -#endif - } -} diff --git a/sandbox/OpenIddict.Sandbox.Console.Client/App.config b/sandbox/OpenIddict.Sandbox.Console.Client/App.config new file mode 100644 index 00000000..35aae7ac --- /dev/null +++ b/sandbox/OpenIddict.Sandbox.Console.Client/App.config @@ -0,0 +1,26 @@ + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/sandbox/OpenIddict.Sandbox.Console.Client/InteractiveService.cs b/sandbox/OpenIddict.Sandbox.Console.Client/InteractiveService.cs index f81649bd..dd373f19 100644 --- a/sandbox/OpenIddict.Sandbox.Console.Client/InteractiveService.cs +++ b/sandbox/OpenIddict.Sandbox.Console.Client/InteractiveService.cs @@ -854,7 +854,6 @@ public class InteractiveService : BackgroundService return Task.Run(Prompt, cancellationToken).WaitAsync(cancellationToken); } -#if SUPPORTS_CERTIFICATE_GENERATION static X509Certificate2 GenerateEphemeralTlsClientCertificate() { using var algorithm = RSA.Create(keySizeInBits: 4096); @@ -876,21 +875,13 @@ public class InteractiveService : BackgroundService // and would be installed in the certificate store, making this workaround unnecessary. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { -#if SUPPORTS_CERTIFICATE_LOADER certificate = X509CertificateLoader.LoadPkcs12( data: certificate.Export(X509ContentType.Pfx, string.Empty), password: string.Empty, keyStorageFlags: X509KeyStorageFlags.DefaultKeySet); -#else - certificate = new X509Certificate2( - rawData: certificate.Export(X509ContentType.Pfx, string.Empty), - password: string.Empty, - keyStorageFlags: X509KeyStorageFlags.DefaultKeySet); -#endif } return certificate; } -#endif } } diff --git a/sandbox/OpenIddict.Sandbox.Console.Client/Models/ApplicationDbContext.cs b/sandbox/OpenIddict.Sandbox.Console.Client/Models/ApplicationDbContext.cs new file mode 100644 index 00000000..04d0d8c1 --- /dev/null +++ b/sandbox/OpenIddict.Sandbox.Console.Client/Models/ApplicationDbContext.cs @@ -0,0 +1,46 @@ +#if NET +using Microsoft.EntityFrameworkCore; +#else +using System.Data.Entity; +using SQLite.CodeFirst; +#endif + +namespace OpenIddict.Sandbox.Console.Client.Models; + +public class ApplicationDbContext : DbContext +{ +#if NET + public ApplicationDbContext(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.UseOpenIddict(); + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-console-client.sqlite3")}"); + } +#else + public ApplicationDbContext() + : base("name=DefaultConnection") + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.UseOpenIddict(); + + // Override the default database initializer to use the one provided + // by SQLite.CodeFirst, which automatically creates the database. + Database.SetInitializer(new SqliteCreateDatabaseIfNotExists(modelBuilder)); + } +#endif +} diff --git a/sandbox/OpenIddict.Sandbox.Console.Client/OpenIddict.Sandbox.Console.Client.csproj b/sandbox/OpenIddict.Sandbox.Console.Client/OpenIddict.Sandbox.Console.Client.csproj index 3c6809a6..9c7cead8 100644 --- a/sandbox/OpenIddict.Sandbox.Console.Client/OpenIddict.Sandbox.Console.Client.csproj +++ b/sandbox/OpenIddict.Sandbox.Console.Client/OpenIddict.Sandbox.Console.Client.csproj @@ -1,21 +1,49 @@ - + Exe - net48;net10.0 + net10.0 + $(TargetFrameworks);net48 + + + + + + x64 + false + + + + + + + - + + + + + + + + + + diff --git a/sandbox/OpenIddict.Sandbox.Console.Client/Program.cs b/sandbox/OpenIddict.Sandbox.Console.Client/Program.cs index 8801d9f0..622025a8 100644 --- a/sandbox/OpenIddict.Sandbox.Console.Client/Program.cs +++ b/sandbox/OpenIddict.Sandbox.Console.Client/Program.cs @@ -1,10 +1,10 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using OpenIddict.Client; using OpenIddict.Client.WebIntegration; using OpenIddict.Sandbox.Console.Client; +using OpenIddict.Sandbox.Console.Client.Models; using static OpenIddict.Abstractions.OpenIddictConstants; var builder = Host.CreateApplicationBuilder(args); @@ -12,21 +12,26 @@ var builder = Host.CreateApplicationBuilder(args); builder.Logging.ClearProviders(); builder.Logging.AddDebug(); -builder.Services.AddDbContext(options => -{ - options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-console-client.sqlite3")}"); - options.UseOpenIddict(); -}); +#if NET +builder.Services.AddDbContext(); +#else +builder.Services.AddScoped(); +#endif builder.Services.AddOpenIddict() // Register the OpenIddict core components. .AddCore(options => { +#if NET // Configure OpenIddict to use the Entity Framework Core stores and models. - // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. options.UseEntityFrameworkCore() - .UseDbContext(); + .UseDbContext(); +#else + // Configure OpenIddict to use the Entity Framework 6.x stores and models. + options.UseEntityFramework() + .UseDbContext(); +#endif }) // Register the OpenIddict client components. @@ -137,10 +142,12 @@ var app = builder.Build(); // Before starting the host, create the database used to store the application data. // // Note: in a real world application, this step should be part of a setup script. +#if NET await using (var scope = app.Services.CreateAsyncScope()) { - var context = scope.ServiceProvider.GetRequiredService(); + var context = scope.ServiceProvider.GetRequiredService(); await context.Database.EnsureCreatedAsync(); } +#endif await app.RunAsync(); diff --git a/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs b/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs index b7b870e5..b1464944 100644 --- a/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs +++ b/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs @@ -29,7 +29,6 @@ public static class MauiProgram .AddCore(options => { // Configure OpenIddict to use the Entity Framework Core stores and models. - // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. options.UseEntityFrameworkCore() .UseDbContext(); }) diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/App.config b/sandbox/OpenIddict.Sandbox.WinForms.Client/App.config index 451442db..d35f0b89 100644 --- a/sandbox/OpenIddict.Sandbox.WinForms.Client/App.config +++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/App.config @@ -1,5 +1,29 @@  + +
+ + + + + + + + + + + + + + + + + + diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs b/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs index d4d27b7f..9aaf0f28 100644 --- a/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs +++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs @@ -62,7 +62,7 @@ public partial class MainForm : Form, IWinFormsShell Nonce = result.Nonce })).Principal; -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Authentication successful", @@ -78,7 +78,7 @@ public partial class MainForm : Form, IWinFormsShell catch (OperationCanceledException) { -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Authentication timed out", @@ -94,7 +94,7 @@ public partial class MainForm : Form, IWinFormsShell catch (ProtocolException exception) when (exception.Error is Errors.AccessDenied) { -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Authorization denied", @@ -110,7 +110,7 @@ public partial class MainForm : Form, IWinFormsShell catch { -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Authentication failed", @@ -167,7 +167,7 @@ public partial class MainForm : Form, IWinFormsShell Nonce = result.Nonce }); -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Logout successful", @@ -183,7 +183,7 @@ public partial class MainForm : Form, IWinFormsShell catch (OperationCanceledException) { -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Logout timed out", @@ -199,7 +199,7 @@ public partial class MainForm : Form, IWinFormsShell catch (ProtocolException exception) when (exception.Error is Errors.AccessDenied) { -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Logout denied", @@ -215,7 +215,7 @@ public partial class MainForm : Form, IWinFormsShell catch { -#if SUPPORTS_WINFORMS_TASK_DIALOG +#if NET TaskDialog.ShowDialog(new TaskDialogPage { Caption = "Logout failed", @@ -239,4 +239,4 @@ public partial class MainForm : Form, IWinFormsShell GitHubLogin.Enabled = true; } } -} \ No newline at end of file +} diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/Models/ApplicationDbContext.cs b/sandbox/OpenIddict.Sandbox.WinForms.Client/Models/ApplicationDbContext.cs new file mode 100644 index 00000000..e7c6840e --- /dev/null +++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/Models/ApplicationDbContext.cs @@ -0,0 +1,46 @@ +#if NET +using Microsoft.EntityFrameworkCore; +#else +using System.Data.Entity; +using SQLite.CodeFirst; +#endif + +namespace OpenIddict.Sandbox.WinForms.Client.Models; + +public class ApplicationDbContext : DbContext +{ +#if NET + public ApplicationDbContext(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.UseOpenIddict(); + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-winforms-client.sqlite3")}"); + } +#else + public ApplicationDbContext() + : base("name=DefaultConnection") + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.UseOpenIddict(); + + // Override the default database initializer to use the one provided + // by SQLite.CodeFirst, which automatically creates the database. + Database.SetInitializer(new SqliteCreateDatabaseIfNotExists(modelBuilder)); + } +#endif +} diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj b/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj index 068b18be..556d7a23 100644 --- a/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj +++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj @@ -2,25 +2,52 @@ WinExe - net48 - $(TargetFrameworks);net10.0-windows7.0 + net10.0-windows7.0 + $(TargetFrameworks);net48 true app.manifest PerMonitorV2 + + + + x64 + false + + + + + + + + + - + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/Program.cs b/sandbox/OpenIddict.Sandbox.WinForms.Client/Program.cs index a54a7102..c3b2ebc2 100644 --- a/sandbox/OpenIddict.Sandbox.WinForms.Client/Program.cs +++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/Program.cs @@ -1,15 +1,15 @@ using System.Diagnostics; using Dapplo.Microsoft.Extensions.Hosting.WinForms; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Win32; using OpenIddict.Client; using OpenIddict.Sandbox.WinForms.Client; +using OpenIddict.Sandbox.WinForms.Client.Models; using static OpenIddict.Abstractions.OpenIddictConstants; -#if SUPPORTS_APPLICATION_CONFIGURATION_INITIALIZATION +#if NET ApplicationConfiguration.Initialize(); #endif @@ -23,21 +23,26 @@ var host = new HostBuilder() .ConfigureLogging(options => options.AddDebug()) .ConfigureServices(services => { - services.AddDbContext(options => - { - options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-winforms-client.sqlite3")}"); - options.UseOpenIddict(); - }); +#if NET + services.AddDbContext(); +#else + services.AddScoped(); +#endif services.AddOpenIddict() // Register the OpenIddict core components. .AddCore(options => { +#if NET // Configure OpenIddict to use the Entity Framework Core stores and models. - // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. options.UseEntityFrameworkCore() - .UseDbContext(); + .UseDbContext(); +#else + // Configure OpenIddict to use the Entity Framework 6.x stores and models. + options.UseEntityFramework() + .UseDbContext(); +#endif }) // Register the OpenIddict client components. @@ -109,8 +114,10 @@ var host = new HostBuilder() // Note: in a real world application, this step should be part of a setup script. await using (var scope = host.Services.CreateAsyncScope()) { - var context = scope.ServiceProvider.GetRequiredService(); +#if NET + var context = scope.ServiceProvider.GetRequiredService(); await context.Database.EnsureCreatedAsync(); +#endif // Create the registry entries necessary to handle URI protocol activations. // @@ -126,12 +133,12 @@ await using (var scope = host.Services.CreateAsyncScope()) using var command = root.CreateSubKey("shell\\open\\command"); command.SetValue(string.Empty, string.Format("\"{0}\" \"%1\"", -#if SUPPORTS_ENVIRONMENT_PROCESS_PATH +#if NET Environment.ProcessPath #else Process.GetCurrentProcess().MainModule.FileName #endif - )); + )); } await host.RunAsync(); \ No newline at end of file diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/App.config b/sandbox/OpenIddict.Sandbox.Wpf.Client/App.config new file mode 100644 index 00000000..db21bfb9 --- /dev/null +++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/App.config @@ -0,0 +1,26 @@ + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/Models/ApplicationDbContext.cs b/sandbox/OpenIddict.Sandbox.Wpf.Client/Models/ApplicationDbContext.cs new file mode 100644 index 00000000..e4964e78 --- /dev/null +++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/Models/ApplicationDbContext.cs @@ -0,0 +1,47 @@ +#if NET +using System.IO; +using Microsoft.EntityFrameworkCore; +#else +using System.Data.Entity; +using SQLite.CodeFirst; +#endif + +namespace OpenIddict.Sandbox.Wpf.Client.Models; + +public class ApplicationDbContext : DbContext +{ +#if NET + public ApplicationDbContext(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.UseOpenIddict(); + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-wpf-client.sqlite3")}"); + } +#else + public ApplicationDbContext() + : base("name=DefaultConnection") + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.UseOpenIddict(); + + // Override the default database initializer to use the one provided + // by SQLite.CodeFirst, which automatically creates the database. + Database.SetInitializer(new SqliteCreateDatabaseIfNotExists(modelBuilder)); + } +#endif +} diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj b/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj index 3a6dd5cb..b13fdcd2 100644 --- a/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj +++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj @@ -2,24 +2,51 @@ WinExe - net48 - $(TargetFrameworks);net10.0-windows10.0.17763 + net10.0-windows10.0.17763 + $(TargetFrameworks);net48 true false + + + + x64 + false + + + + + + + + + - + + + + + + + + + + diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/Program.cs b/sandbox/OpenIddict.Sandbox.Wpf.Client/Program.cs index f89a7c30..060fe68e 100644 --- a/sandbox/OpenIddict.Sandbox.Wpf.Client/Program.cs +++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/Program.cs @@ -1,13 +1,12 @@ using System.Diagnostics; -using System.IO; using Dapplo.Microsoft.Extensions.Hosting.Wpf; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Win32; using OpenIddict.Client; using OpenIddict.Sandbox.Wpf.Client; +using OpenIddict.Sandbox.Wpf.Client.Models; using static OpenIddict.Abstractions.OpenIddictConstants; var host = new HostBuilder() @@ -20,21 +19,26 @@ var host = new HostBuilder() .ConfigureLogging(options => options.AddDebug()) .ConfigureServices(services => { - services.AddDbContext(options => - { - options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-wpf-client.sqlite3")}"); - options.UseOpenIddict(); - }); +#if NET + services.AddDbContext(); +#else + services.AddScoped(); +#endif services.AddOpenIddict() // Register the OpenIddict core components. .AddCore(options => { +#if NET // Configure OpenIddict to use the Entity Framework Core stores and models. - // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. options.UseEntityFrameworkCore() - .UseDbContext(); + .UseDbContext(); +#else + // Configure OpenIddict to use the Entity Framework 6.x stores and models. + options.UseEntityFramework() + .UseDbContext(); +#endif }) // Register the OpenIddict client components. @@ -110,8 +114,10 @@ var host = new HostBuilder() // Note: in a real world application, this step should be part of a setup script. await using (var scope = host.Services.CreateAsyncScope()) { - var context = scope.ServiceProvider.GetRequiredService(); +#if NET + var context = scope.ServiceProvider.GetRequiredService(); await context.Database.EnsureCreatedAsync(); +#endif // Create the registry entries necessary to handle URI protocol activations. // @@ -127,12 +133,12 @@ await using (var scope = host.Services.CreateAsyncScope()) using var command = root.CreateSubKey("shell\\open\\command"); command.SetValue(string.Empty, string.Format("\"{0}\" \"%1\"", -#if SUPPORTS_ENVIRONMENT_PROCESS_PATH +#if NET Environment.ProcessPath #else Process.GetCurrentProcess().MainModule.FileName #endif - )); + )); } -await host.RunAsync(); \ No newline at end of file +await host.RunAsync(); diff --git a/shared/OpenIddict.Extensions/OpenIddict.Extensions.csproj b/shared/OpenIddict.Extensions/OpenIddict.Extensions.csproj index d1f609b1..a577891e 100644 --- a/shared/OpenIddict.Extensions/OpenIddict.Extensions.csproj +++ b/shared/OpenIddict.Extensions/OpenIddict.Extensions.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net10.0 false $(DefineConstants);FeatureValueTuple @@ -10,7 +10,7 @@ - + diff --git a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs index 65bc5579..3d814499 100644 --- a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs +++ b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs @@ -6,7 +6,6 @@ using System.Collections.ObjectModel; using System.Data; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.CompilerServices; @@ -332,509 +331,6 @@ internal static class OpenIddictHelpers return await reader.ReadFormAsync(cancellationToken); } -#if SUPPORTS_ECDSA - /// - /// Creates a new key. - /// - /// A new key. - /// - /// The implementation resolved from is not valid. - /// - public static ECDsa CreateEcdsaKey() - { - return GetAlgorithmFromConfig() switch - { - ECDsa result => result, - null => ECDsa.Create(), - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict ECDSA Cryptographic Provider"); - } - - /// - /// Creates a new key. - /// - /// The EC curve to use to create the key. - /// A new key. - /// - /// The implementation resolved from is not valid. - /// - public static ECDsa CreateEcdsaKey(ECCurve curve) - { - var algorithm = GetAlgorithmFromConfig() switch - { - ECDsa result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom algorithm was registered, use either the static Create() API - // on platforms that support it or create a default instance provided by the BCL. - if (algorithm is null) - { - return ECDsa.Create(curve); - } - - try - { - algorithm.GenerateKey(curve); - } - - catch - { - algorithm.Dispose(); - - throw; - } - - return algorithm; - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict ECDSA Cryptographic Provider"); - } -#endif - - /// - /// Creates a new key. - /// - /// The key size to use to create the key. - /// A new key. - /// - /// The implementation resolved from is not valid. - /// - public static RSA CreateRsaKey(int size) - { - var algorithm = GetAlgorithmFromConfig() switch - { - RSA result => result, - -#if SUPPORTS_RSA_KEY_CREATION_WITH_SPECIFIED_SIZE - // Note: on .NET Framework >= 4.7.2, the new RSA.Create(int keySizeInBits) uses - // CryptoConfig.CreateFromName("RSAPSS") internally, which returns by default - // a RSACng instance instead of a RSACryptoServiceProvider based on CryptoAPI. - null => RSA.Create(size), -#else - // Note: while a RSACng object could be manually instantiated and returned on - // .NET Framework < 4.7.2, the static RSA.Create() factory (which returns a - // RSACryptoServiceProvider instance by default) is always preferred to RSACng - // as this type is known to have compatibility issues on .NET Framework < 4.6.2. - // - // Developers who prefer using a CNG-based implementation on .NET Framework 4.6.1 - // can do so by tweaking machine.config or by using CryptoConfig.AddAlgorithm(). - null => RSA.Create(), -#endif - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // Note: on .NET Framework, the RSA.Create() overload uses CryptoConfig.CreateFromName() - // and always returns a RSACryptoServiceProvider instance unless the default name mapping was - // explicitly overridden in machine.config or via CryptoConfig.AddAlgorithm(). Unfortunately, - // RSACryptoServiceProvider still uses 1024-bit keys by default and doesn't support changing - // the key size via RSACryptoServiceProvider.KeySize (setting it has no effect on the object). - // - // To ensure the key size matches the requested size, this method replaces the instance by a - // new RSACryptoServiceProvider using the constructor allowing to override the default key size. - try - { - if (algorithm.KeySize != size) - { - if (algorithm is RSACryptoServiceProvider) - { - algorithm.Dispose(); - algorithm = new RSACryptoServiceProvider(size); - } - - else - { - algorithm.KeySize = size; - } - - if (algorithm.KeySize != size) - { - throw new CryptographicException(SR.FormatID0059(algorithm.GetType().FullName)); - } - } - } - - catch - { - algorithm.Dispose(); - - throw; - } - - return algorithm; - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict RSA Cryptographic Provider"); - } - - /// - /// Computes the SHA-256 message authentication code (HMAC) of the specified array. - /// - /// The cryptographic key. - /// The data to hash. - /// The SHA-256 message authentication code (HMAC) of the specified array. - /// - /// The implementation resolved from is not valid. - /// - public static byte[] ComputeSha256MessageAuthenticationCode(byte[] key, byte[] data) - { - var algorithm = GetAlgorithmFromConfig(key) switch - { - HMACSHA256 result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom algorithm was registered, use either the static/one-shot HashData() API - // on platforms that support it or create a default instance provided by the BCL. - if (algorithm is null) - { -#if SUPPORTS_ONE_SHOT_HASHING_METHODS - return HMACSHA256.HashData(key, data); -#else - algorithm = new HMACSHA256(key); -#endif - } - - try - { - return algorithm.ComputeHash(data); - } - - finally - { - algorithm.Dispose(); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig(byte[] key) => CryptoConfig.CreateFromName("OpenIddict HMAC SHA-256 Cryptographic Provider", [key]); - } - - /// - /// Computes the SHA-256 hash of the specified array. - /// - /// The data to hash. - /// The SHA-256 hash of the specified array. - /// - /// The implementation resolved from is not valid. - /// - public static byte[] ComputeSha256Hash(byte[] data) - { - var algorithm = GetAlgorithmFromConfig() switch - { - SHA256 result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom algorithm was registered, use either the static/one-shot HashData() API - // on platforms that support it or create a default instance provided by the BCL. - if (algorithm is null) - { -#if SUPPORTS_ONE_SHOT_HASHING_METHODS - return SHA256.HashData(data); -#else - algorithm = SHA256.Create(); -#endif - } - - try - { - return algorithm.ComputeHash(data); - } - - finally - { - algorithm.Dispose(); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict SHA-256 Cryptographic Provider"); - } - - /// - /// Computes the SHA-384 hash of the specified array. - /// - /// The data to hash. - /// The SHA-384 hash of the specified array. - /// - /// The implementation resolved from is not valid. - /// - public static byte[] ComputeSha384Hash(byte[] data) - { - var algorithm = GetAlgorithmFromConfig() switch - { - SHA384 result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom algorithm was registered, use either the static/one-shot HashData() API - // on platforms that support it or create a default instance provided by the BCL. - if (algorithm is null) - { -#if SUPPORTS_ONE_SHOT_HASHING_METHODS - return SHA384.HashData(data); -#else - algorithm = SHA384.Create(); -#endif - } - - try - { - return algorithm.ComputeHash(data); - } - - finally - { - algorithm.Dispose(); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict SHA-384 Cryptographic Provider"); - } - - /// - /// Computes the SHA-512 hash of the specified array. - /// - /// The data to hash. - /// The SHA-512 hash of the specified array. - /// - /// The implementation resolved from is not valid. - /// - public static byte[] ComputeSha512Hash(byte[] data) - { - var algorithm = GetAlgorithmFromConfig() switch - { - SHA512 result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom algorithm was registered, use either the static/one-shot HashData() API - // on platforms that support it or create a default instance provided by the BCL. - if (algorithm is null) - { -#if SUPPORTS_ONE_SHOT_HASHING_METHODS - return SHA512.HashData(data); -#else - algorithm = SHA512.Create(); -#endif - } - - try - { - return algorithm.ComputeHash(data); - } - - finally - { - algorithm.Dispose(); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict SHA-512 Cryptographic Provider"); - } - - /// - /// Creates a new array of containing random data. - /// - /// The desired entropy, in bits. - /// A new array of containing random data. - /// - /// The implementation resolved from is not valid. - /// - public static byte[] CreateRandomArray(int size) - { - var algorithm = GetAlgorithmFromConfig() switch - { - RandomNumberGenerator result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom random number generator was registered, use either the static GetBytes() or - // Fill() APIs on platforms that support them or create a default instance provided by the BCL. -#if SUPPORTS_ONE_SHOT_RANDOM_NUMBER_GENERATOR_METHODS - if (algorithm is null) - { - var array = new byte[size / 8]; - algorithm.GetBytes(array); - - return array; - } -#endif - var array = new byte[size / 8]; - -#if SUPPORTS_STATIC_RANDOM_NUMBER_GENERATOR_METHODS - if (algorithm is null) - { - RandomNumberGenerator.Fill(array); - return array; - } -#else - algorithm ??= RandomNumberGenerator.Create(); -#endif - try - { - algorithm.GetBytes(array); - } - - finally - { - algorithm.Dispose(); - } - - return array; - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict RNG Cryptographic Provider"); - } - - /// - /// Creates a new containing characters - /// randomly selected in the specified . - /// - /// The characters allowed to be included in the . - /// The number of characters. - /// A new containing random data. - /// - /// The implementation resolved from is not valid. - /// - public static string CreateRandomString(ReadOnlySpan charset, int count) - { - var algorithm = GetAlgorithmFromConfig() switch - { - RandomNumberGenerator result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - try - { - var builder = new StringBuilder(); - - for (var index = 0; index < count; index++) - { - // Pick a character in the specified charset by generating a random index. - builder.Append(charset[index: algorithm switch - { -#if SUPPORTS_INT32_RANDOM_NUMBER_GENERATOR_METHODS - // If no custom random number generator was registered, use - // the static GetInt32() API on platforms that support it. - null => RandomNumberGenerator.GetInt32(0, charset.Length), -#endif - // Otherwise, create a default implementation if necessary - // and use the local function that achieves the same result. - _ => GetInt32(algorithm ??= RandomNumberGenerator.Create(), 0..charset.Length) - }]); - } - - return builder.ToString(); - } - - finally - { - algorithm?.Dispose(); - } - - static int GetInt32(RandomNumberGenerator algorithm, Range range) - { - // Note: the logic used here is directly taken from the official implementation - // of the RandomNumberGenerator.GetInt32() method introduced in .NET Core 3.0. - // - // See https://github.com/dotnet/corefx/pull/31243 for more information. - - var count = (uint) range.End.Value - (uint) range.Start.Value - 1; - if (count is 0) - { - return range.Start.Value; - } - - var mask = count; - mask |= mask >> 1; - mask |= mask >> 2; - mask |= mask >> 4; - mask |= mask >> 8; - mask |= mask >> 16; - - var buffer = new byte[sizeof(uint)]; - uint value; - - do - { - algorithm.GetBytes(buffer); - - value = mask & BitConverter.ToUInt32(buffer, 0); - } - - while (value > count); - - return (int) value + range.Start.Value; - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig() => CryptoConfig.CreateFromName("OpenIddict RNG Cryptographic Provider"); - } - - /// - /// Determines the equality of two byte sequences in an amount of time - /// which depends on the length of the sequences, but not the values. - /// - /// The first buffer to compare. - /// The second buffer to compare. - /// - /// if and have the same values - /// for and the same contents, otherwise. - /// -#if !SUPPORTS_TIME_CONSTANT_COMPARISONS - [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] -#endif - public static bool FixedTimeEquals(ReadOnlySpan left, ReadOnlySpan right) - { -#if SUPPORTS_TIME_CONSTANT_COMPARISONS - return CryptographicOperations.FixedTimeEquals(left, right); -#else - // Note: the logic used here is directly taken from the official implementation of - // the CryptographicOperations.FixedTimeEquals() method introduced in .NET Core 2.1. - // - // See https://github.com/dotnet/corefx/pull/27103 for more information. - - // Note: these null checks can be theoretically considered as early checks - // (which would defeat the purpose of a time-constant comparison method), - // but the expected string length is the only information an attacker - // could get at this stage, which is not critical where this method is used. - - if (left.Length != right.Length) - { - return false; - } - - var length = left.Length; - var accumulator = 0; - - for (var index = 0; index < length; index++) - { - accumulator |= left[index] - right[index]; - } - - return accumulator is 0; -#endif - } - /// /// Removes the characters that are not part of /// from the specified string. @@ -870,97 +366,6 @@ internal static class OpenIddictHelpers return builder.ToString(); } -#if SUPPORTS_KEY_DERIVATION_WITH_SPECIFIED_HASH_ALGORITHM - /// - /// Creates a derived key based on the specified using PBKDF2. - /// - /// The secret from which the derived key is created. - /// The salt. - /// The hash algorithm to use. - /// The number of iterations to use. - /// The desired length of the derived key. - /// A derived key based on the specified . - /// - /// The implementation resolved from is not valid. - /// - public static byte[] DeriveKey(string secret, byte[] salt, HashAlgorithmName algorithm, int iterations, int length) - { - // Warning: the type and order of the arguments specified here MUST exactly match the parameters used with - // Rfc2898DeriveBytes(string password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm). - var generator = GetAlgorithmFromConfig(secret, salt, iterations, algorithm) switch - { - Rfc2898DeriveBytes result => result, - null => null, - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; - - // If no custom generator was registered, use either the static/one-shot Pbkdf2() API - // on platforms that support it or create an instance using the dedicated constructor. - if (generator is null) - { -#if SUPPORTS_ONE_SHOT_KEY_DERIVATION_METHODS - return Rfc2898DeriveBytes.Pbkdf2(secret, salt, iterations, algorithm, length); -#else -#pragma warning disable CA5379 - generator = new Rfc2898DeriveBytes(secret, salt, iterations, algorithm); -#pragma warning restore CA5379 -#endif - } - - try - { - return generator.GetBytes(length); - } - - finally - { - generator.Dispose(); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static object? GetAlgorithmFromConfig(string secret, byte[] salt, int iterations, HashAlgorithmName algorithm) - => CryptoConfig.CreateFromName("OpenIddict PBKDF2 Cryptographic Provider", [secret, salt, iterations, algorithm]); - } -#endif - -#if SUPPORTS_ECDSA - /// - /// Determines whether the specified represent a specific EC curve. - /// - /// The . - /// The . - /// - /// if is identical to - /// the specified , otherwise. - /// - public static bool IsEcCurve(ECParameters parameters, ECCurve curve) - { - Debug.Assert(parameters.Curve.Oid is not null, SR.GetResourceString(SR.ID4011)); - Debug.Assert(curve.Oid is not null, SR.GetResourceString(SR.ID4011)); - - // Warning: on .NET Framework 4.x and .NET Core 2.1, exported ECParameters generally have - // a null OID value attached. To work around this limitation, both the raw OID values and - // the friendly names are compared to determine whether the curve is of the specified type. - if (!string.IsNullOrEmpty(parameters.Curve.Oid.Value) && - !string.IsNullOrEmpty(curve.Oid.Value)) - { - return string.Equals(parameters.Curve.Oid.Value, - curve.Oid.Value, StringComparison.Ordinal); - } - - if (!string.IsNullOrEmpty(parameters.Curve.Oid.FriendlyName) && - !string.IsNullOrEmpty(curve.Oid.FriendlyName)) - { - return string.Equals(parameters.Curve.Oid.FriendlyName, - curve.Oid.FriendlyName, StringComparison.Ordinal); - } - - Debug.Fail(SR.GetResourceString(SR.ID4012)); - return false; - } -#endif - /// /// Determines whether the specified represents a null, undefined or empty JSON node. /// @@ -968,31 +373,16 @@ internal static class OpenIddictHelpers /// /// if the JSON node is null, undefined or empty otherwise. /// - public static bool IsNullOrEmpty(JsonElement element) + public static bool IsNullOrEmpty(JsonElement element) => element.ValueKind switch { - switch (element.ValueKind) - { - case JsonValueKind.Undefined or JsonValueKind.Null: - return true; - - case JsonValueKind.String: - return string.IsNullOrEmpty(element.GetString()); + JsonValueKind.Undefined or JsonValueKind.Null => true, - case JsonValueKind.Array: - return element.GetArrayLength() is 0; + JsonValueKind.String => string.IsNullOrEmpty(element.GetString()), + JsonValueKind.Array => element.GetArrayLength() is 0, + JsonValueKind.Object => element.GetPropertyCount() is 0, - case JsonValueKind.Object: -#if SUPPORTS_JSON_ELEMENT_PROPERTY_COUNT - return element.GetPropertyCount() is 0; -#else - using (var enumerator = element.EnumerateObject()) - { - return !enumerator.MoveNext(); - } -#endif - default: return false; - } - } + _ => false, + }; /// /// Determines whether the specified represents a null or empty JSON node. diff --git a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs index 940c0c90..56d785b1 100644 --- a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs +++ b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs @@ -4,8 +4,10 @@ * the license and the contributors participating to this project. */ +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; +using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; namespace OpenIddict.Extensions; @@ -44,6 +46,29 @@ internal static class OpenIddictPolyfills #endif } + extension(HMACSHA256) + { +#if !SUPPORTS_ONE_SHOT_HASHING_METHODS + /// + /// Computes the HMAC of data using the SHA256 algorithm. + /// + /// The HMAC key. + /// The data to HMAC. + /// The HMAC of the data. + /// + /// or is . + /// + public static byte[] HashData(byte[] key, byte[] source) + { + ArgumentNullException.ThrowIfNull(key); + ArgumentNullException.ThrowIfNull(source); + + using var algorithm = new HMACSHA256(key); + return algorithm.ComputeHash(source); + } +#endif + } + extension(OperatingSystem) { #if !SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON @@ -131,6 +156,69 @@ internal static class OpenIddictPolyfills #endif } + extension(Rfc2898DeriveBytes) + { +#if !SUPPORTS_ONE_SHOT_KEY_DERIVATION_METHODS + + /// + /// Creates a PBKDF2 derived key from a password. + /// + /// The password used to derive the key. + /// The key salt used to derive the key. + /// The number of iterations for the operation. + /// The hash algorithm to use to derive the key. + /// The size of key to derive. + /// + /// is not zero or a positive value. + /// -or- + /// is not a positive value. + /// + /// + /// has a + /// that is empty or . + /// + /// + /// is an unsupported hash algorithm. Supported algorithms + /// are , , + /// , and . + /// + public static byte[] Pbkdf2( + ReadOnlySpan password, + ReadOnlySpan salt, + int iterations, + HashAlgorithmName hashAlgorithm, + int outputLength) + { + ArgumentOutOfRangeException.ThrowIfNegative(outputLength); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(iterations); + + using var algorithm = new Rfc2898DeriveBytes(password.ToString(), salt.ToArray(), iterations, hashAlgorithm); + return algorithm.GetBytes(outputLength); + } +#endif + } + + extension(SHA384) + { +#if !SUPPORTS_ONE_SHOT_HASHING_METHODS + /// + /// Computes the hash of data using the SHA384 algorithm. + /// + /// The data to hash. + /// The hash of the data. + /// + /// is . + /// + public static byte[] HashData(byte[] source) + { + ArgumentNullException.ThrowIfNull(source); + + using var algorithm = SHA384.Create(); + return algorithm.ComputeHash(source); + } +#endif + } + extension(ValueTask) { #if !SUPPORTS_VALUETASK_COMPLETED_TASK @@ -219,3 +307,85 @@ internal static class OpenIddictPolyfills #endif } } + + +/// +/// Exposes common polyfills used by the OpenIddict assemblies. +/// +internal static class OpenIddictPolyfills_SHA512 +{ + extension(SHA512) + { +#if !SUPPORTS_ONE_SHOT_HASHING_METHODS + /// + /// Computes the hash of data using the SHA512 algorithm. + /// + /// The data to hash. + /// The hash of the data. + /// + /// is . + /// + public static byte[] HashData(byte[] source) + { + ArgumentNullException.ThrowIfNull(source); + + using var algorithm = SHA512.Create(); + return algorithm.ComputeHash(source); + } +#endif + } +} + +#if !SUPPORTS_TIME_CONSTANT_COMPARISONS +internal static class CryptographicOperations +{ + /// + /// Determine the equality of two byte sequences in an amount of time which depends on + /// the length of the sequences, but not the values. + /// + /// The first buffer to compare. + /// The second buffer to compare. + /// + /// true if and have the same + /// values for and the same contents, false + /// otherwise. + /// + /// + /// This method compares two buffers' contents for equality in a manner which does not + /// leak timing information, making it ideal for use within cryptographic routines. + /// This method will short-circuit and return false only if + /// and have different lengths. + /// + /// Fixed-time behavior is guaranteed in all other cases, including if + /// and reference the same address. + /// + [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] + public static bool FixedTimeEquals(ReadOnlySpan left, ReadOnlySpan right) + { + // Note: the logic used here is directly taken from the official implementation of + // the CryptographicOperations.FixedTimeEquals() method introduced in .NET Core 2.1. + // + // See https://github.com/dotnet/corefx/pull/27103 for more information. + + // Note: these null checks can be theoretically considered as early checks + // (which would defeat the purpose of a time-constant comparison method), + // but the expected string length is the only information an attacker + // could get at this stage, which is not critical where this method is used. + + if (left.Length != right.Length) + { + return false; + } + + var length = left.Length; + var accumulator = 0; + + for (var index = 0; index < length; index++) + { + accumulator |= left[index] - right[index]; + } + + return accumulator is 0; + } +} +#endif diff --git a/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj b/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj index b8ae6582..59120ff2 100644 --- a/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj +++ b/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) true @@ -19,31 +15,17 @@ - + - - - + - - - - - - - - diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs index c3a810a8..a4082420 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs @@ -119,8 +119,8 @@ public readonly struct OpenIddictParameter : IEquatable string?[] value => value.Length, // If the parameter is a JSON array or a JSON object, return its length. - JsonElement { ValueKind: JsonValueKind.Array or JsonValueKind.Object } element - => Count(element), + JsonElement { ValueKind: JsonValueKind.Array } element => element.GetArrayLength(), + JsonElement { ValueKind: JsonValueKind.Object } element => element.GetPropertyCount(), // If the parameter is a JsonArray, return its length. JsonArray value => value.Count, @@ -130,8 +130,13 @@ public readonly struct OpenIddictParameter : IEquatable // If the parameter is a JsonValue wrapping a JsonElement, // apply the same logic as with direct JsonElement instances. - JsonValue value when value.TryGetValue(out JsonElement element) - => element.ValueKind is JsonValueKind.Array or JsonValueKind.Object ? Count(element) : 0, + JsonValue value when value.TryGetValue(out JsonElement element) => element.ValueKind switch + { + JsonValueKind.Array => element.GetArrayLength(), + JsonValueKind.Object => element.GetPropertyCount(), + + _ => 0 + }, // If the parameter is a JsonValue wrapping a well-known primitive type // (e.g int or string), always return 0 as these types can't have a length. @@ -145,42 +150,11 @@ public readonly struct OpenIddictParameter : IEquatable // and extract the number of items if the element is a JSON array or object. JsonNode value when JsonSerializer.SerializeToElement(value, OpenIddictSerializer.Default.JsonNode) is JsonElement { ValueKind: JsonValueKind.Array or JsonValueKind.Object } element - => Count(element), + => element.ValueKind is JsonValueKind.Array ? element.GetArrayLength() : element.GetPropertyCount(), // Otherwise, return 0. _ => 0 }; - - static int Count(JsonElement element) - { - switch (element.ValueKind) - { - case JsonValueKind.Array: - return element.GetArrayLength(); - - case JsonValueKind.Object: -#if SUPPORTS_JSON_ELEMENT_PROPERTY_COUNT - return element.GetPropertyCount(); -#else - var count = 0; - - using (var enumerator = element.EnumerateObject()) - { - checked - { - while (enumerator.MoveNext()) - { - count++; - } - } - } - - return count; -#endif - - default: return 0; - } - } } } @@ -290,75 +264,21 @@ public readonly struct OpenIddictParameter : IEquatable JsonSerializer.SerializeToElement(right, right.GetType(), OpenIddictSerializer.Default)) }; - static bool DeepEquals(JsonElement left, JsonElement right) + static bool DeepEquals(JsonElement left, JsonElement right) => (left.ValueKind, right.ValueKind) switch { -#if !SUPPORTS_JSON_ELEMENT_DEEP_EQUALS - RuntimeHelpers.EnsureSufficientExecutionStack(); -#endif - switch ((left.ValueKind, right.ValueKind)) - { - case (JsonValueKind.Undefined, JsonValueKind.Undefined): - case (JsonValueKind.Null, JsonValueKind.Null): - case (JsonValueKind.False, JsonValueKind.False): - case (JsonValueKind.True, JsonValueKind.True): - return true; - - // Treat undefined JsonElement instances as null values. - case (JsonValueKind.Undefined, JsonValueKind.Null): - case (JsonValueKind.Null, JsonValueKind.Undefined): - return true; - -#if SUPPORTS_JSON_ELEMENT_DEEP_EQUALS - default: return JsonElement.DeepEquals(left, right); -#else - case (JsonValueKind.Number, JsonValueKind.Number): - return string.Equals(left.GetRawText(), right.GetRawText(), StringComparison.Ordinal); - - case (JsonValueKind.String, JsonValueKind.String): - return string.Equals(left.GetString(), right.GetString(), StringComparison.Ordinal); - - case (JsonValueKind.Array, JsonValueKind.Array): - { - var length = left.GetArrayLength(); - if (length != right.GetArrayLength()) - { - return false; - } - - for (var index = 0; index < length; index++) - { - if (!DeepEquals(left[index], right[index])) - { - return false; - } - } - - return true; - } - - case (JsonValueKind.Object, JsonValueKind.Object): - { - foreach (var property in left.EnumerateObject()) - { - if (!right.TryGetProperty(property.Name, out JsonElement element) || - property.Value.ValueKind != element.ValueKind) - { - return false; - } - - if (!DeepEquals(property.Value, element)) - { - return false; - } - } - - return true; - } - - default: return false; -#endif - } - } + (JsonValueKind.Undefined, JsonValueKind.Undefined) or + (JsonValueKind.Null, JsonValueKind.Null) or + (JsonValueKind.False, JsonValueKind.False) or + (JsonValueKind.True, JsonValueKind.True) + => true, + + // Treat undefined JsonElement instances as null values. + (JsonValueKind.Undefined, JsonValueKind.Null) or + (JsonValueKind.Null, JsonValueKind.Undefined) + => true, + + _ => JsonElement.DeepEquals(left, right) + }; } /// diff --git a/src/OpenIddict.AspNetCore/OpenIddict.AspNetCore.csproj b/src/OpenIddict.AspNetCore/OpenIddict.AspNetCore.csproj index 8cc45bfb..a9f28bf4 100644 --- a/src/OpenIddict.AspNetCore/OpenIddict.AspNetCore.csproj +++ b/src/OpenIddict.AspNetCore/OpenIddict.AspNetCore.csproj @@ -1,7 +1,7 @@  - $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) false false false diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddict.Client.AspNetCore.csproj b/src/OpenIddict.Client.AspNetCore/OpenIddict.Client.AspNetCore.csproj index 4a6bd8d1..fb2b9013 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddict.Client.AspNetCore.csproj +++ b/src/OpenIddict.Client.AspNetCore/OpenIddict.Client.AspNetCore.csproj @@ -1,7 +1,7 @@  - $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) @@ -13,24 +13,8 @@ - - - - - - - - - - - - + diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs index ad850f42..961b84c4 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreConfiguration.cs @@ -115,7 +115,6 @@ public sealed class OpenIddictClientAspNetCoreConfiguration : IConfigureOptions< throw new InvalidOperationException(SR.GetResourceString(SR.ID0289)); } -#if SUPPORTS_AUTHENTICATION_HANDLER_SELECTION_FALLBACK // Starting in ASP.NET 7.0, the authentication stack integrates a fallback // mechanism to select the default scheme to use when no value is set, but // only if a single handler has been registered in the authentication options. @@ -132,7 +131,6 @@ public sealed class OpenIddictClientAspNetCoreConfiguration : IConfigureOptions< { options.AddScheme(Guid.NewGuid().ToString(), displayName: null); } -#endif static bool TryValidate(IDictionary map, string? scheme) { diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandler.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandler.cs index e433b4d4..3dda2386 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandler.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandler.cs @@ -29,7 +29,6 @@ public sealed class OpenIddictClientAspNetCoreHandler : AuthenticationHandler /// Creates a new instance of the class. /// -#if SUPPORTS_AUTHENTICATION_HANDLER_TIME_PROVIDER_ARGUMENT public OpenIddictClientAspNetCoreHandler( IOpenIddictClientDispatcher dispatcher, IOpenIddictClientFactory factory, @@ -41,20 +40,6 @@ public sealed class OpenIddictClientAspNetCoreHandler : AuthenticationHandler options, - ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock) - : base(options, logger, encoder, clock) - { - _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); - _factory = factory ?? throw new ArgumentNullException(nameof(factory)); - } -#endif /// public async Task HandleRequestAsync() diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs index a071ebf7..3efe09d6 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs @@ -72,7 +72,6 @@ public static partial class OpenIddictClientAspNetCoreHandlers // with the same name are used by derived drafts like the OAuth 2.0 token exchange specification. // For consistency, multiple parameters with the same name are also supported by this endpoint. -#if SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS var location = QueryHelpers.AddQueryString(context.AuthorizationEndpoint, from parameter in context.Request.GetParameters() let values = (ImmutableArray?) parameter.Value @@ -80,20 +79,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers from value in values.GetValueOrDefault() where !string.IsNullOrEmpty(value) select KeyValuePair.Create(parameter.Key, value)); -#else - var location = context.AuthorizationEndpoint; - foreach (var (key, value) in - from parameter in context.Request.GetParameters() - let values = (ImmutableArray?) parameter.Value - where values is not null - from value in values.GetValueOrDefault() - where !string.IsNullOrEmpty(value) - select (parameter.Key, Value: value)) - { - location = QueryHelpers.AddQueryString(location, key, value); - } -#endif response.Redirect(location); context.HandleRequest(); diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs index 855f7e4b..91ec1a29 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs @@ -72,7 +72,6 @@ public static partial class OpenIddictClientAspNetCoreHandlers // with the same name are used by derived drafts like the OAuth 2.0 token exchange specification. // For consistency, multiple parameters with the same name are also supported by this endpoint. -#if SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS var location = QueryHelpers.AddQueryString(context.EndSessionEndpoint, from parameter in context.Request.GetParameters() let values = (ImmutableArray?) parameter.Value @@ -80,20 +79,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers from value in values.GetValueOrDefault() where !string.IsNullOrEmpty(value) select KeyValuePair.Create(parameter.Key, value)); -#else - var location = context.EndSessionEndpoint; - foreach (var (key, value) in - from parameter in context.Request.GetParameters() - let values = (ImmutableArray?) parameter.Value - where values is not null - from value in values.GetValueOrDefault() - where !string.IsNullOrEmpty(value) - select (parameter.Key, Value: value)) - { - location = QueryHelpers.AddQueryString(location, key, value); - } -#endif response.Redirect(location); context.HandleRequest(); diff --git a/src/OpenIddict.Client.DataProtection/OpenIddict.Client.DataProtection.csproj b/src/OpenIddict.Client.DataProtection/OpenIddict.Client.DataProtection.csproj index 79f5a391..bc91236a 100644 --- a/src/OpenIddict.Client.DataProtection/OpenIddict.Client.DataProtection.csproj +++ b/src/OpenIddict.Client.DataProtection/OpenIddict.Client.DataProtection.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) @@ -18,15 +14,7 @@ - - - diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj b/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj index 252699ff..dd3c7c7f 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj @@ -1,4 +1,4 @@ - + @@ -8,20 +8,8 @@ $(NetCoreIOSTargetFrameworks); $(NetCoreMacCatalystTargetFrameworks); $(NetCoreMacOSTargetFrameworks); - $(NetCoreWindowsTargetFrameworks); - $(NetStandardTargetFrameworks); - $(UniversalWindowsPlatformTargetFrameworks) + $(NetCoreWindowsTargetFrameworks) - - - .NETCoreApp true - - - - - diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs index 3c7d5df3..1ac67331 100644 --- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs +++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs @@ -6,7 +6,6 @@ using System.Data; using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; using Microsoft.Extensions.DependencyInjection; using OpenIddict.EntityFrameworkCore; using OpenIddict.EntityFrameworkCore.Models; @@ -205,45 +204,6 @@ public static class OpenIddictEntityFrameworkCoreHelpers .ApplyConfiguration(new OpenIddictEntityFrameworkCoreTokenConfiguration()); } -#if SUPPORTS_BCL_ASYNC_ENUMERABLE - /// - /// Executes the query and returns the results as a streamed async enumeration. - /// - /// The type of the returned entities. - /// The query source. - /// The that can be used to abort the operation. - /// The non-streamed async enumeration containing the results. -#else - /// - /// Executes the query and returns the results as a non-streamed async enumeration. - /// - /// The type of the returned entities. - /// The query source. - /// The that can be used to abort the operation. - /// The non-streamed async enumeration containing the results. -#endif - internal static IAsyncEnumerable AsAsyncEnumerable(this IQueryable source, CancellationToken cancellationToken) - { - ArgumentNullException.ThrowIfNull(source); - - return ExecuteAsync(source, cancellationToken); - - static async IAsyncEnumerable ExecuteAsync(IQueryable source, [EnumeratorCancellation] CancellationToken cancellationToken) - { -#if SUPPORTS_BCL_ASYNC_ENUMERABLE - await foreach (var element in source.AsAsyncEnumerable().WithCancellation(cancellationToken)) - { - yield return element; - } -#else - foreach (var element in await source.ToListAsync(cancellationToken)) - { - yield return element; - } -#endif - } - } - /// /// Tries to create a new with the specified . /// diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs index 58ac6190..3ee68e93 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs @@ -136,7 +136,6 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< var context = await Context.GetDbContextAsync(cancellationToken); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { var strategy = context.Database.CreateExecutionStrategy(); @@ -180,7 +179,6 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< } else -#endif { // Note: due to a bug in Entity Framework Core's query visitor, the authorizations can't be // filtered using authorization.Application.Id.Equals(key). To work around this issue, @@ -323,7 +321,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< var applications = (from application in context.Set().AsTracking() where application.PostLogoutRedirectUris!.Contains(uri) - select application).AsAsyncEnumerable(cancellationToken); + select application).AsAsyncEnumerable().WithCancellation(cancellationToken); await foreach (var application in applications) { @@ -356,7 +354,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< var applications = (from application in context.Set().AsTracking() where application.RedirectUris!.Contains(uri) - select application).AsAsyncEnumerable(cancellationToken); + select application).AsAsyncEnumerable().WithCancellation(cancellationToken); await foreach (var application in applications) { @@ -754,7 +752,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< query = query.Take(count.Value); } - await foreach (var application in query.AsAsyncEnumerable(cancellationToken)) + await foreach (var application in query.AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return application; } @@ -773,7 +771,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< { var context = await Context.GetDbContextAsync(cancellationToken); - await foreach (var application in query(context.Set().AsTracking(), state).AsAsyncEnumerable(cancellationToken)) + await foreach (var application in query(context.Set().AsTracking(), state).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return application; } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs index e18d3102..7dc52f63 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs @@ -135,7 +135,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< var context = await Context.GetDbContextAsync(cancellationToken); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { var strategy = context.Database.CreateExecutionStrategy(); @@ -173,7 +172,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< } else -#endif { // Note: due to a bug in Entity Framework Core's query visitor, the tokens can't be // filtered using token.Application.Id.Equals(key). To work around this issue, @@ -265,7 +263,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< query = query.Where(authorization => authorization.Type == type); } - await foreach (var authorization in query.AsAsyncEnumerable(cancellationToken)) + await foreach (var authorization in query.AsAsyncEnumerable().WithCancellation(cancellationToken)) { if (scopes is null || (await GetScopesAsync(authorization, cancellationToken)) .ToHashSet(StringComparer.Ordinal) @@ -298,7 +296,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< (from authorization in context.Set().Include(authorization => authorization.Application).AsTracking() join application in context.Set().AsTracking() on authorization.Application!.Id equals application.Id where application.Id!.Equals(key) - select authorization).AsAsyncEnumerable(cancellationToken)) + select authorization).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return authorization; } @@ -340,7 +338,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< await foreach (var authorization in (from authorization in context.Set().Include(authorization => authorization.Application).AsTracking() where authorization.Subject == subject - select authorization).AsAsyncEnumerable(cancellationToken)) + select authorization).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return authorization; } @@ -539,7 +537,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< query = query.Take(count.Value); } - await foreach (var authorization in query.AsAsyncEnumerable(cancellationToken)) + await foreach (var authorization in query.AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return authorization; } @@ -561,7 +559,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< await foreach (var authorization in query( context.Set() .Include(authorization => authorization.Application) - .AsTracking(), state).AsAsyncEnumerable(cancellationToken)) + .AsTracking(), state).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return authorization; } @@ -589,7 +587,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< { cancellationToken.ThrowIfCancellationRequested(); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { try @@ -621,7 +618,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< } else -#endif { var strategy = context.Database.CreateExecutionStrategy(); var count = await strategy.ExecuteAsync(async () => @@ -720,7 +716,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< query = query.Where(authorization => authorization.Type == type); } -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await query.ExecuteUpdateAsync(entity => entity.SetProperty( @@ -729,7 +724,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -779,7 +774,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< var context = await Context.GetDbContextAsync(cancellationToken); var key = ConvertIdentifierFromString(identifier); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await ( @@ -791,7 +785,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -843,7 +837,6 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< var context = await Context.GetDbContextAsync(cancellationToken); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await ( @@ -855,7 +848,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -905,28 +898,8 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< if (!string.IsNullOrEmpty(identifier)) { -#if SUPPORTS_DBSET_VALUETASK_FINDASYNC authorization.Application = await context.Set() .FindAsync([ConvertIdentifierFromString(identifier)], cancellationToken); -#else - // Warning: when targeting older TFMs, FindAsync() is deliberately not used to work around a breaking - // change introduced in Entity Framework Core 3.x (where a ValueTask instead of a Task is now returned). - - var key = ConvertIdentifierFromString(identifier); - - authorization.Application = GetTrackedEntity() ?? await QueryAsync() ?? - throw new InvalidOperationException(SR.GetResourceString(SR.ID0244)); - - TApplication? GetTrackedEntity() => - (from entry in context.ChangeTracker.Entries() - where entry.Entity.Id is TKey identifier && identifier.Equals(key) - select entry.Entity).FirstOrDefault(); - - Task QueryAsync() => - (from application in context.Set().AsTracking() - where application.Id!.Equals(key) - select application).FirstOrDefaultAsync(cancellationToken); -#endif } else diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs index 3a821c51..9cc80f89 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs @@ -198,7 +198,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore< // ImmutableArray.Contains() (which is not fully supported by Entity Framework Core) is not used instead. await foreach (var scope in (from scope in context.Set().AsTracking() where Enumerable.Contains(names, scope.Name) - select scope).AsAsyncEnumerable(cancellationToken)) + select scope).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return scope; } @@ -225,7 +225,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore< var scopes = (from scope in context.Set().AsTracking() where scope.Resources!.Contains(resource) - select scope).AsAsyncEnumerable(cancellationToken); + select scope).AsAsyncEnumerable().WithCancellation(cancellationToken); await foreach (var scope in scopes) { @@ -461,7 +461,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore< query = query.Take(count.Value); } - await foreach (var scope in query.AsAsyncEnumerable(cancellationToken)) + await foreach (var scope in query.AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return scope; } @@ -480,7 +480,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore< { var context = await Context.GetDbContextAsync(cancellationToken); - await foreach (var scope in query(context.Set().AsTracking(), state).AsAsyncEnumerable(cancellationToken)) + await foreach (var scope in query(context.Set().AsTracking(), state).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return scope; } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs index a44cdce8..17cc3018 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs @@ -193,7 +193,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< query = query.Where(token => token.Type == type); } - await foreach (var token in query.AsAsyncEnumerable(cancellationToken)) + await foreach (var token in query.AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return token; } @@ -224,7 +224,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< .AsTracking() join application in context.Set().AsTracking() on token.Application!.Id equals application.Id where application.Id!.Equals(key) - select token).AsAsyncEnumerable(cancellationToken)) + select token).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return token; } @@ -256,7 +256,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< .AsTracking() join authorization in context.Set().AsTracking() on token.Authorization!.Id equals authorization.Id where authorization.Id!.Equals(key) - select token).AsAsyncEnumerable(cancellationToken)) + select token).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return token; } @@ -318,7 +318,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< await foreach (var token in (from token in context.Set().Include(token => token.Application).Include(token => token.Authorization).AsTracking() where token.Subject == subject - select token).AsAsyncEnumerable(cancellationToken)) + select token).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return token; } @@ -549,7 +549,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< query = query.Take(count.Value); } - await foreach (var token in query.AsAsyncEnumerable(cancellationToken)) + await foreach (var token in query.AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return token; } @@ -572,7 +572,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< context.Set() .Include(token => token.Application) .Include(token => token.Authorization) - .AsTracking(), state).AsAsyncEnumerable(cancellationToken)) + .AsTracking(), state).AsAsyncEnumerable().WithCancellation(cancellationToken)) { yield return token; } @@ -600,7 +600,6 @@ public class OpenIddictEntityFrameworkCoreTokenStore< { cancellationToken.ThrowIfCancellationRequested(); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { try @@ -633,7 +632,6 @@ public class OpenIddictEntityFrameworkCoreTokenStore< } else -#endif { var strategy = context.Database.CreateExecutionStrategy(); var count = await strategy.ExecuteAsync(async () => @@ -729,7 +727,6 @@ public class OpenIddictEntityFrameworkCoreTokenStore< query = query.Where(token => token.Type == type); } -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await query.ExecuteUpdateAsync(entity => entity.SetProperty( @@ -738,7 +735,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -782,7 +779,6 @@ public class OpenIddictEntityFrameworkCoreTokenStore< var context = await Context.GetDbContextAsync(cancellationToken); var key = ConvertIdentifierFromString(identifier); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await ( @@ -795,7 +791,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -852,7 +848,6 @@ public class OpenIddictEntityFrameworkCoreTokenStore< var context = await Context.GetDbContextAsync(cancellationToken); var key = ConvertIdentifierFromString(identifier); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await ( @@ -865,7 +860,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -921,7 +916,6 @@ public class OpenIddictEntityFrameworkCoreTokenStore< var context = await Context.GetDbContextAsync(cancellationToken); -#if SUPPORTS_BULK_DBSET_OPERATIONS if (!Options.CurrentValue.DisableBulkOperations) { return await ( @@ -934,7 +928,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< // Note: calling DbContext.SaveChangesAsync() is not necessary // with bulk update operations as they are executed immediately. } -#endif + List? exceptions = null; var result = 0L; @@ -985,28 +979,8 @@ public class OpenIddictEntityFrameworkCoreTokenStore< if (!string.IsNullOrEmpty(identifier)) { -#if SUPPORTS_DBSET_VALUETASK_FINDASYNC token.Application = await context.Set() .FindAsync([ConvertIdentifierFromString(identifier)], cancellationToken); -#else - // Warning: when targeting older TFMs, FindAsync() is deliberately not used to work around a breaking - // change introduced in Entity Framework Core 3.x (where a ValueTask instead of a Task is now returned). - - var key = ConvertIdentifierFromString(identifier); - - token.Application = GetTrackedEntity() ?? await QueryAsync() ?? - throw new InvalidOperationException(SR.GetResourceString(SR.ID0250)); - - TApplication? GetTrackedEntity() => - (from entry in context.ChangeTracker.Entries() - where entry.Entity.Id is TKey identifier && identifier.Equals(key) - select entry.Entity).FirstOrDefault(); - - Task QueryAsync() => - (from application in context.Set().AsTracking() - where application.Id!.Equals(key) - select application).FirstOrDefaultAsync(cancellationToken); -#endif } else @@ -1036,28 +1010,8 @@ public class OpenIddictEntityFrameworkCoreTokenStore< if (!string.IsNullOrEmpty(identifier)) { -#if SUPPORTS_DBSET_VALUETASK_FINDASYNC token.Authorization = await context.Set() .FindAsync([ConvertIdentifierFromString(identifier)], cancellationToken); -#else - // Warning: when targeting older TFMs, FindAsync() is deliberately not used to work around a breaking - // change introduced in Entity Framework Core 3.x (where a ValueTask instead of a Task is now returned). - - var key = ConvertIdentifierFromString(identifier); - - token.Authorization = GetTrackedEntity() ?? await QueryAsync() ?? - throw new InvalidOperationException(SR.GetResourceString(SR.ID0251)); - - TAuthorization? GetTrackedEntity() => - (from entry in context.ChangeTracker.Entries() - where entry.Entity.Id is TKey identifier && identifier.Equals(key) - select entry.Entity).FirstOrDefault(); - - Task QueryAsync() => - (from authorization in context.Set().AsTracking() - where authorization.Id!.Equals(key) - select authorization).FirstOrDefaultAsync(cancellationToken); -#endif } else diff --git a/src/OpenIddict.MongoDb.Models/OpenIddict.MongoDb.Models.csproj b/src/OpenIddict.MongoDb.Models/OpenIddict.MongoDb.Models.csproj index 0588bae2..5a5e8a6c 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddict.MongoDb.Models.csproj +++ b/src/OpenIddict.MongoDb.Models/OpenIddict.MongoDb.Models.csproj @@ -1,12 +1,7 @@  - - net472; - net48; - $(NetCoreTargetFrameworks); - netstandard2.1 - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) false @@ -19,8 +14,7 @@ - + diff --git a/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj b/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj index 73ea988d..806717d1 100644 --- a/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj +++ b/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj @@ -1,12 +1,7 @@  - - net472; - net48; - $(NetCoreTargetFrameworks); - netstandard2.1 - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/src/OpenIddict.Quartz/OpenIddict.Quartz.csproj b/src/OpenIddict.Quartz/OpenIddict.Quartz.csproj index b3293c82..550900d5 100644 --- a/src/OpenIddict.Quartz/OpenIddict.Quartz.csproj +++ b/src/OpenIddict.Quartz/OpenIddict.Quartz.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddict.Server.AspNetCore.csproj b/src/OpenIddict.Server.AspNetCore/OpenIddict.Server.AspNetCore.csproj index 5264b5b6..4feae9ec 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddict.Server.AspNetCore.csproj +++ b/src/OpenIddict.Server.AspNetCore/OpenIddict.Server.AspNetCore.csproj @@ -1,7 +1,7 @@  - $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) @@ -13,25 +13,8 @@ - - - - - - - - - - - - + diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs index 545b24e8..d4fd2c11 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs @@ -62,7 +62,6 @@ public sealed class OpenIddictServerAspNetCoreConfiguration : IConfigureOptions< throw new InvalidOperationException(SR.GetResourceString(SR.ID0109)); } -#if SUPPORTS_AUTHENTICATION_HANDLER_SELECTION_FALLBACK // Starting in ASP.NET 7.0, the authentication stack integrates a fallback // mechanism to select the default scheme to use when no value is set, but // only if a single handler has been registered in the authentication options. @@ -81,7 +80,6 @@ public sealed class OpenIddictServerAspNetCoreConfiguration : IConfigureOptions< { options.AddScheme(Guid.NewGuid().ToString(), displayName: null); } -#endif static bool TryValidate(IDictionary map, string? scheme) { diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs index 87034bda..31018c57 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs @@ -29,7 +29,6 @@ public sealed class OpenIddictServerAspNetCoreHandler : AuthenticationHandler /// Creates a new instance of the class. /// -#if SUPPORTS_AUTHENTICATION_HANDLER_TIME_PROVIDER_ARGUMENT public OpenIddictServerAspNetCoreHandler( IOpenIddictServerDispatcher dispatcher, IOpenIddictServerFactory factory, @@ -41,20 +40,6 @@ public sealed class OpenIddictServerAspNetCoreHandler : AuthenticationHandler options, - ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock) - : base(options, logger, encoder, clock) - { - _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); - _factory = factory ?? throw new ArgumentNullException(nameof(factory)); - } -#endif /// public async Task HandleRequestAsync() diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs index c20568a2..58e77a97 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs @@ -97,7 +97,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers var response = context.Transaction.GetHttpRequest()?.HttpContext.Response ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0114)); -#if SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS var location = QueryHelpers.AddQueryString(context.RequestUri.GetLeftPart(UriPartial.Path), from parameter in context.Response.GetParameters() let values = (ImmutableArray?) parameter.Value @@ -105,20 +104,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers from value in values.GetValueOrDefault() where !string.IsNullOrEmpty(value) select KeyValuePair.Create(parameter.Key, value)); -#else - var location = context.RequestUri.GetLeftPart(UriPartial.Path); - foreach (var (key, value) in - from parameter in context.Response.GetParameters() - let values = (ImmutableArray?) parameter.Value - where values is not null - from value in values.GetValueOrDefault() - where !string.IsNullOrEmpty(value) - select (parameter.Key, Value: value)) - { - location = QueryHelpers.AddQueryString(location, key, value); - } -#endif response.Redirect(location); context.HandleRequest(); @@ -253,7 +239,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers // with the same name are used by derived drafts like the OAuth 2.0 token exchange specification. // For consistency, multiple parameters with the same name are also supported by this endpoint. -#if SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS var location = QueryHelpers.AddQueryString(context.RedirectUri, from parameter in context.Response.GetParameters() let values = (ImmutableArray?) parameter.Value @@ -261,20 +246,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers from value in values.GetValueOrDefault() where !string.IsNullOrEmpty(value) select KeyValuePair.Create(parameter.Key, value)); -#else - var location = context.RedirectUri; - foreach (var (key, value) in - from parameter in context.Response.GetParameters() - let values = (ImmutableArray?) parameter.Value - where values is not null - from value in values.GetValueOrDefault() - where !string.IsNullOrEmpty(value) - select (parameter.Key, Value: value)) - { - location = QueryHelpers.AddQueryString(location, key, value); - } -#endif response.Redirect(location); context.HandleRequest(); diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs index ee677d8f..212e5e61 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs @@ -78,7 +78,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers var response = context.Transaction.GetHttpRequest()?.HttpContext.Response ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0114)); -#if SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS var location = QueryHelpers.AddQueryString(context.RequestUri.GetLeftPart(UriPartial.Path), from parameter in context.Response.GetParameters() let values = (ImmutableArray?) parameter.Value @@ -86,20 +85,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers from value in values.GetValueOrDefault() where !string.IsNullOrEmpty(value) select KeyValuePair.Create(parameter.Key, value)); -#else - var location = context.RequestUri.GetLeftPart(UriPartial.Path); - foreach (var (key, value) in - from parameter in context.Response.GetParameters() - let values = (ImmutableArray?) parameter.Value - where values is not null - from value in values.GetValueOrDefault() - where !string.IsNullOrEmpty(value) - select (parameter.Key, Value: value)) - { - location = QueryHelpers.AddQueryString(location, key, value); - } -#endif response.Redirect(location); context.HandleRequest(); @@ -145,7 +131,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers // with the same name are used by derived drafts like the OAuth 2.0 token exchange specification. // For consistency, multiple parameters with the same name are also supported by this endpoint. -#if SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS var location = QueryHelpers.AddQueryString(context.PostLogoutRedirectUri, from parameter in context.Response.GetParameters() let values = (ImmutableArray?) parameter.Value @@ -153,20 +138,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers from value in values.GetValueOrDefault() where !string.IsNullOrEmpty(value) select KeyValuePair.Create(parameter.Key, value)); -#else - var location = context.PostLogoutRedirectUri; - foreach (var (key, value) in - from parameter in context.Response.GetParameters() - let values = (ImmutableArray?) parameter.Value - where values is not null - from value in values.GetValueOrDefault() - where !string.IsNullOrEmpty(value) - select (parameter.Key, Value: value)) - { - location = QueryHelpers.AddQueryString(location, key, value); - } -#endif response.Redirect(location); context.HandleRequest(); diff --git a/src/OpenIddict.Server.DataProtection/OpenIddict.Server.DataProtection.csproj b/src/OpenIddict.Server.DataProtection/OpenIddict.Server.DataProtection.csproj index 62b42cb2..6b375534 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddict.Server.DataProtection.csproj +++ b/src/OpenIddict.Server.DataProtection/OpenIddict.Server.DataProtection.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) @@ -18,15 +14,7 @@ - - - diff --git a/src/OpenIddict.Server/OpenIddict.Server.csproj b/src/OpenIddict.Server/OpenIddict.Server.csproj index 2ed0a516..b62c0061 100644 --- a/src/OpenIddict.Server/OpenIddict.Server.csproj +++ b/src/OpenIddict.Server/OpenIddict.Server.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) @@ -25,6 +21,10 @@ To use the server feature on ASP.NET Core or OWIN/Katana, reference the OpenIddi + + + + diff --git a/src/OpenIddict.Server/OpenIddictServerBuilder.cs b/src/OpenIddict.Server/OpenIddictServerBuilder.cs index bca5f7a7..3fd8ccf4 100644 --- a/src/OpenIddict.Server/OpenIddictServerBuilder.cs +++ b/src/OpenIddict.Server/OpenIddictServerBuilder.cs @@ -218,8 +218,7 @@ public sealed class OpenIddictServerBuilder if (!certificates.Exists(certificate => certificate.NotBefore < now.LocalDateTime && certificate.NotAfter > now.LocalDateTime)) { -#if SUPPORTS_CERTIFICATE_GENERATION - using var algorithm = OpenIddictHelpers.CreateRsaKey(size: 4096); + using var algorithm = RSA.Create(keySizeInBits: 4096); var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment, critical: true)); @@ -250,11 +249,7 @@ public sealed class OpenIddictServerBuilder flags |= X509KeyStorageFlags.Exportable; } -#if SUPPORTS_CERTIFICATE_LOADER certificate = X509CertificateLoader.LoadPkcs12(data, string.Empty, flags); -#else - certificate = new X509Certificate2(data, string.Empty, flags); -#endif certificates.Insert(0, certificate); } @@ -264,9 +259,6 @@ public sealed class OpenIddictServerBuilder } store.Add(certificate); -#else - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0264)); -#endif } options.EncryptionCredentials.AddRange( @@ -305,13 +297,13 @@ public sealed class OpenIddictServerBuilder { SecurityAlgorithms.Aes256KW => AddEncryptionCredentials(new EncryptingCredentials( - new SymmetricSecurityKey(OpenIddictHelpers.CreateRandomArray(size: 256)), + new SymmetricSecurityKey(RandomNumberGenerator.GetBytes(count: 256 / 8)), algorithm, SecurityAlgorithms.Aes256CbcHmacSha512)), SecurityAlgorithms.RsaOAEP or SecurityAlgorithms.RsaOaepKeyWrap => AddEncryptionCredentials(new EncryptingCredentials( - new RsaSecurityKey(OpenIddictHelpers.CreateRsaKey(size: 4096)), + new RsaSecurityKey(RSA.Create(keySizeInBits: 4096)), algorithm, SecurityAlgorithms.Aes256CbcHmacSha512)), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0058)) @@ -355,14 +347,10 @@ public sealed class OpenIddictServerBuilder /// The password used to open the certificate. /// The instance. public OpenIddictServerBuilder AddEncryptionCertificate(Assembly assembly, string resource, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddEncryptionCertificate(assembly, resource, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddEncryptionCertificate(assembly, resource, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers an encryption certificate retrieved from an embedded resource. @@ -392,14 +380,10 @@ public sealed class OpenIddictServerBuilder /// The password used to open the certificate. /// The instance. public OpenIddictServerBuilder AddEncryptionCertificate(Stream stream, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddEncryptionCertificate(stream, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddEncryptionCertificate(stream, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers an encryption certificate extracted from a stream. @@ -415,16 +399,13 @@ public sealed class OpenIddictServerBuilder using var buffer = new MemoryStream(); stream.CopyTo(buffer); -#if SUPPORTS_CERTIFICATE_LOADER var certificate = X509Certificate2.GetCertContentType(buffer.ToArray()) switch { X509ContentType.Pkcs12 => X509CertificateLoader.LoadPkcs12(buffer.ToArray(), password, flags), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0454)) }; -#else - var certificate = new X509Certificate2(buffer.ToArray(), password, flags); -#endif + return AddEncryptionCertificate(certificate); } @@ -522,7 +503,6 @@ public sealed class OpenIddictServerBuilder return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.HmacSha256)); } -#if SUPPORTS_ECDSA // Note: ECDSA algorithms are bound to specific curves and must be treated separately. if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { @@ -538,14 +518,6 @@ public sealed class OpenIddictServerBuilder { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha512)); } -#else - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256) || - key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384) || - key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha512)) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0069)); - } -#endif throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); } @@ -596,8 +568,7 @@ public sealed class OpenIddictServerBuilder if (!certificates.Exists(certificate => certificate.NotBefore < now.LocalDateTime && certificate.NotAfter > now.LocalDateTime)) { -#if SUPPORTS_CERTIFICATE_GENERATION - using var algorithm = OpenIddictHelpers.CreateRsaKey(size: 4096); + using var algorithm = RSA.Create(keySizeInBits: 4096); var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature, critical: true)); @@ -628,11 +599,7 @@ public sealed class OpenIddictServerBuilder flags |= X509KeyStorageFlags.Exportable; } -#if SUPPORTS_CERTIFICATE_LOADER certificate = X509CertificateLoader.LoadPkcs12(data, string.Empty, flags); -#else - certificate = new X509Certificate2(data, string.Empty, flags); -#endif certificates.Insert(0, certificate); } @@ -642,9 +609,6 @@ public sealed class OpenIddictServerBuilder } store.Add(certificate); -#else - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0264)); -#endif } options.SigningCredentials.AddRange( @@ -693,32 +657,22 @@ public sealed class OpenIddictServerBuilder SecurityAlgorithms.RsaSsaPssSha384Signature or SecurityAlgorithms.RsaSsaPssSha512Signature => AddSigningCredentials(new SigningCredentials(new RsaSecurityKey( - OpenIddictHelpers.CreateRsaKey(size: 4096)), algorithm)), + RSA.Create(keySizeInBits: 4096)), algorithm)), -#if SUPPORTS_ECDSA SecurityAlgorithms.EcdsaSha256 or SecurityAlgorithms.EcdsaSha256Signature => AddSigningCredentials(new SigningCredentials(new ECDsaSecurityKey( - OpenIddictHelpers.CreateEcdsaKey(ECCurve.NamedCurves.nistP256)), algorithm)), + ECDsa.Create(ECCurve.NamedCurves.nistP256)), algorithm)), SecurityAlgorithms.EcdsaSha384 or SecurityAlgorithms.EcdsaSha384Signature => AddSigningCredentials(new SigningCredentials(new ECDsaSecurityKey( - OpenIddictHelpers.CreateEcdsaKey(ECCurve.NamedCurves.nistP384)), algorithm)), + ECDsa.Create(ECCurve.NamedCurves.nistP384)), algorithm)), SecurityAlgorithms.EcdsaSha512 or SecurityAlgorithms.EcdsaSha512Signature => AddSigningCredentials(new SigningCredentials(new ECDsaSecurityKey( - OpenIddictHelpers.CreateEcdsaKey(ECCurve.NamedCurves.nistP521)), algorithm)), -#else - SecurityAlgorithms.EcdsaSha256 or - SecurityAlgorithms.EcdsaSha384 or - SecurityAlgorithms.EcdsaSha512 or - SecurityAlgorithms.EcdsaSha256Signature or - SecurityAlgorithms.EcdsaSha384Signature or - SecurityAlgorithms.EcdsaSha512Signature - => throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0069)), -#endif + ECDsa.Create(ECCurve.NamedCurves.nistP521)), algorithm)), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0058)) }; @@ -761,14 +715,10 @@ public sealed class OpenIddictServerBuilder /// The password used to open the certificate. /// The instance. public OpenIddictServerBuilder AddSigningCertificate(Assembly assembly, string resource, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddSigningCertificate(assembly, resource, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddSigningCertificate(assembly, resource, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers a signing certificate retrieved from an embedded resource. @@ -798,14 +748,10 @@ public sealed class OpenIddictServerBuilder /// The password used to open the certificate. /// The instance. public OpenIddictServerBuilder AddSigningCertificate(Stream stream, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddSigningCertificate(stream, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddSigningCertificate(stream, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers a signing certificate extracted from a stream. @@ -821,16 +767,13 @@ public sealed class OpenIddictServerBuilder using var buffer = new MemoryStream(); stream.CopyTo(buffer); -#if SUPPORTS_CERTIFICATE_LOADER var certificate = X509Certificate2.GetCertContentType(buffer.ToArray()) switch { X509ContentType.Pkcs12 => X509CertificateLoader.LoadPkcs12(buffer.ToArray(), password, flags), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0454)) }; -#else - var certificate = new X509Certificate2(buffer.ToArray(), password, flags); -#endif + return AddSigningCertificate(certificate); } diff --git a/src/OpenIddict.Server/OpenIddictServerConfiguration.cs b/src/OpenIddict.Server/OpenIddictServerConfiguration.cs index 772df51e..061a5caf 100644 --- a/src/OpenIddict.Server/OpenIddictServerConfiguration.cs +++ b/src/OpenIddict.Server/OpenIddictServerConfiguration.cs @@ -615,7 +615,6 @@ public sealed class OpenIddictServerConfiguration : IPostConfigureOptions SecurityAlgorithms.EcdsaSha256, SecurityAlgorithms.EcdsaSha384 or SecurityAlgorithms.EcdsaSha384Signature => SecurityAlgorithms.EcdsaSha384, SecurityAlgorithms.EcdsaSha512 or SecurityAlgorithms.EcdsaSha512Signature => SecurityAlgorithms.EcdsaSha512, -#endif + SecurityAlgorithms.RsaSha256 or SecurityAlgorithms.RsaSha256Signature => SecurityAlgorithms.RsaSha256, SecurityAlgorithms.RsaSha384 or SecurityAlgorithms.RsaSha384Signature @@ -1167,7 +1167,6 @@ public static partial class OpenIddictServerHandlers foreach (var credentials in context.Options.SigningCredentials) { -#if SUPPORTS_ECDSA if (!credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.RsaSha256) && !credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.RsaSsaPssSha256) && !credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256) && @@ -1178,15 +1177,6 @@ public static partial class OpenIddictServerHandlers continue; } -#else - if (!credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.RsaSha256) && - !credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.RsaSsaPssSha256)) - { - context.Logger.LogInformation(6072, SR.GetResourceString(SR.ID6072), credentials.Key.GetType().Name); - - continue; - } -#endif var key = new JsonWebKey { @@ -1195,14 +1185,13 @@ public static partial class OpenIddictServerHandlers // Resolve the JWA identifier from the algorithm specified in the credentials. Alg = credentials.Algorithm switch { -#if SUPPORTS_ECDSA SecurityAlgorithms.EcdsaSha256 or SecurityAlgorithms.EcdsaSha256Signature => SecurityAlgorithms.EcdsaSha256, SecurityAlgorithms.EcdsaSha384 or SecurityAlgorithms.EcdsaSha384Signature => SecurityAlgorithms.EcdsaSha384, SecurityAlgorithms.EcdsaSha512 or SecurityAlgorithms.EcdsaSha512Signature => SecurityAlgorithms.EcdsaSha512, -#endif + SecurityAlgorithms.RsaSha256 or SecurityAlgorithms.RsaSha256Signature => SecurityAlgorithms.RsaSha256, SecurityAlgorithms.RsaSha384 or SecurityAlgorithms.RsaSha384Signature @@ -1260,7 +1249,6 @@ public static partial class OpenIddictServerHandlers key.N = Base64UrlEncoder.Encode(parameters.Value.Modulus); } -#if SUPPORTS_ECDSA else if (credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256) || credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384) || credentials.Key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha512)) @@ -1281,10 +1269,17 @@ public static partial class OpenIddictServerHandlers continue; } - var curve = - OpenIddictHelpers.IsEcCurve(parameters.Value, ECCurve.NamedCurves.nistP256) ? JsonWebKeyECTypes.P256 : - OpenIddictHelpers.IsEcCurve(parameters.Value, ECCurve.NamedCurves.nistP384) ? JsonWebKeyECTypes.P384 : - OpenIddictHelpers.IsEcCurve(parameters.Value, ECCurve.NamedCurves.nistP521) ? JsonWebKeyECTypes.P521 : null; + // Warning: on .NET Framework 4.x, exported ECParameters generally have a null OID + // value attached. To work around this limitation, both the raw OID values and the + // friendly names are compared to determine whether the curve is of the specified type. + var curve = parameters.Value.Curve.Oid switch + { + { FriendlyName: "nistP256" } or { Value: "1.2.840.10045.3.1.7" } => JsonWebKeyECTypes.P256, + { FriendlyName: "nistP384" } or { Value: "1.3.132.0.34" } => JsonWebKeyECTypes.P384, + { FriendlyName: "nistP521" } or { Value: "1.3.132.0.35" } => JsonWebKeyECTypes.P521, + + _ => null + }; if (string.IsNullOrEmpty(curve)) { @@ -1296,9 +1291,6 @@ public static partial class OpenIddictServerHandlers Debug.Assert(parameters.Value.Q.X is not null && parameters.Value.Q.Y is not null, SR.GetResourceString(SR.ID4004)); - Debug.Assert(parameters.Value.Curve.Oid is not null, SR.GetResourceString(SR.ID4011)); - Debug.Assert(parameters.Value.Curve.IsNamed, SR.GetResourceString(SR.ID4005)); - key.Kty = JsonWebAlgorithmsKeyTypes.EllipticCurve; key.Crv = curve; @@ -1307,12 +1299,10 @@ public static partial class OpenIddictServerHandlers key.X = Base64UrlEncoder.Encode(parameters.Value.Q.X); key.Y = Base64UrlEncoder.Encode(parameters.Value.Q.Y); } -#endif // If the signing key is embedded in a X.509 certificate, set // the x5t and x5c parameters using the certificate details. - var certificate = (credentials.Key as X509SecurityKey)?.Certificate; - if (certificate is not null) + if (credentials.Key is X509SecurityKey { Certificate: X509Certificate2 certificate }) { // x5t must be base64url-encoded. // See https://tools.ietf.org/html/rfc7517#section-4.8. @@ -1320,7 +1310,7 @@ public static partial class OpenIddictServerHandlers // x5t#S256 must be base64url-encoded. // See https://tools.ietf.org/html/rfc7517#section-4.9. - key.X5tS256 = Base64UrlEncoder.Encode(OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)); + key.X5tS256 = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)); // Unlike E or N, the certificates contained in x5c // must be base64-encoded and not base64url-encoded. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs index 138ab343..8d9b400f 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs @@ -8,6 +8,7 @@ using System.Collections.Immutable; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security.Claims; +using System.Security.Cryptography; using System.Text; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -1993,7 +1994,7 @@ public static partial class OpenIddictServerHandlers CodeChallengeMethods.Plain => context.Request.CodeVerifier, CodeChallengeMethods.Sha256 => Base64UrlEncoder.Encode( - OpenIddictHelpers.ComputeSha256Hash(Encoding.ASCII.GetBytes(context.Request.CodeVerifier))), + SHA256.HashData(Encoding.ASCII.GetBytes(context.Request.CodeVerifier))), null or { Length: 0 } => throw new InvalidOperationException(SR.GetResourceString(SR.ID0268)), @@ -2002,7 +2003,7 @@ public static partial class OpenIddictServerHandlers // Compare the verifier and the code challenge: if the two don't match, return an error. // Note: to prevent timing attacks, a time-constant comparer is always used. - if (!OpenIddictHelpers.FixedTimeEquals( + if (!CryptographicOperations.FixedTimeEquals( left: MemoryMarshal.AsBytes(comparand.AsSpan()), right: MemoryMarshal.AsBytes(challenge.AsSpan()))) { diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs index 7325d43c..7398f7a2 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs @@ -9,7 +9,9 @@ using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Claims; +using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; +using System.Text; using System.Text.Json.Nodes; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -1177,8 +1179,8 @@ public static partial class OpenIddictServerHandlers // If the thumbprint of the certificate doesn't match the hash // resolved from the confirmation claim, return an error. - var hash = Base64UrlEncoder.Encode(OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)); - if (!OpenIddictHelpers.FixedTimeEquals( + var hash = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)); + if (!CryptographicOperations.FixedTimeEquals( left : MemoryMarshal.AsBytes(hash), right: MemoryMarshal.AsBytes(thumbprint))) { @@ -1829,7 +1831,7 @@ public static partial class OpenIddictServerHandlers { do { - descriptor.ReferenceId = OpenIddictHelpers.CreateRandomString( + descriptor.ReferenceId = CreateRandomString( charset: [.. context.Options.UserCodeCharset], count : context.Options.UserCodeLength); } @@ -1842,7 +1844,7 @@ public static partial class OpenIddictServerHandlers else { // For other tokens, generate a base64url-encoded 256-bit random identifier. - descriptor.ReferenceId = Base64UrlEncoder.Encode(OpenIddictHelpers.CreateRandomArray(size: 256)); + descriptor.ReferenceId = Base64UrlEncoder.Encode(RandomNumberGenerator.GetBytes(count: 256 / 8)); } } @@ -1856,6 +1858,19 @@ public static partial class OpenIddictServerHandlers context.Token = descriptor.ReferenceId; context.Logger.LogTrace(6015, SR.GetResourceString(SR.ID6015), descriptor.ReferenceId, identifier, context.TokenType); } + + static string CreateRandomString(ReadOnlySpan charset, int count) + { + var builder = new StringBuilder(); + + for (var index = 0; index < count; index++) + { + // Pick a character in the specified charset by generating a random index. + builder.Append(RandomNumberGenerator.GetInt32(0, charset.Length)); + } + + return builder.ToString(); + } } } } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.cs index cdd1526a..ef19dafa 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.cs @@ -3662,8 +3662,7 @@ public static partial class OpenIddictServerHandlers static JsonNode CreateConfirmationClaim(X509Certificate2 certificate) => new JsonObject { - [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode( - OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)) + [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)) }; } } @@ -4192,8 +4191,7 @@ public static partial class OpenIddictServerHandlers static JsonNode CreateConfirmationClaim(X509Certificate2 certificate) => new JsonObject { - [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode( - OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)) + [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)) }; } } @@ -4486,8 +4484,7 @@ public static partial class OpenIddictServerHandlers static JsonNode CreateConfirmationClaim(X509Certificate2 certificate) => new JsonObject { - [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode( - OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)) + [JsonWebKeyParameterNames.X5tS256] = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)) }; } } @@ -5338,21 +5335,21 @@ public static partial class OpenIddictServerHandlers { Algorithm: SecurityAlgorithms.HmacSha256 or SecurityAlgorithms.HmacSha256Signature } or { Algorithm: SecurityAlgorithms.RsaSha256 or SecurityAlgorithms.RsaSha256Signature } or { Algorithm: SecurityAlgorithms.RsaSsaPssSha256 or SecurityAlgorithms.RsaSsaPssSha256Signature } - => OpenIddictHelpers.ComputeSha256Hash(Encoding.ASCII.GetBytes(token)), + => SHA256.HashData(Encoding.ASCII.GetBytes(token)), { Digest: SecurityAlgorithms.Sha384 or SecurityAlgorithms.Sha384Digest } or { Algorithm: SecurityAlgorithms.EcdsaSha384 or SecurityAlgorithms.EcdsaSha384Signature } or { Algorithm: SecurityAlgorithms.HmacSha384 or SecurityAlgorithms.HmacSha384Signature } or { Algorithm: SecurityAlgorithms.RsaSha384 or SecurityAlgorithms.RsaSha384Signature } or { Algorithm: SecurityAlgorithms.RsaSsaPssSha384 or SecurityAlgorithms.RsaSsaPssSha384Signature } - => OpenIddictHelpers.ComputeSha384Hash(Encoding.ASCII.GetBytes(token)), + => SHA384.HashData(Encoding.ASCII.GetBytes(token)), { Digest: SecurityAlgorithms.Sha512 or SecurityAlgorithms.Sha512Digest } or { Algorithm: SecurityAlgorithms.EcdsaSha512 or SecurityAlgorithms.EcdsaSha512Signature } or { Algorithm: SecurityAlgorithms.HmacSha512 or SecurityAlgorithms.HmacSha512Signature } or { Algorithm: SecurityAlgorithms.RsaSha512 or SecurityAlgorithms.RsaSha512Signature } or { Algorithm: SecurityAlgorithms.RsaSsaPssSha512 or SecurityAlgorithms.RsaSsaPssSha512Signature } - => OpenIddictHelpers.ComputeSha512Hash(Encoding.ASCII.GetBytes(token)), + => SHA512.HashData(Encoding.ASCII.GetBytes(token)), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0267)) }; diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddict.Validation.AspNetCore.csproj b/src/OpenIddict.Validation.AspNetCore/OpenIddict.Validation.AspNetCore.csproj index 8ff58969..6e796f07 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddict.Validation.AspNetCore.csproj +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddict.Validation.AspNetCore.csproj @@ -1,7 +1,7 @@  - $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) @@ -13,24 +13,8 @@ - - - - - - - - - - - + diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs index d453e53b..7066599e 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs @@ -53,7 +53,6 @@ public sealed class OpenIddictValidationAspNetCoreConfiguration : IConfigureOpti throw new InvalidOperationException(SR.GetResourceString(SR.ID0165)); } -#if SUPPORTS_AUTHENTICATION_HANDLER_SELECTION_FALLBACK // Starting in ASP.NET 7.0, the authentication stack integrates a fallback // mechanism to select the default scheme to use when no value is set, but // only if a single handler has been registered in the authentication options. @@ -69,7 +68,6 @@ public sealed class OpenIddictValidationAspNetCoreConfiguration : IConfigureOpti { options.AddScheme(Guid.NewGuid().ToString(), displayName: null); } -#endif static bool TryValidate(IDictionary map, string? scheme) { diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs index b668f0c8..ecc6818f 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs @@ -27,7 +27,6 @@ public sealed class OpenIddictValidationAspNetCoreHandler : AuthenticationHandle /// /// Creates a new instance of the class. /// -#if SUPPORTS_AUTHENTICATION_HANDLER_TIME_PROVIDER_ARGUMENT public OpenIddictValidationAspNetCoreHandler( IOpenIddictValidationDispatcher dispatcher, IOpenIddictValidationFactory factory, @@ -39,20 +38,6 @@ public sealed class OpenIddictValidationAspNetCoreHandler : AuthenticationHandle _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); _factory = factory ?? throw new ArgumentNullException(nameof(factory)); } -#else - public OpenIddictValidationAspNetCoreHandler( - IOpenIddictValidationDispatcher dispatcher, - IOpenIddictValidationFactory factory, - IOptionsMonitor options, - ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock) - : base(options, logger, encoder, clock) - { - _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); - _factory = factory ?? throw new ArgumentNullException(nameof(factory)); - } -#endif /// public async Task HandleRequestAsync() diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddict.Validation.DataProtection.csproj b/src/OpenIddict.Validation.DataProtection/OpenIddict.Validation.DataProtection.csproj index 50d58bbe..ab0a2129 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddict.Validation.DataProtection.csproj +++ b/src/OpenIddict.Validation.DataProtection/OpenIddict.Validation.DataProtection.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) @@ -18,15 +14,7 @@ - - - diff --git a/src/OpenIddict.Validation.ServerIntegration/OpenIddict.Validation.ServerIntegration.csproj b/src/OpenIddict.Validation.ServerIntegration/OpenIddict.Validation.ServerIntegration.csproj index d7681dca..9d179813 100644 --- a/src/OpenIddict.Validation.ServerIntegration/OpenIddict.Validation.ServerIntegration.csproj +++ b/src/OpenIddict.Validation.ServerIntegration/OpenIddict.Validation.ServerIntegration.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj b/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj index 3b2fcfcb..e8ed6ece 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) @@ -21,8 +17,7 @@ - + diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs index a221f90e..25906d18 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpContext.cs @@ -5,7 +5,6 @@ */ using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using Microsoft.IdentityModel.Tokens; @@ -44,7 +43,7 @@ public sealed class OpenIddictValidationSystemNetHttpContext { ArgumentNullException.ThrowIfNull(context); - using var algorithm = CreateAlgorithm(); + using var algorithm = SHA256.Create(); if (context.LocalCertificate is X509Certificate2 certificate) { @@ -54,14 +53,5 @@ public sealed class OpenIddictValidationSystemNetHttpContext algorithm.TransformFinalBlock([], 0, 0); return Base64UrlEncoder.Encode(algorithm.Hash); - - [UnconditionalSuppressMessage("Trimming", "IL2026", - Justification = "The default implementation is always used when no custom algorithm was registered.")] - static SHA256 CreateAlgorithm() => CryptoConfig.CreateFromName("OpenIddict SHA-256 Cryptographic Provider") switch - { - SHA256 result => result, - null => SHA256.Create(), - var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName)) - }; } } diff --git a/src/OpenIddict.Validation/OpenIddict.Validation.csproj b/src/OpenIddict.Validation/OpenIddict.Validation.csproj index 99c49d2f..eb5469ca 100644 --- a/src/OpenIddict.Validation/OpenIddict.Validation.csproj +++ b/src/OpenIddict.Validation/OpenIddict.Validation.csproj @@ -1,11 +1,7 @@  - - $(NetFrameworkTargetFrameworks); - $(NetCoreTargetFrameworks); - $(NetStandardTargetFrameworks) - + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) @@ -26,6 +22,10 @@ To use the validation feature on ASP.NET Core or OWIN/Katana, reference the Open + + + + diff --git a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs index d0c2da48..a81aa907 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs @@ -204,14 +204,10 @@ public sealed class OpenIddictValidationBuilder /// The instance. public OpenIddictValidationBuilder AddEncryptionCertificate( Assembly assembly, string resource, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddEncryptionCertificate(assembly, resource, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddEncryptionCertificate(assembly, resource, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers an encryption certificate retrieved from an embedded resource. @@ -241,14 +237,10 @@ public sealed class OpenIddictValidationBuilder /// The password used to open the certificate. /// The instance. public OpenIddictValidationBuilder AddEncryptionCertificate(Stream stream, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddEncryptionCertificate(stream, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddEncryptionCertificate(stream, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers an encryption certificate extracted from a stream. @@ -265,16 +257,13 @@ public sealed class OpenIddictValidationBuilder using var buffer = new MemoryStream(); stream.CopyTo(buffer); -#if SUPPORTS_CERTIFICATE_LOADER var certificate = X509Certificate2.GetCertContentType(buffer.ToArray()) switch { X509ContentType.Pkcs12 => X509CertificateLoader.LoadPkcs12(buffer.ToArray(), password, flags), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0454)) }; -#else - var certificate = new X509Certificate2(buffer.ToArray(), password, flags); -#endif + return AddEncryptionCertificate(certificate); } @@ -373,7 +362,6 @@ public sealed class OpenIddictValidationBuilder return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.HmacSha256)); } -#if SUPPORTS_ECDSA // Note: ECDSA algorithms are bound to specific curves and must be treated separately. if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { @@ -389,14 +377,6 @@ public sealed class OpenIddictValidationBuilder { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha512)); } -#else - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256) || - key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384) || - key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha512)) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0069)); - } -#endif throw new InvalidOperationException(SR.GetResourceString(SR.ID0068)); } @@ -450,14 +430,10 @@ public sealed class OpenIddictValidationBuilder /// The password used to open the certificate. /// The instance. public OpenIddictValidationBuilder AddSigningCertificate(Assembly assembly, string resource, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddSigningCertificate(assembly, resource, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddSigningCertificate(assembly, resource, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers a signing certificate retrieved from an embedded resource. @@ -487,14 +463,10 @@ public sealed class OpenIddictValidationBuilder /// The password used to open the certificate. /// The instance. public OpenIddictValidationBuilder AddSigningCertificate(Stream stream, string? password) -#if SUPPORTS_EPHEMERAL_KEY_SETS // Note: ephemeral key sets are currently not supported on macOS. => AddSigningCertificate(stream, password, OperatingSystem.IsMacOS() ? X509KeyStorageFlags.MachineKeySet : X509KeyStorageFlags.EphemeralKeySet); -#else - => AddSigningCertificate(stream, password, X509KeyStorageFlags.MachineKeySet); -#endif /// /// Registers a signing certificate extracted from a stream. @@ -510,16 +482,13 @@ public sealed class OpenIddictValidationBuilder using var buffer = new MemoryStream(); stream.CopyTo(buffer); -#if SUPPORTS_CERTIFICATE_LOADER var certificate = X509Certificate2.GetCertContentType(buffer.ToArray()) switch { X509ContentType.Pkcs12 => X509CertificateLoader.LoadPkcs12(buffer.ToArray(), password, flags), _ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0454)) }; -#else - var certificate = new X509Certificate2(buffer.ToArray(), password, flags); -#endif + return AddSigningCertificate(certificate); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs index fc34bd63..b1753420 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Claims; +using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text.Json.Nodes; using Microsoft.Extensions.Logging; @@ -865,8 +866,8 @@ public static partial class OpenIddictValidationHandlers // If the thumbprint of the certificate doesn't match the hash // resolved from the confirmation claim, return an error. - var hash = Base64UrlEncoder.Encode(OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)); - if (!OpenIddictHelpers.FixedTimeEquals( + var hash = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)); + if (!CryptographicOperations.FixedTimeEquals( left : MemoryMarshal.AsBytes(hash), right: MemoryMarshal.AsBytes(thumbprint))) { diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs index 9aefdd4d..d094de36 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs @@ -9,6 +9,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security.Claims; +using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text.Json.Nodes; using Microsoft.Extensions.Logging; @@ -920,8 +921,8 @@ public static partial class OpenIddictValidationHandlers // If the thumbprint of the certificate doesn't match the hash // resolved from the confirmation claim, return an error. - var hash = Base64UrlEncoder.Encode(OpenIddictHelpers.ComputeSha256Hash(certificate.RawData)); - if (!OpenIddictHelpers.FixedTimeEquals( + var hash = Base64UrlEncoder.Encode(certificate.GetCertHash(HashAlgorithmName.SHA256)); + if (!CryptographicOperations.FixedTimeEquals( left : MemoryMarshal.AsBytes(hash), right: MemoryMarshal.AsBytes(thumbprint))) { diff --git a/src/OpenIddict/OpenIddict.csproj b/src/OpenIddict/OpenIddict.csproj index b88f3bda..13be7e2b 100644 --- a/src/OpenIddict/OpenIddict.csproj +++ b/src/OpenIddict/OpenIddict.csproj @@ -1,4 +1,4 @@ - + @@ -8,20 +8,8 @@ $(NetCoreIOSTargetFrameworks); $(NetCoreMacCatalystTargetFrameworks); $(NetCoreMacOSTargetFrameworks); - $(NetCoreWindowsTargetFrameworks); - $(NetStandardTargetFrameworks); - $(UniversalWindowsPlatformTargetFrameworks) + $(NetCoreWindowsTargetFrameworks) - - - .NETCoreApp false false false diff --git a/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj b/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj index 0b259d30..34532d9e 100644 --- a/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj +++ b/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Client.AspNetCore.IntegrationTests/OpenIddict.Client.AspNetCore.IntegrationTests.csproj b/test/OpenIddict.Client.AspNetCore.IntegrationTests/OpenIddict.Client.AspNetCore.IntegrationTests.csproj index 77867bb8..4c71641c 100644 --- a/test/OpenIddict.Client.AspNetCore.IntegrationTests/OpenIddict.Client.AspNetCore.IntegrationTests.csproj +++ b/test/OpenIddict.Client.AspNetCore.IntegrationTests/OpenIddict.Client.AspNetCore.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) @@ -13,10 +13,6 @@ - - - - diff --git a/test/OpenIddict.Client.IntegrationTests/OpenIddict.Client.IntegrationTests.csproj b/test/OpenIddict.Client.IntegrationTests/OpenIddict.Client.IntegrationTests.csproj index a5330ac6..902e4012 100644 --- a/test/OpenIddict.Client.IntegrationTests/OpenIddict.Client.IntegrationTests.csproj +++ b/test/OpenIddict.Client.IntegrationTests/OpenIddict.Client.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Client.Owin.IntegrationTests/OpenIddict.Client.Owin.IntegrationTests.csproj b/test/OpenIddict.Client.Owin.IntegrationTests/OpenIddict.Client.Owin.IntegrationTests.csproj index 997a2e49..942dcee3 100644 --- a/test/OpenIddict.Client.Owin.IntegrationTests/OpenIddict.Client.Owin.IntegrationTests.csproj +++ b/test/OpenIddict.Client.Owin.IntegrationTests/OpenIddict.Client.Owin.IntegrationTests.csproj @@ -1,7 +1,7 @@ - net472;net48 + $(NetFrameworkTargetFrameworks) diff --git a/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj b/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj index 8e694ed5..a7428b12 100644 --- a/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj +++ b/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj b/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj index 5419c2bb..6c13834a 100644 --- a/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj +++ b/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj index 227b3bbe..05a95bb9 100644 --- a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj +++ b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj b/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj index ae373f5d..b05f2bea 100644 --- a/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj +++ b/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) false false diff --git a/test/OpenIddict.Quartz.Tests/OpenIddict.Quartz.Tests.csproj b/test/OpenIddict.Quartz.Tests/OpenIddict.Quartz.Tests.csproj index 7392a58c..aee54d13 100644 --- a/test/OpenIddict.Quartz.Tests/OpenIddict.Quartz.Tests.csproj +++ b/test/OpenIddict.Quartz.Tests/OpenIddict.Quartz.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj index fe12937f..9ef9a227 100644 --- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj +++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) @@ -13,10 +13,6 @@ - - - - diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs index 0c030caf..ea9e3320 100644 --- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs +++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs @@ -5,11 +5,8 @@ */ using Microsoft.AspNetCore.TestHost; -using OpenIddict.Server.IntegrationTests; - -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST using Microsoft.Extensions.Hosting; -#endif +using OpenIddict.Server.IntegrationTests; namespace OpenIddict.Server.AspNetCore.IntegrationTests; @@ -18,7 +15,6 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests; /// public class OpenIddictServerAspNetCoreIntegrationTestServer : OpenIddictServerIntegrationTestServer { -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST public OpenIddictServerAspNetCoreIntegrationTestServer(IHost host) { Host = host; @@ -29,10 +25,6 @@ public class OpenIddictServerAspNetCoreIntegrationTestServer : OpenIddictServerI /// Gets the generic host used by this instance. /// public IHost Host { get; } -#else - public OpenIddictServerAspNetCoreIntegrationTestServer(TestServer server) - => Server = server; -#endif /// /// Gets the ASP.NET Core test server used by this instance. @@ -42,21 +34,13 @@ public class OpenIddictServerAspNetCoreIntegrationTestServer : OpenIddictServerI public override ValueTask CreateClientAsync() => new(new OpenIddictServerIntegrationTestClient(Server.CreateClient())); - public override -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST - async -#endif - ValueTask DisposeAsync() + public override async ValueTask DisposeAsync() { // Dispose of the underlying test server. Server.Dispose(); -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST // Stop and dispose of the underlying generic host. await Host.StopAsync(); Host.Dispose(); -#else - return ValueTask.CompletedTask; -#endif } } diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs index 483cef5d..8d484e02 100644 --- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs +++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs @@ -652,17 +652,10 @@ public partial class OpenIddictServerAspNetCoreIntegrationTests : OpenIddictServ Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); } - protected override -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST - async -#endif - ValueTask CreateServerAsync(Action? configuration = null) + protected override async ValueTask CreateServerAsync( + Action? configuration = null) { -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST var builder = new HostBuilder(); -#else - var builder = new WebHostBuilder(); -#endif builder.UseEnvironment("Testing"); builder.ConfigureLogging(options => options.AddXUnit(OutputHelper)); @@ -681,25 +674,15 @@ public partial class OpenIddictServerAspNetCoreIntegrationTests : OpenIddictServ }); }); -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST builder.ConfigureWebHost(options => { options.UseTestServer(); options.Configure(ConfigurePipeline); }); -#else - builder.Configure(ConfigurePipeline); -#endif -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST var host = await builder.StartAsync(); return new OpenIddictServerAspNetCoreIntegrationTestServer(host); -#else - var server = new TestServer(builder); - - return new(new OpenIddictServerAspNetCoreIntegrationTestServer(server)); -#endif void ConfigurePipeline(IApplicationBuilder app) { diff --git a/test/OpenIddict.Server.DataProtection.Tests/OpenIddict.Server.DataProtection.Tests.csproj b/test/OpenIddict.Server.DataProtection.Tests/OpenIddict.Server.DataProtection.Tests.csproj index 10ebefd4..e9278c21 100644 --- a/test/OpenIddict.Server.DataProtection.Tests/OpenIddict.Server.DataProtection.Tests.csproj +++ b/test/OpenIddict.Server.DataProtection.Tests/OpenIddict.Server.DataProtection.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddict.Server.IntegrationTests.csproj b/test/OpenIddict.Server.IntegrationTests/OpenIddict.Server.IntegrationTests.csproj index ad2fa5ed..0cd569c1 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddict.Server.IntegrationTests.csproj +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddict.Server.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs index a99af36e..71e46836 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs @@ -890,11 +890,9 @@ public abstract partial class OpenIddictServerIntegrationTests [InlineData(Algorithms.RsaSha256)] [InlineData(Algorithms.RsaSha384)] [InlineData(Algorithms.RsaSha512)] -#if SUPPORTS_ECDSA [InlineData(Algorithms.EcdsaSha256)] [InlineData(Algorithms.EcdsaSha384)] [InlineData(Algorithms.EcdsaSha512)] -#endif public async Task HandleConfigurationRequest_SigningAlgorithmsAreCorrectlyReturned(string algorithm) { // Arrange @@ -1422,11 +1420,6 @@ public abstract partial class OpenIddictServerIntegrationTests [InlineData(SecurityAlgorithms.HmacSha256Signature)] [InlineData(SecurityAlgorithms.HmacSha384Signature)] [InlineData(SecurityAlgorithms.HmacSha512Signature)] -#if !SUPPORTS_ECDSA - [InlineData(SecurityAlgorithms.EcdsaSha256Signature)] - [InlineData(SecurityAlgorithms.EcdsaSha384Signature)] - [InlineData(SecurityAlgorithms.EcdsaSha512Signature)] -#endif public async Task HandleJsonWebKeySetRequest_UnsupportedSecurityKeysAreIgnored(string algorithm) { // Arrange @@ -1487,7 +1480,6 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Equal(parameters.Modulus, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.N])); } -#if SUPPORTS_ECDSA [Theory] [InlineData( /* oid: */ "1.2.840.10045.3.1.7", // P-256 @@ -1538,7 +1530,6 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Equal(parameters.Q.X, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.X])); Assert.Equal(parameters.Q.Y, Base64UrlEncoder.DecodeBytes((string?) key?[JsonWebKeyParameterNames.Y])); } -#endif [Fact] public async Task HandleJsonWebKeySetRequest_X509CertificatesAreCorrectlyExposed() diff --git a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddict.Server.Owin.IntegrationTests.csproj b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddict.Server.Owin.IntegrationTests.csproj index 0559bf0c..7bf61994 100644 --- a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddict.Server.Owin.IntegrationTests.csproj +++ b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddict.Server.Owin.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net472;net48 + $(NetFrameworkTargetFrameworks) diff --git a/test/OpenIddict.Server.Tests/OpenIddict.Server.Tests.csproj b/test/OpenIddict.Server.Tests/OpenIddict.Server.Tests.csproj index b77f315a..ea1b827d 100644 --- a/test/OpenIddict.Server.Tests/OpenIddict.Server.Tests.csproj +++ b/test/OpenIddict.Server.Tests/OpenIddict.Server.Tests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs b/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs index 36491060..7eef66c6 100644 --- a/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs +++ b/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs @@ -8,11 +8,6 @@ using Moq; using Xunit; using static OpenIddict.Server.OpenIddictServerEvents; -#if !SUPPORTS_CERTIFICATE_GENERATION -using System.Globalization; -using System.Security.Cryptography.X509Certificates; -#endif - namespace OpenIddict.Server.Tests; public class OpenIddictServerBuilderTests @@ -281,7 +276,6 @@ public class OpenIddictServerBuilderTests Assert.Equal("subject", exception.ParamName); } -#if SUPPORTS_CERTIFICATE_GENERATION [Fact] public void AddDevelopmentEncryptionCertificate_CanGenerateCertificate() { @@ -300,27 +294,6 @@ public class OpenIddictServerBuilderTests Assert.Equal(SecurityAlgorithms.Aes256CbcHmacSha512, options.EncryptionCredentials[0].Enc); Assert.NotNull(options.EncryptionCredentials[0].Key.KeyId); } -#else - [Fact] - public void AddDevelopmentEncryptionCertificate_ThrowsAnExceptionOnUnsupportedPlatforms() - { - // Arrange - var services = CreateServices(); - var builder = CreateBuilder(services); - - builder.AddDevelopmentEncryptionCertificate( - subject: new X500DistinguishedName("CN=" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))); - - var provider = services.BuildServiceProvider(); - - var options = provider.GetRequiredService>(); - - // Act and assert - var exception = Assert.Throws(() => options.Value); - - Assert.Equal("X.509 certificate generation is not supported on this platform.", exception.Message); - } -#endif [Fact] public void AddDevelopmentSigningCertificate_ThrowsAnExceptionForNullSubject() @@ -338,7 +311,6 @@ public class OpenIddictServerBuilderTests Assert.Equal("subject", exception.ParamName); } -#if SUPPORTS_CERTIFICATE_GENERATION [Fact] public void AddDevelopmentSigningCertificate_CanGenerateCertificate() { @@ -356,27 +328,6 @@ public class OpenIddictServerBuilderTests Assert.Equal(SecurityAlgorithms.RsaSha256, options.SigningCredentials[0].Algorithm); Assert.NotNull(options.SigningCredentials[0].Kid); } -#else - [Fact] - public void AddDevelopmentSigningCertificate_ThrowsAnExceptionOnUnsupportedPlatforms() - { - // Arrange - var services = CreateServices(); - var builder = CreateBuilder(services); - - builder.AddDevelopmentSigningCertificate( - subject: new X500DistinguishedName("CN=" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))); - - var provider = services.BuildServiceProvider(); - - var options = provider.GetRequiredService>(); - - // Act and assert - var exception = Assert.Throws(() => options.Value); - - Assert.Equal("X.509 certificate generation is not supported on this platform.", exception.Message); - } -#endif [Fact] public void AddEphemeralSigningKey_SigningKeyIsCorrectlyAdded() @@ -398,11 +349,9 @@ public class OpenIddictServerBuilderTests [InlineData(SecurityAlgorithms.RsaSha256)] [InlineData(SecurityAlgorithms.RsaSha384)] [InlineData(SecurityAlgorithms.RsaSha512)] -#if SUPPORTS_ECDSA [InlineData(SecurityAlgorithms.EcdsaSha256)] [InlineData(SecurityAlgorithms.EcdsaSha384)] [InlineData(SecurityAlgorithms.EcdsaSha512)] -#endif public void AddEphemeralSigningKey_SigningCredentialsUseSpecifiedAlgorithm(string algorithm) { // Arrange @@ -447,11 +396,9 @@ public class OpenIddictServerBuilderTests [Theory] [InlineData(SecurityAlgorithms.HmacSha256)] [InlineData(SecurityAlgorithms.RsaSha256)] -#if SUPPORTS_ECDSA [InlineData(SecurityAlgorithms.EcdsaSha256)] [InlineData(SecurityAlgorithms.EcdsaSha384)] [InlineData(SecurityAlgorithms.EcdsaSha512)] -#endif public void AddSigningKey_SigningKeyIsCorrectlyAdded(string algorithm) { // Arrange diff --git a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddict.Validation.AspNetCore.IntegrationTests.csproj b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddict.Validation.AspNetCore.IntegrationTests.csproj index ce3f724a..3eafbcaa 100644 --- a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddict.Validation.AspNetCore.IntegrationTests.csproj +++ b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddict.Validation.AspNetCore.IntegrationTests.csproj @@ -1,7 +1,7 @@ - net472;net48;$(NetCoreTargetFrameworks) + $(NetCoreTargetFrameworks) @@ -13,10 +13,6 @@ - - - - diff --git a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTestServer.cs b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTestServer.cs index c4840ab8..9d4d0f31 100644 --- a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTestServer.cs +++ b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTestServer.cs @@ -5,11 +5,8 @@ */ using Microsoft.AspNetCore.TestHost; -using OpenIddict.Validation.IntegrationTests; - -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST using Microsoft.Extensions.Hosting; -#endif +using OpenIddict.Validation.IntegrationTests; namespace OpenIddict.Validation.AspNetCore.IntegrationTests; @@ -18,7 +15,6 @@ namespace OpenIddict.Validation.AspNetCore.IntegrationTests; /// public class OpenIddictValidationAspNetCoreIntegrationTestServer : OpenIddictValidationIntegrationTestServer { -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST public OpenIddictValidationAspNetCoreIntegrationTestServer(IHost host) { Host = host; @@ -29,10 +25,6 @@ public class OpenIddictValidationAspNetCoreIntegrationTestServer : OpenIddictVal /// Gets the generic host used by this instance. /// public IHost Host { get; } -#else - public OpenIddictValidationAspNetCoreIntegrationTestServer(TestServer server) - => Server = server; -#endif /// /// Gets the ASP.NET Core test server used by this instance. @@ -42,21 +34,13 @@ public class OpenIddictValidationAspNetCoreIntegrationTestServer : OpenIddictVal public override ValueTask CreateClientAsync() => new(new OpenIddictValidationIntegrationTestClient(Server.CreateClient())); - public override -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST - async -#endif - ValueTask DisposeAsync() + public override async ValueTask DisposeAsync() { // Dispose of the underlying test server. Server.Dispose(); -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST // Stop and dispose of the underlying generic host. await Host.StopAsync(); Host.Dispose(); -#else - return ValueTask.CompletedTask; -#endif } } diff --git a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs index 626386cc..27bf54e4 100644 --- a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs +++ b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs @@ -109,17 +109,10 @@ public partial class OpenIddictValidationAspNetCoreIntegrationTests : OpenIddict Assert.Equal(new DateTimeOffset(2120, 01, 01, 00, 00, 00, TimeSpan.Zero), properties.ExpiresUtc); } - protected override -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST - async -#endif - ValueTask CreateServerAsync(Action? configuration = null) + protected override async ValueTask CreateServerAsync( + Action? configuration = null) { -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST var builder = new HostBuilder(); -#else - var builder = new WebHostBuilder(); -#endif builder.UseEnvironment("Testing"); builder.ConfigureLogging(options => options.AddXUnit(OutputHelper)); @@ -136,25 +129,15 @@ public partial class OpenIddictValidationAspNetCoreIntegrationTests : OpenIddict }); }); -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST builder.ConfigureWebHost(options => { options.UseTestServer(); options.Configure(ConfigurePipeline); }); -#else - builder.Configure(ConfigurePipeline); -#endif -#if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST var host = await builder.StartAsync(); return new OpenIddictValidationAspNetCoreIntegrationTestServer(host); -#else - var server = new TestServer(builder); - - return new(new OpenIddictValidationAspNetCoreIntegrationTestServer(server)); -#endif void ConfigurePipeline(IApplicationBuilder app) { diff --git a/test/OpenIddict.Validation.IntegrationTests/OpenIddict.Validation.IntegrationTests.csproj b/test/OpenIddict.Validation.IntegrationTests/OpenIddict.Validation.IntegrationTests.csproj index e8a7c7f1..fbac1241 100644 --- a/test/OpenIddict.Validation.IntegrationTests/OpenIddict.Validation.IntegrationTests.csproj +++ b/test/OpenIddict.Validation.IntegrationTests/OpenIddict.Validation.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net472;net48;$(NetCoreTargetFrameworks) + $(NetFrameworkTargetFrameworks);$(NetCoreTargetFrameworks) diff --git a/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTests.cs b/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTests.cs index 5d4475b9..ea0a03bb 100644 --- a/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTests.cs +++ b/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTests.cs @@ -409,11 +409,7 @@ public abstract partial class OpenIddictValidationIntegrationTests using var buffer = new MemoryStream(); stream.CopyTo(buffer); -#if SUPPORTS_CERTIFICATE_LOADER return X509CertificateLoader.LoadCertificate(buffer.ToArray()); -#else - return new X509Certificate2(buffer.ToArray()); -#endif } } diff --git a/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddict.Validation.Owin.IntegrationTests.csproj b/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddict.Validation.Owin.IntegrationTests.csproj index 107ac2e8..dcc261db 100644 --- a/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddict.Validation.Owin.IntegrationTests.csproj +++ b/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddict.Validation.Owin.IntegrationTests.csproj @@ -1,7 +1,7 @@ - net472;net48 + $(NetFrameworkTargetFrameworks)