Browse Source

Backport the core services resolution changes to OpenIddict 1.x

pull/670/head
Kévin Chalet 8 years ago
parent
commit
5c13960b04
  1. 2
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictApplicationStoreResolver.cs
  2. 2
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictAuthorizationStoreResolver.cs
  3. 2
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictScopeStoreResolver.cs
  4. 2
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictTokenStoreResolver.cs
  5. 2
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictApplicationStoreResolver.cs
  6. 2
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictAuthorizationStoreResolver.cs
  7. 2
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictScopeStoreResolver.cs
  8. 2
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictTokenStoreResolver.cs
  9. 8
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Authentication.cs
  10. 10
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs
  11. 64
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs
  12. 8
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs
  13. 8
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs
  14. 6
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Session.cs

2
src/OpenIddict.EntityFramework/Resolvers/OpenIddictApplicationStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFramework
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.") .AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFramework().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFramework/Resolvers/OpenIddictAuthorizationStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFramework
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.") .AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFramework().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFramework/Resolvers/OpenIddictScopeStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFramework
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.") .AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFramework().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFramework/Resolvers/OpenIddictTokenStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFramework
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.") .AppendLine("No Entity Framework 6.x context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework 6.x stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFramework().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictApplicationStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFrameworkCore
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework Core context was specified in the OpenIddict options.") .AppendLine("No Entity Framework Core context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkCoreStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFrameworkCore().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictAuthorizationStoreResolver.cs

@ -67,7 +67,7 @@ namespace OpenIddict.EntityFrameworkCore
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework Core context was specified in the OpenIddict options.") .AppendLine("No Entity Framework Core context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkCoreStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFrameworkCore().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictScopeStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFrameworkCore
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework Core context was specified in the OpenIddict options.") .AppendLine("No Entity Framework Core context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkCoreStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFrameworkCore().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

2
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictTokenStoreResolver.cs

@ -66,7 +66,7 @@ namespace OpenIddict.EntityFrameworkCore
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("No Entity Framework Core context was specified in the OpenIddict options.") .AppendLine("No Entity Framework Core context was specified in the OpenIddict options.")
.Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ") .Append("To configure the OpenIddict Entity Framework Core stores to use a specific 'DbContext', ")
.Append("use 'options.AddEntityFrameworkCoreStores().UseContext<TContext>()'.") .Append("use 'options.UseEntityFrameworkCore().UseDbContext<TContext>()'.")
.ToString()); .ToString());
} }

8
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Authentication.cs

@ -32,7 +32,7 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
// Reject requests using the unsupported request parameter. // Reject requests using the unsupported request parameter.
if (!string.IsNullOrEmpty(context.Request.Request)) if (!string.IsNullOrEmpty(context.Request.Request))
@ -117,9 +117,9 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var applicationManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.HttpContext.RequestServices);
var scopeManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictScopeManager>(); var scopeManager = GetScopeManager(context.HttpContext.RequestServices);
// Note: the OpenID Connect server middleware supports authorization code, implicit, hybrid, // Note: the OpenID Connect server middleware supports authorization code, implicit, hybrid,
// none and custom flows but OpenIddict uses a stricter policy rejecting none and custum flows. // none and custom flows but OpenIddict uses a stricter policy rejecting none and custum flows.

10
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs

@ -25,9 +25,9 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var applicationManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.HttpContext.RequestServices);
var scopeManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictScopeManager>(); var scopeManager = GetScopeManager(context.HttpContext.RequestServices);
// Reject token requests that don't specify a supported grant type. // Reject token requests that don't specify a supported grant type.
if (!options.GrantTypes.Contains(context.Request.GrantType)) if (!options.GrantTypes.Contains(context.Request.GrantType))
@ -294,8 +294,8 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var tokenManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.HttpContext.RequestServices);
if (context.Ticket != null) if (context.Ticket != null)
{ {

64
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Extensions; using AspNet.Security.OpenIdConnect.Extensions;
using AspNet.Security.OpenIdConnect.Primitives; using AspNet.Security.OpenIdConnect.Primitives;
@ -30,9 +31,9 @@ namespace OpenIddict.Server
[NotNull] AuthenticationTicket ticket, [NotNull] OpenIddictServerOptions options, [NotNull] AuthenticationTicket ticket, [NotNull] OpenIddictServerOptions options,
[NotNull] HttpContext context, [NotNull] OpenIdConnectRequest request) [NotNull] HttpContext context, [NotNull] OpenIdConnectRequest request)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var applicationManager = context.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.RequestServices);
var authorizationManager = context.RequestServices.GetRequiredService<IOpenIddictAuthorizationManager>(); var authorizationManager = GetAuthorizationManager(context.RequestServices);
var descriptor = new OpenIddictAuthorizationDescriptor var descriptor = new OpenIddictAuthorizationDescriptor
{ {
@ -99,9 +100,9 @@ namespace OpenIddict.Server
type == OpenIdConnectConstants.TokenUsages.RefreshToken, type == OpenIdConnectConstants.TokenUsages.RefreshToken,
"Only authorization codes, access and refresh tokens should be created using this method."); "Only authorization codes, access and refresh tokens should be created using this method.");
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var applicationManager = context.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.RequestServices);
var tokenManager = context.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.RequestServices);
// When sliding expiration is disabled, the expiration date of generated refresh tokens is fixed // When sliding expiration is disabled, the expiration date of generated refresh tokens is fixed
// and must exactly match the expiration date of the refresh token used in the token request. // and must exactly match the expiration date of the refresh token used in the token request.
@ -228,8 +229,8 @@ namespace OpenIddict.Server
[NotNull] OpenIdConnectRequest request, [NotNull] OpenIdConnectRequest request,
[NotNull] ISecureDataFormat<AuthenticationTicket> format) [NotNull] ISecureDataFormat<AuthenticationTicket> format)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var tokenManager = context.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.RequestServices);
Debug.Assert(type == OpenIdConnectConstants.TokenUsages.AccessToken || Debug.Assert(type == OpenIdConnectConstants.TokenUsages.AccessToken ||
type == OpenIdConnectConstants.TokenUsages.AuthorizationCode || type == OpenIdConnectConstants.TokenUsages.AuthorizationCode ||
@ -377,8 +378,8 @@ namespace OpenIddict.Server
private async Task<bool> TryRevokeAuthorizationAsync([NotNull] AuthenticationTicket ticket, [NotNull] HttpContext context) private async Task<bool> TryRevokeAuthorizationAsync([NotNull] AuthenticationTicket ticket, [NotNull] HttpContext context)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var authorizationManager = context.RequestServices.GetRequiredService<IOpenIddictAuthorizationManager>(); var authorizationManager = GetAuthorizationManager(context.RequestServices);
// Note: if the authorization identifier or the authorization itself // Note: if the authorization identifier or the authorization itself
// cannot be found, return true as the authorization doesn't need // cannot be found, return true as the authorization doesn't need
@ -425,8 +426,8 @@ namespace OpenIddict.Server
private async Task<bool> TryRevokeTokenAsync([NotNull] object token, [NotNull] HttpContext context) private async Task<bool> TryRevokeTokenAsync([NotNull] object token, [NotNull] HttpContext context)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var tokenManager = context.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.RequestServices);
var identifier = await tokenManager.GetIdAsync(token); var identifier = await tokenManager.GetIdAsync(token);
Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty."); Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty.");
@ -459,7 +460,7 @@ namespace OpenIddict.Server
private async Task<bool> TryRevokeTokensAsync([NotNull] AuthenticationTicket ticket, [NotNull] HttpContext context) private async Task<bool> TryRevokeTokensAsync([NotNull] AuthenticationTicket ticket, [NotNull] HttpContext context)
{ {
var tokenManager = context.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.RequestServices);
// Note: if the authorization identifier is null, return true as no tokens need to be revoked. // Note: if the authorization identifier is null, return true as no tokens need to be revoked.
var identifier = ticket.GetProperty(OpenIddictConstants.Properties.AuthorizationId); var identifier = ticket.GetProperty(OpenIddictConstants.Properties.AuthorizationId);
@ -486,8 +487,8 @@ namespace OpenIddict.Server
private async Task<bool> TryRedeemTokenAsync([NotNull] object token, [NotNull] HttpContext context) private async Task<bool> TryRedeemTokenAsync([NotNull] object token, [NotNull] HttpContext context)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var tokenManager = context.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.RequestServices);
var identifier = await tokenManager.GetIdAsync(token); var identifier = await tokenManager.GetIdAsync(token);
Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty."); Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty.");
@ -522,8 +523,8 @@ namespace OpenIddict.Server
[NotNull] object token, [NotNull] AuthenticationTicket ticket, [NotNull] object token, [NotNull] AuthenticationTicket ticket,
[NotNull] HttpContext context, [NotNull] OpenIddictServerOptions options) [NotNull] HttpContext context, [NotNull] OpenIddictServerOptions options)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
var tokenManager = context.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.RequestServices);
var identifier = ticket.GetTokenId(); var identifier = ticket.GetTokenId();
Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty."); Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty.");
@ -565,7 +566,7 @@ namespace OpenIddict.Server
[NotNull] HttpContext context, [NotNull] OpenIdConnectRequest request, [NotNull] HttpContext context, [NotNull] OpenIdConnectRequest request,
[NotNull] AuthenticationProperties properties) [NotNull] AuthenticationProperties properties)
{ {
var logger = context.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.RequestServices);
Debug.Assert(properties != null, "The authentication properties shouldn't be null."); Debug.Assert(properties != null, "The authentication properties shouldn't be null.");
@ -677,5 +678,32 @@ namespace OpenIddict.Server
continue; continue;
} }
} }
private static ILogger GetLogger(IServiceProvider provider) => provider.GetRequiredService<ILogger<OpenIddictServerProvider>>();
private static IOpenIddictApplicationManager GetApplicationManager(IServiceProvider provider)
=> provider.GetService<IOpenIddictApplicationManager>() ?? throw new InvalidOperationException(new StringBuilder()
.AppendLine("The core services must be registered when enabling the server handler.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.ToString());
private static IOpenIddictAuthorizationManager GetAuthorizationManager(IServiceProvider provider)
=> provider.GetService<IOpenIddictAuthorizationManager>() ?? throw new InvalidOperationException(new StringBuilder()
.AppendLine("The core services must be registered when enabling the server handler.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.ToString());
private static IOpenIddictScopeManager GetScopeManager(IServiceProvider provider)
=> provider.GetService<IOpenIddictScopeManager>() ?? throw new InvalidOperationException(new StringBuilder()
.AppendLine("The core services must be registered when enabling the server handler.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.ToString());
private static IOpenIddictTokenManager GetTokenManager(IServiceProvider provider)
=> provider.GetService<IOpenIddictTokenManager>() ?? throw new InvalidOperationException(new StringBuilder()
.AppendLine("The core services must be registered when enabling the server handler.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.ToString());
} }
} }

8
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs

@ -20,8 +20,8 @@ namespace OpenIddict.Server
{ {
public override async Task ValidateIntrospectionRequest([NotNull] ValidateIntrospectionRequestContext context) public override async Task ValidateIntrospectionRequest([NotNull] ValidateIntrospectionRequestContext context)
{ {
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var applicationManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.HttpContext.RequestServices);
// Note: the OpenID Connect server middleware supports unauthenticated introspection requests // Note: the OpenID Connect server middleware supports unauthenticated introspection requests
// but OpenIddict uses a stricter policy preventing unauthenticated/public applications // but OpenIddict uses a stricter policy preventing unauthenticated/public applications
@ -102,8 +102,8 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var tokenManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.HttpContext.RequestServices);
Debug.Assert(context.Ticket != null, "The authentication ticket shouldn't be null."); Debug.Assert(context.Ticket != null, "The authentication ticket shouldn't be null.");
Debug.Assert(!string.IsNullOrEmpty(context.Request.ClientId), "The client_id parameter shouldn't be null."); Debug.Assert(!string.IsNullOrEmpty(context.Request.ClientId), "The client_id parameter shouldn't be null.");

8
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs

@ -23,8 +23,8 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var applicationManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.HttpContext.RequestServices);
Debug.Assert(!options.DisableTokenRevocation, "Token revocation support shouldn't be disabled at this stage."); Debug.Assert(!options.DisableTokenRevocation, "Token revocation support shouldn't be disabled at this stage.");
@ -170,8 +170,8 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var tokenManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictTokenManager>(); var tokenManager = GetTokenManager(context.HttpContext.RequestServices);
Debug.Assert(context.Ticket != null, "The authentication ticket shouldn't be null."); Debug.Assert(context.Ticket != null, "The authentication ticket shouldn't be null.");

6
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Session.cs

@ -29,7 +29,7 @@ namespace OpenIddict.Server
{ {
var options = (OpenIddictServerOptions) context.Options; var options = (OpenIddictServerOptions) context.Options;
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
// If a request_id parameter can be found in the logout request, // If a request_id parameter can be found in the logout request,
// restore the complete logout request from the distributed cache. // restore the complete logout request from the distributed cache.
@ -86,8 +86,8 @@ namespace OpenIddict.Server
public override async Task ValidateLogoutRequest([NotNull] ValidateLogoutRequestContext context) public override async Task ValidateLogoutRequest([NotNull] ValidateLogoutRequestContext context)
{ {
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<OpenIddictServerProvider>>(); var logger = GetLogger(context.HttpContext.RequestServices);
var applicationManager = context.HttpContext.RequestServices.GetRequiredService<IOpenIddictApplicationManager>(); var applicationManager = GetApplicationManager(context.HttpContext.RequestServices);
// If an optional post_logout_redirect_uri was provided, validate it. // If an optional post_logout_redirect_uri was provided, validate it.
if (!string.IsNullOrEmpty(context.PostLogoutRedirectUri)) if (!string.IsNullOrEmpty(context.PostLogoutRedirectUri))

Loading…
Cancel
Save