From 996ffeec37b263ea830aa516552926a634290592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Wed, 21 May 2025 16:52:28 +0200 Subject: [PATCH] Remove the runtime checks that prevent the generic version of OpenIddict.Client.SystemIntegration from being used on Android/iOS/macOS/Mac Catalyst --- .../OpenIddictResources.resx | 5 +++-- ...ictClientSystemIntegrationConfiguration.cs | 22 ------------------- ...IddictClientSystemIntegrationExtensions.cs | 22 ------------------- ...penIddictClientSystemIntegrationHelpers.cs | 11 +++++++--- 4 files changed, 11 insertions(+), 49 deletions(-) diff --git a/src/OpenIddict.Abstractions/OpenIddictResources.resx b/src/OpenIddict.Abstractions/OpenIddictResources.resx index 2159850b..b9d130e9 100644 --- a/src/OpenIddict.Abstractions/OpenIddictResources.resx +++ b/src/OpenIddict.Abstractions/OpenIddictResources.resx @@ -1560,7 +1560,7 @@ To apply post-logout redirection responses, create a class implementing 'IOpenId An explicit grant type must be attached when specifying a specific response type (except when using the special response_type=none value). - AS web authentication sessions are only supported on iOS 12.0 and higher. + AS web authentication sessions are only supported on iOS 12.0+/macOS 10.15+/Mac Catalyst 12.0+ and require using an OS-specific target framework moniker (e.g on macOS, 'net8.0-macos15.0'). The current UI window cannot be resolved. @@ -1570,6 +1570,7 @@ To apply post-logout redirection responses, create a class implementing 'IOpenId The generic version of the OpenIddict.Client.SystemIntegration package cannot be used on this platform. Make sure your application is referencing the correct version by using the appropriate OS-specific TFM (e.g on macOS, 'net8.0-macos10.15'). + This resource is no longer used and will be removed in a future version. An HTTP redirect_uri or post_logout_redirect_uri cannot be used when using AS web authentication sessions. Make sure you're using a custom protocol scheme for all the callback URIs attached to the client registration. Alternatively, you can register an associated domain and use an HTTPS redirect_uri or post_logout_redirect_uri pointing to that domain (supported only on iOS 17.4+, Mac Catalyst 17.4+ and macOS 14.4+). @@ -1578,7 +1579,7 @@ To apply post-logout redirection responses, create a class implementing 'IOpenId The Zoho integration requires sending the region of the server when using the client credentials or refresh token grants. For that, attach a ".location" authentication property containing the region to use. - Custom tabs intents are only supported on Android. + Custom tabs intents are only supported on Android and require using an OS-specific target framework moniker (e.g 'net8.0-android34.0'). The specified intent doesn't contain a valid data URI. diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs index e8301f3c..c8c7287a 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs @@ -83,28 +83,6 @@ public sealed class OpenIddictClientSystemIntegrationConfiguration : IConfigureO throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0389)); } -#if !SUPPORTS_ANDROID - // When running on Android, iOS, Mac Catalyst or macOS, ensure the version compiled for - // these platforms is used to prevent the generic/non-OS specific TFM from being used. - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("android"))) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0449)); - } -#endif -#if !SUPPORTS_APPKIT - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0449)); - } -#endif -#if !SUPPORTS_UIKIT - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ios")) || - RuntimeInformation.IsOSPlatform(OSPlatform.Create("maccatalyst"))) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0449)); - } -#endif - #if SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON // Ensure the operating system version is supported. if ((OperatingSystem.IsAndroid() && !OperatingSystem.IsAndroidVersionAtLeast(21)) || diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs index a64bdb38..708bd6bf 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs @@ -42,28 +42,6 @@ public static class OpenIddictClientSystemIntegrationExtensions throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0389)); } -#if !SUPPORTS_ANDROID - // When running on Android, iOS, Mac Catalyst or macOS, ensure the version compiled for - // these platforms is used to prevent the generic/non-OS specific TFM from being used. - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("android"))) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0449)); - } -#endif -#if !SUPPORTS_APPKIT - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0449)); - } -#endif -#if !SUPPORTS_UIKIT - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ios")) || - RuntimeInformation.IsOSPlatform(OSPlatform.Create("maccatalyst"))) - { - throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0449)); - } -#endif - #if SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON // Ensure the operating system version is supported. if ((OperatingSystem.IsAndroid() && !OperatingSystem.IsAndroidVersionAtLeast(21)) || diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs index 5821986b..a0e9f69a 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs @@ -110,7 +110,7 @@ public static class OpenIddictClientSystemIntegrationHelpers [SupportedOSPlatformGuard("maccatalyst13.1")] [SupportedOSPlatformGuard("macos10.15")] internal static bool IsASWebAuthenticationSessionSupported() -#if SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON +#if SUPPORTS_AUTHENTICATION_SERVICES && SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON => OperatingSystem.IsIOSVersionAtLeast(12) || OperatingSystem.IsMacCatalystVersionAtLeast(13) || OperatingSystem.IsMacOSVersionAtLeast(10, 15); @@ -125,7 +125,7 @@ public static class OpenIddictClientSystemIntegrationHelpers [MethodImpl(MethodImplOptions.AggressiveInlining)] [SupportedOSPlatformGuard("android21.0")] internal static bool IsCustomTabsIntentSupported() -#if SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON +#if SUPPORTS_ANDROIDX_BROWSER && SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON => OperatingSystem.IsAndroidVersionAtLeast(21); #else => false; @@ -143,7 +143,12 @@ public static class OpenIddictClientSystemIntegrationHelpers // guard that will prevent the WinRT projections from being loaded by the runtime on // platforms that don't support it. Since OpenIddict declares Windows 10 1809 as the // oldest supported version in the package, it is also used for the runtime check. - internal static bool IsWindowsRuntimeSupported() => IsWindowsVersionAtLeast(10, 0, 17763); + internal static bool IsWindowsRuntimeSupported() +#if SUPPORTS_WINDOWS_RUNTIME + => IsWindowsVersionAtLeast(10, 0, 17763); +#else + => false; +#endif /// /// Determines whether WinRT app instance activation is supported on this platform.