diff --git a/src/OpenIddict.Abstractions/OpenIddictResources.resx b/src/OpenIddict.Abstractions/OpenIddictResources.resx index 76f1516f..8fa5fc50 100644 --- a/src/OpenIddict.Abstractions/OpenIddictResources.resx +++ b/src/OpenIddict.Abstractions/OpenIddictResources.resx @@ -1115,7 +1115,7 @@ Note: when using a dependency injection container supporting middleware resoluti The OpenIddict client services cannot be resolved from the DI container. -To register the server services, use 'services.AddOpenIddict().AddClient()'. +To register the client services, use 'services.AddOpenIddict().AddClient()'. The core services must be registered when enabling the OpenIddict client feature. diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs index 670b18c8..f75d35bb 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs @@ -130,6 +130,12 @@ public sealed class OpenIddictClientOwinBuilder /// /// Sets the cookie manager used to read and write the cookies produced by the OWIN host. /// + /// + /// If the manager isn't explicitly set, OpenIddict will try to resolve the default instance + /// provided by the OWIN host (only if was registered as a service + /// in the dependency injection container). If no instance can be resolved, the generic + /// implementation will be used. + /// /// The cookie manager to use. /// The instance. public OpenIddictClientOwinBuilder SetCookieManager(ICookieManager manager) diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs index f052c8b8..701f721b 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Owin; namespace OpenIddict.Client.Owin; @@ -46,6 +47,19 @@ public sealed class OpenIddictClientOwinConfiguration : IConfigureOptions() switch + { + // See https://github.com/aspnet/AspNetKatana/pull/486 for more information. + IAppBuilder builder when builder.Properties.TryGetValue("infrastructure.CookieManager", + out object? property) && property is ICookieManager manager => manager, + + _ => new CookieManager() + }; + if (options.AuthenticationMode is AuthenticationMode.Active) { throw new InvalidOperationException(SR.GetResourceString(SR.ID0314)); diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinOptions.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinOptions.cs index 9b7adaea..8442594b 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinOptions.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinOptions.cs @@ -72,7 +72,13 @@ public sealed class OpenIddictClientOwinOptions : AuthenticationOptions /// /// Gets or sets the cookie manager used to read and write the cookies produced by the OWIN host. /// - public ICookieManager CookieManager { get; set; } = new CookieManager(); + /// + /// If the manager isn't explicitly set, OpenIddict will try to resolve the default instance + /// provided by the OWIN host (only if was registered as a service + /// in the dependency injection container). If no instance can be resolved, the generic + /// implementation will be used. + /// + public ICookieManager CookieManager { get; set; } = default!; /// /// Gets or sets the name of the correlation cookie used to bind authorization