Browse Source

Backport the namespace changes to OpenIddict 1.x

pull/670/head
Kévin Chalet 8 years ago
parent
commit
2d47be7660
  1. 2
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  2. 8
      src/OpenIddict.Server/IOpenIddictServerEvent.cs
  3. 8
      src/OpenIddict.Server/IOpenIddictServerEventHandler.cs
  4. 22
      src/OpenIddict.Server/IOpenIddictServerEventService.cs
  5. 16
      src/OpenIddict.Server/Internal/OpenIddictServerEventService.cs
  6. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Authentication.cs
  7. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Discovery.cs
  8. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Exchange.cs
  9. 13
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Helpers.cs
  10. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Introspection.cs
  11. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Revocation.cs
  12. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Serialization.cs
  13. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Session.cs
  14. 9
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.Userinfo.cs
  15. 10
      src/OpenIddict.Server/Internal/OpenIddictServerProvider.cs
  16. 8
      src/OpenIddict.Server/OpenIddictServerDefaults.cs
  17. 8
      src/OpenIddict.Server/OpenIddictServerEvent.cs
  18. 8
      src/OpenIddict.Server/OpenIddictServerEventHandler.cs
  19. 8
      src/OpenIddict.Server/OpenIddictServerEvents.cs
  20. 3
      src/OpenIddict.Server/OpenIddictServerExtensions.cs
  21. 1
      src/OpenIddict.Server/OpenIddictServerOptions.cs
  22. 8
      src/OpenIddict.Validation/IOpenIddictValidationEvent.cs
  23. 8
      src/OpenIddict.Validation/IOpenIddictValidationEventHandler.cs
  24. 22
      src/OpenIddict.Validation/IOpenIddictValidationEventService.cs
  25. 16
      src/OpenIddict.Validation/Internal/OpenIddictValidationEventService.cs
  26. 4
      src/OpenIddict.Validation/Internal/OpenIddictValidationHelpers.cs
  27. 26
      src/OpenIddict.Validation/Internal/OpenIddictValidationProvider.cs
  28. 8
      src/OpenIddict.Validation/OpenIddictValidationDefaults.cs
  29. 8
      src/OpenIddict.Validation/OpenIddictValidationEvent.cs
  30. 8
      src/OpenIddict.Validation/OpenIddictValidationEventHandler.cs
  31. 8
      src/OpenIddict.Validation/OpenIddictValidationEvents.cs
  32. 3
      src/OpenIddict.Validation/OpenIddictValidationExtensions.cs
  33. 1
      src/OpenIddict.Validation/OpenIddictValidationOptions.cs
  34. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Authentication.cs
  35. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Discovery.cs
  36. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs
  37. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs
  38. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs
  39. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs
  40. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Session.cs
  41. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Userinfo.cs
  42. 2
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs
  43. 4
      test/OpenIddict.Server.Tests/OpenIddictServerExtensionsTests.cs
  44. 8
      test/OpenIddict.Validation.Tests/Internal/OpenIddictValidationProviderTests.cs
  45. 3
      test/OpenIddict.Validation.Tests/OpenIddictValidationExtensionsTests.cs

2
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -1137,7 +1137,7 @@ namespace OpenIddict.Core
=> UpdateAsync((TAuthorization) authorization, cancellationToken);
Task IOpenIddictAuthorizationManager.UpdateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken)
=> UpdateAsync((TAuthorization) authorization, cancellationToken);
=> UpdateAsync((TAuthorization) authorization, descriptor, cancellationToken);
Task<ImmutableArray<ValidationResult>> IOpenIddictAuthorizationManager.ValidateAsync(object authorization, CancellationToken cancellationToken)
=> ValidateAsync((TAuthorization) authorization, cancellationToken);

8
src/OpenIddict.Server/IOpenIddictServerEvent.cs

@ -1,4 +1,10 @@
namespace OpenIddict.Server
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
namespace OpenIddict.Server
{
/// <summary>
/// Represents an OpenIddict server event.

8
src/OpenIddict.Server/IOpenIddictServerEventHandler.cs

@ -1,4 +1,10 @@
using System.Threading;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

22
src/OpenIddict.Server/IOpenIddictServerEventService.cs

@ -1,22 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Server
{
/// <summary>
/// Dispatches events by invoking the corresponding handlers.
/// </summary>
public interface IOpenIddictServerEventService
{
/// <summary>
/// Publishes a new event.
/// </summary>
/// <typeparam name="TEvent">The type of the event to publish.</typeparam>
/// <param name="notification">The event to publish.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
Task PublishAsync<TEvent>([NotNull] TEvent notification, CancellationToken cancellationToken = default)
where TEvent : class, IOpenIddictServerEvent;
}
}

16
src/OpenIddict.Server/OpenIddictServerEventService.cs → src/OpenIddict.Server/Internal/OpenIddictServerEventService.cs

@ -1,4 +1,10 @@
using System;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using System.Threading;
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Primitives;
@ -7,12 +13,14 @@ using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using static OpenIddict.Server.OpenIddictServerEvents;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
/// <summary>
/// Dispatches notifications by invoking the corresponding handlers.
/// Dispatches events by invoking the corresponding notification handlers.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public class OpenIddictServerEventService : IOpenIddictServerEventService
public class OpenIddictServerEventService
{
private readonly IServiceProvider _provider;

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

@ -24,9 +24,14 @@ using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Linq;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override async Task ExtractAuthorizationRequest([NotNull] ExtractAuthorizationRequestContext context)
{

9
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Discovery.cs

@ -9,9 +9,14 @@ using AspNet.Security.OpenIdConnect.Primitives;
using AspNet.Security.OpenIdConnect.Server;
using JetBrains.Annotations;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override Task ExtractConfigurationRequest([NotNull] ExtractConfigurationRequestContext context)
=> GetEventService(context.HttpContext.RequestServices)

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

@ -17,9 +17,14 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override Task ExtractTokenRequest([NotNull] ExtractTokenRequestContext context)
=> GetEventService(context.HttpContext.RequestServices)

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

@ -23,9 +23,14 @@ using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json.Linq;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
private async Task CreateAuthorizationAsync(
[NotNull] AuthenticationTicket ticket, [NotNull] OpenIddictServerOptions options,
@ -679,8 +684,8 @@ namespace OpenIddict.Server
private static ILogger GetLogger(IServiceProvider provider)
=> provider.GetRequiredService<ILogger<OpenIddictServerProvider>>();
private static IOpenIddictServerEventService GetEventService(IServiceProvider provider)
=> provider.GetRequiredService<IOpenIddictServerEventService>();
private static OpenIddictServerEventService GetEventService(IServiceProvider provider)
=> provider.GetRequiredService<OpenIddictServerEventService>();
private static IOpenIddictApplicationManager GetApplicationManager(IServiceProvider provider)
=> provider.GetService<IOpenIddictApplicationManager>() ?? throw new InvalidOperationException(new StringBuilder()

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

@ -14,9 +14,14 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override Task ExtractIntrospectionRequest([NotNull] ExtractIntrospectionRequestContext context)
=> GetEventService(context.HttpContext.RequestServices)

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

@ -15,9 +15,14 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override Task ExtractRevocationRequest([NotNull] ExtractRevocationRequestContext context)
=> GetEventService(context.HttpContext.RequestServices)

9
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Serialization.cs

@ -10,9 +10,14 @@ using AspNet.Security.OpenIdConnect.Primitives;
using AspNet.Security.OpenIdConnect.Server;
using JetBrains.Annotations;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override async Task DeserializeAccessToken([NotNull] DeserializeAccessTokenContext context)
{

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

@ -21,9 +21,14 @@ using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Linq;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override async Task ExtractLogoutRequest([NotNull] ExtractLogoutRequestContext context)
{

9
src/OpenIddict.Server/Internal/OpenIddictServerProvider.Userinfo.cs

@ -8,9 +8,14 @@ using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Server;
using JetBrains.Annotations;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override Task ExtractUserinfoRequest([NotNull] ExtractUserinfoRequestContext context)
{

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

@ -17,10 +17,14 @@ using JetBrains.Annotations;
using Microsoft.AspNetCore.Authentication;
using OpenIddict.Abstractions;
namespace OpenIddict.Server
namespace OpenIddict.Server.Internal
{
[EditorBrowsable(EditorBrowsableState.Never)]
public partial class OpenIddictServerProvider : OpenIdConnectServerProvider
/// <summary>
/// Provides the logic necessary to extract, validate and handle OpenID Connect requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public sealed partial class OpenIddictServerProvider : OpenIdConnectServerProvider
{
public override Task MatchEndpoint([NotNull] MatchEndpointContext context)
=> GetEventService(context.HttpContext.RequestServices)

8
src/OpenIddict.Server/OpenIddictServerDefaults.cs

@ -1,4 +1,10 @@
using AspNet.Security.OpenIdConnect.Server;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using AspNet.Security.OpenIdConnect.Server;
using Microsoft.AspNetCore.Builder;
namespace OpenIddict.Server

8
src/OpenIddict.Server/OpenIddictServerEvent.cs

@ -1,4 +1,10 @@
using System;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using JetBrains.Annotations;
namespace OpenIddict.Server

8
src/OpenIddict.Server/OpenIddictServerEventHandler.cs

@ -1,4 +1,10 @@
using System;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

8
src/OpenIddict.Server/OpenIddictServerEvents.cs

@ -1,4 +1,10 @@
using AspNet.Security.OpenIdConnect.Server;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using AspNet.Security.OpenIdConnect.Server;
using JetBrains.Annotations;
namespace OpenIddict.Server

3
src/OpenIddict.Server/OpenIddictServerExtensions.cs

@ -18,6 +18,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Server;
using OpenIddict.Server.Internal;
namespace Microsoft.Extensions.DependencyInjection
{
@ -42,7 +43,7 @@ namespace Microsoft.Extensions.DependencyInjection
builder.Services.AddMemoryCache();
builder.Services.AddOptions();
builder.Services.TryAddScoped<IOpenIddictServerEventService, OpenIddictServerEventService>();
builder.Services.TryAddScoped<OpenIddictServerEventService>();
return new OpenIddictServerBuilder(builder.Services);
}

1
src/OpenIddict.Server/OpenIddictServerOptions.cs

@ -10,6 +10,7 @@ using System.Security.Cryptography;
using AspNet.Security.OpenIdConnect.Primitives;
using AspNet.Security.OpenIdConnect.Server;
using Microsoft.Extensions.Caching.Distributed;
using OpenIddict.Server.Internal;
namespace OpenIddict.Server
{

8
src/OpenIddict.Validation/IOpenIddictValidationEvent.cs

@ -1,4 +1,10 @@
namespace OpenIddict.Validation
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
namespace OpenIddict.Validation
{
/// <summary>
/// Represents an OpenIddict validation event.

8
src/OpenIddict.Validation/IOpenIddictValidationEventHandler.cs

@ -1,4 +1,10 @@
using System.Threading;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

22
src/OpenIddict.Validation/IOpenIddictValidationEventService.cs

@ -1,22 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Validation
{
/// <summary>
/// Dispatches events by invoking the corresponding handlers.
/// </summary>
public interface IOpenIddictValidationEventService
{
/// <summary>
/// Publishes a new event.
/// </summary>
/// <typeparam name="TEvent">The type of the event to publish.</typeparam>
/// <param name="notification">The event to publish.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
Task PublishAsync<TEvent>([NotNull] TEvent notification, CancellationToken cancellationToken = default)
where TEvent : class, IOpenIddictValidationEvent;
}
}

16
src/OpenIddict.Validation/OpenIddictValidationEventService.cs → src/OpenIddict.Validation/Internal/OpenIddictValidationEventService.cs

@ -1,16 +1,24 @@
using System;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
namespace OpenIddict.Validation
namespace OpenIddict.Validation.Internal
{
/// <summary>
/// Dispatches notifications by invoking the corresponding handlers.
/// Dispatches events by invoking the corresponding notification handlers.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
public class OpenIddictValidationEventService : IOpenIddictValidationEventService
public class OpenIddictValidationEventService
{
private readonly IServiceProvider _provider;

4
src/OpenIddict.Validation/Internal/OpenIddictValidationHelpers.cs

@ -8,10 +8,12 @@ using System;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Http.Authentication;
namespace OpenIddict.Validation
namespace OpenIddict.Validation.Internal
{
/// <summary>
/// Defines a set of commonly used helpers.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
internal static class OpenIddictValidationHelpers
{

26
src/OpenIddict.Validation/Internal/OpenIddictValidationProvider.cs

@ -5,7 +5,6 @@
*/
using System;
using System.ComponentModel;
using System.Text;
using System.Threading.Tasks;
using AspNet.Security.OAuth.Validation;
@ -14,20 +13,21 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenIddict.Abstractions;
namespace OpenIddict.Validation
namespace OpenIddict.Validation.Internal
{
/// <summary>
/// Provides the logic necessary to extract, validate and handle OAuth2 requests.
/// Provides the logic necessary to extract and validate tokens from HTTP requests.
/// Note: this API supports the OpenIddict infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future minor releases.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public class OpenIddictValidationProvider : OAuthValidationEvents
public sealed class OpenIddictValidationProvider : OAuthValidationEvents
{
public override Task ApplyChallenge([NotNull] ApplyChallengeContext context)
=> context.HttpContext.RequestServices.GetRequiredService<IOpenIddictValidationEventService>()
=> context.HttpContext.RequestServices.GetRequiredService<OpenIddictValidationEventService>()
.PublishAsync(new OpenIddictValidationEvents.ApplyChallenge(context));
public override Task CreateTicket([NotNull] CreateTicketContext context)
=> context.HttpContext.RequestServices.GetRequiredService<IOpenIddictValidationEventService>()
=> context.HttpContext.RequestServices.GetRequiredService<OpenIddictValidationEventService>()
.PublishAsync(new OpenIddictValidationEvents.CreateTicket(context));
public override async Task DecryptToken([NotNull] DecryptTokenContext context)
@ -42,7 +42,8 @@ namespace OpenIddict.Validation
{
throw new InvalidOperationException(new StringBuilder()
.AppendLine("The core services must be registered when enabling reference tokens support.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.Append("To register the OpenIddict core services, reference the 'OpenIddict.Core' package ")
.Append("and call 'services.AddOpenIddict().AddCore()' from 'ConfigureServices'.")
.ToString());
}
@ -102,12 +103,12 @@ namespace OpenIddict.Validation
context.HandleResponse();
}
await context.HttpContext.RequestServices.GetRequiredService<IOpenIddictValidationEventService>()
await context.HttpContext.RequestServices.GetRequiredService<OpenIddictValidationEventService>()
.PublishAsync(new OpenIddictValidationEvents.DecryptToken(context));
}
public override Task RetrieveToken([NotNull] RetrieveTokenContext context)
=> context.HttpContext.RequestServices.GetRequiredService<IOpenIddictValidationEventService>()
=> context.HttpContext.RequestServices.GetRequiredService<OpenIddictValidationEventService>()
.PublishAsync(new OpenIddictValidationEvents.RetrieveToken(context));
public override async Task ValidateToken([NotNull] ValidateTokenContext context)
@ -122,7 +123,8 @@ namespace OpenIddict.Validation
{
throw new InvalidOperationException(new StringBuilder()
.AppendLine("The core services must be registered when enabling authorization validation.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.Append("To register the OpenIddict core services, reference the 'OpenIddict.Core' package ")
.Append("and call 'services.AddOpenIddict().AddCore()' from 'ConfigureServices'.")
.ToString());
}
@ -143,7 +145,7 @@ namespace OpenIddict.Validation
}
}
await context.HttpContext.RequestServices.GetRequiredService<IOpenIddictValidationEventService>()
await context.HttpContext.RequestServices.GetRequiredService<OpenIddictValidationEventService>()
.PublishAsync(new OpenIddictValidationEvents.ValidateToken(context));
}
}

8
src/OpenIddict.Validation/OpenIddictValidationDefaults.cs

@ -1,4 +1,10 @@
using AspNet.Security.OAuth.Validation;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using AspNet.Security.OAuth.Validation;
using Microsoft.AspNetCore.Builder;
namespace OpenIddict.Validation

8
src/OpenIddict.Validation/OpenIddictValidationEvent.cs

@ -1,4 +1,10 @@
using System;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using JetBrains.Annotations;
namespace OpenIddict.Validation

8
src/OpenIddict.Validation/OpenIddictValidationEventHandler.cs

@ -1,4 +1,10 @@
using System;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

8
src/OpenIddict.Validation/OpenIddictValidationEvents.cs

@ -1,4 +1,10 @@
using AspNet.Security.OAuth.Validation;
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using AspNet.Security.OAuth.Validation;
using JetBrains.Annotations;
namespace OpenIddict.Validation

3
src/OpenIddict.Validation/OpenIddictValidationExtensions.cs

@ -13,6 +13,7 @@ using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using OpenIddict.Validation;
using OpenIddict.Validation.Internal;
namespace Microsoft.Extensions.DependencyInjection
{
@ -38,7 +39,7 @@ namespace Microsoft.Extensions.DependencyInjection
builder.Services.AddLogging();
builder.Services.AddOptions();
builder.Services.TryAddScoped<IOpenIddictValidationEventService, OpenIddictValidationEventService>();
builder.Services.TryAddScoped<OpenIddictValidationEventService>();
return new OpenIddictValidationBuilder(builder.Services);
}

1
src/OpenIddict.Validation/OpenIddictValidationOptions.cs

@ -5,6 +5,7 @@
*/
using AspNet.Security.OAuth.Validation;
using OpenIddict.Validation.Internal;
namespace OpenIddict.Validation
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Authentication.cs

@ -20,7 +20,7 @@ using Newtonsoft.Json.Bson;
using OpenIddict.Abstractions;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Discovery.cs

@ -11,7 +11,7 @@ using AspNet.Security.OpenIdConnect.Primitives;
using Newtonsoft.Json.Linq;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs

@ -20,7 +20,7 @@ using Moq;
using OpenIddict.Abstractions;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs

@ -17,7 +17,7 @@ using Moq;
using OpenIddict.Abstractions;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs

@ -21,7 +21,7 @@ using Moq;
using OpenIddict.Abstractions;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs

@ -20,7 +20,7 @@ using Moq;
using OpenIddict.Abstractions;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Session.cs

@ -17,7 +17,7 @@ using Moq;
using OpenIddict.Abstractions;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Userinfo.cs

@ -9,7 +9,7 @@ using AspNet.Security.OpenIdConnect.Client;
using AspNet.Security.OpenIdConnect.Primitives;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

2
test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs

@ -34,7 +34,7 @@ using OpenIddict.Abstractions;
using OpenIddict.Core;
using Xunit;
namespace OpenIddict.Server.Tests
namespace OpenIddict.Server.Internal.Tests
{
public partial class OpenIddictServerProviderTests
{

4
test/OpenIddict.Server.Tests/OpenIddictServerExtensionsTests.cs

@ -18,6 +18,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using OpenIddict.Server.Internal;
using OpenIddict.Server.Internal.Tests;
using Xunit;
namespace OpenIddict.Server.Tests
@ -103,7 +105,7 @@ namespace OpenIddict.Server.Tests
// Assert
Assert.Contains(services, service => service.Lifetime == ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictServerEventService) &&
service.ServiceType == typeof(OpenIddictServerEventService) &&
service.ImplementationType == typeof(OpenIddictServerEventService));
}

8
test/OpenIddict.Validation.Tests/Internal/OpenIddictValidationProviderTests.cs

@ -34,7 +34,7 @@ using OpenIddict.Abstractions;
using OpenIddict.Core;
using Xunit;
namespace OpenIddict.Validation.Tests
namespace OpenIddict.Validation.Internal.Tests
{
public class OpenIddictValidationProviderTests
{
@ -66,7 +66,8 @@ namespace OpenIddict.Validation.Tests
Assert.Equal(new StringBuilder()
.AppendLine("The core services must be registered when enabling reference tokens support.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.Append("To register the OpenIddict core services, reference the 'OpenIddict.Core' package ")
.Append("and call 'services.AddOpenIddict().AddCore()' from 'ConfigureServices'.")
.ToString(), exception.Message);
}
@ -348,7 +349,8 @@ namespace OpenIddict.Validation.Tests
Assert.Equal(new StringBuilder()
.AppendLine("The core services must be registered when enabling authorization validation.")
.Append("To register the OpenIddict core services, use 'services.AddOpenIddict().AddCore()'.")
.Append("To register the OpenIddict core services, reference the 'OpenIddict.Core' package ")
.Append("and call 'services.AddOpenIddict().AddCore()' from 'ConfigureServices'.")
.ToString(), exception.Message);
}

3
test/OpenIddict.Validation.Tests/OpenIddictValidationExtensionsTests.cs

@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenIddict.Validation.Internal;
using Xunit;
namespace OpenIddict.Validation.Tests
@ -82,7 +83,7 @@ namespace OpenIddict.Validation.Tests
// Assert
Assert.Contains(services, service => service.Lifetime == ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictValidationEventService) &&
service.ServiceType == typeof(OpenIddictValidationEventService) &&
service.ImplementationType == typeof(OpenIddictValidationEventService));
}

Loading…
Cancel
Save