From 92524d4371da8b331ac4aa8db4eaa9b65e731781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Wed, 2 May 2018 15:01:04 +0200 Subject: [PATCH] Introduce OpenIddictServerDefaults and OpenIddictValidationDefaults --- .../Controllers/AuthorizationController.cs | 10 ++-- .../Controllers/ResourceController.cs | 4 +- .../OpenIddictServerBuilder.cs | 3 +- .../OpenIddictServerDefaults.cs | 16 +++++ .../OpenIddictServerExtensions.cs | 6 +- .../OpenIddictValidationBuilder.cs | 3 +- .../OpenIddictValidationDefaults.cs | 16 +++++ .../OpenIddictValidationExtensions.cs | 6 +- .../OpenIddictServerInitializerTests.cs | 2 +- .../OpenIddictServerProviderTests.Exchange.cs | 28 ++++----- ...IddictServerProviderTests.Introspection.cs | 18 +++--- ...penIddictServerProviderTests.Revocation.cs | 10 ++-- ...IddictServerProviderTests.Serialization.cs | 42 +++++++------- .../Internal/OpenIddictServerProviderTests.cs | 58 +++++++++---------- .../OpenIddictServerBuilderTests.cs | 2 +- .../OpenIddictValidationHandlerTests.cs | 34 +++++------ 16 files changed, 144 insertions(+), 114 deletions(-) create mode 100644 src/OpenIddict.Server/OpenIddictServerDefaults.cs create mode 100644 src/OpenIddict.Validation/OpenIddictValidationDefaults.cs diff --git a/samples/Mvc.Server/Controllers/AuthorizationController.cs b/samples/Mvc.Server/Controllers/AuthorizationController.cs index 002d4e0f..a01a54b2 100644 --- a/samples/Mvc.Server/Controllers/AuthorizationController.cs +++ b/samples/Mvc.Server/Controllers/AuthorizationController.cs @@ -10,7 +10,6 @@ using System.Security.Claims; using System.Threading.Tasks; using AspNet.Security.OpenIdConnect.Extensions; using AspNet.Security.OpenIdConnect.Primitives; -using AspNet.Security.OpenIdConnect.Server; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -22,6 +21,7 @@ using Mvc.Server.ViewModels.Shared; using OpenIddict.Abstractions; using OpenIddict.Core; using OpenIddict.Models; +using OpenIddict.Server; namespace Mvc.Server { @@ -105,7 +105,7 @@ namespace Mvc.Server { // Notify OpenIddict that the authorization grant has been denied by the resource owner // to redirect the user agent to the client application using the appropriate response_mode. - return Forbid(OpenIdConnectServerDefaults.AuthenticationScheme); + return Forbid(OpenIddictServerDefaults.AuthenticationScheme); } // Note: the logout action is only useful when implementing interactive @@ -136,7 +136,7 @@ namespace Mvc.Server // Returning a SignOutResult will ask OpenIddict to redirect the user agent // to the post_logout_redirect_uri specified by the client application. - return SignOut(OpenIdConnectServerDefaults.AuthenticationScheme); + return SignOut(OpenIddictServerDefaults.AuthenticationScheme); } #endregion @@ -183,7 +183,7 @@ namespace Mvc.Server else if (request.IsAuthorizationCodeGrantType() || request.IsRefreshTokenGrantType()) { // Retrieve the claims principal stored in the authorization code/refresh token. - var info = await HttpContext.AuthenticateAsync(OpenIdConnectServerDefaults.AuthenticationScheme); + var info = await HttpContext.AuthenticateAsync(OpenIddictServerDefaults.AuthenticationScheme); // Retrieve the user profile corresponding to the authorization code/refresh token. // Note: if you want to automatically invalidate the authorization code/refresh token @@ -234,7 +234,7 @@ namespace Mvc.Server // Create a new authentication ticket holding the user identity. var ticket = new AuthenticationTicket(principal, properties, - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); if (!request.IsAuthorizationCodeGrantType() && !request.IsRefreshTokenGrantType()) { diff --git a/samples/Mvc.Server/Controllers/ResourceController.cs b/samples/Mvc.Server/Controllers/ResourceController.cs index 6d754dbc..3bfa2b46 100644 --- a/samples/Mvc.Server/Controllers/ResourceController.cs +++ b/samples/Mvc.Server/Controllers/ResourceController.cs @@ -1,9 +1,9 @@ using System.Threading.Tasks; -using AspNet.Security.OAuth.Validation; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Mvc.Server.Models; +using OpenIddict.Validation; namespace Mvc.Server.Controllers { @@ -17,7 +17,7 @@ namespace Mvc.Server.Controllers _userManager = userManager; } - [Authorize(AuthenticationSchemes = OAuthValidationDefaults.AuthenticationScheme)] + [Authorize(AuthenticationSchemes = OpenIddictValidationDefaults.AuthenticationScheme)] [HttpGet("message")] public async Task GetMessage() { diff --git a/src/OpenIddict.Server/OpenIddictServerBuilder.cs b/src/OpenIddict.Server/OpenIddictServerBuilder.cs index f300732f..5a58c62e 100644 --- a/src/OpenIddict.Server/OpenIddictServerBuilder.cs +++ b/src/OpenIddict.Server/OpenIddictServerBuilder.cs @@ -14,7 +14,6 @@ using System.Reflection; using System.Security.Cryptography.X509Certificates; using System.Threading; using AspNet.Security.OpenIdConnect.Primitives; -using AspNet.Security.OpenIdConnect.Server; using JetBrains.Annotations; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; @@ -62,7 +61,7 @@ namespace Microsoft.Extensions.DependencyInjection throw new ArgumentNullException(nameof(configuration)); } - Services.Configure(OpenIdConnectServerDefaults.AuthenticationScheme, configuration); + Services.Configure(OpenIddictServerDefaults.AuthenticationScheme, configuration); return this; } diff --git a/src/OpenIddict.Server/OpenIddictServerDefaults.cs b/src/OpenIddict.Server/OpenIddictServerDefaults.cs new file mode 100644 index 00000000..2fe78aef --- /dev/null +++ b/src/OpenIddict.Server/OpenIddictServerDefaults.cs @@ -0,0 +1,16 @@ +using AspNet.Security.OpenIdConnect.Server; +using Microsoft.AspNetCore.Authentication; + +namespace OpenIddict.Server +{ + /// + /// Exposes the default values used by the OpenIddict server handler. + /// + public static class OpenIddictServerDefaults + { + /// + /// Default value for . + /// + public const string AuthenticationScheme = OpenIdConnectServerDefaults.AuthenticationScheme; + } +} diff --git a/src/OpenIddict.Server/OpenIddictServerExtensions.cs b/src/OpenIddict.Server/OpenIddictServerExtensions.cs index 75781bc4..5dc99df8 100644 --- a/src/OpenIddict.Server/OpenIddictServerExtensions.cs +++ b/src/OpenIddict.Server/OpenIddictServerExtensions.cs @@ -48,7 +48,7 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddScoped(provider => { var options = provider.GetRequiredService>() - .Get(OpenIdConnectServerDefaults.AuthenticationScheme); + .Get(OpenIddictServerDefaults.AuthenticationScheme); if (options == null) { @@ -80,12 +80,12 @@ namespace Microsoft.Extensions.DependencyInjection { // Note: this method is guaranteed to be idempotent. To prevent multiple schemes from being // registered (which would result in an exception being thrown), a manual check is made here. - if (options.SchemeMap.ContainsKey(OpenIdConnectServerDefaults.AuthenticationScheme)) + if (options.SchemeMap.ContainsKey(OpenIddictServerDefaults.AuthenticationScheme)) { return; } - options.AddScheme(OpenIdConnectServerDefaults.AuthenticationScheme, scheme => + options.AddScheme(OpenIddictServerDefaults.AuthenticationScheme, scheme => { scheme.HandlerType = typeof(OpenIddictServerHandler); }); diff --git a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs index 272790ff..30444bad 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs @@ -7,7 +7,6 @@ using System; using System.ComponentModel; using System.Linq; -using AspNet.Security.OAuth.Validation; using JetBrains.Annotations; using Microsoft.AspNetCore.DataProtection; using OpenIddict.Validation; @@ -52,7 +51,7 @@ namespace Microsoft.Extensions.DependencyInjection throw new ArgumentNullException(nameof(configuration)); } - Services.Configure(OAuthValidationDefaults.AuthenticationScheme, configuration); + Services.Configure(OpenIddictValidationDefaults.AuthenticationScheme, configuration); return this; } diff --git a/src/OpenIddict.Validation/OpenIddictValidationDefaults.cs b/src/OpenIddict.Validation/OpenIddictValidationDefaults.cs new file mode 100644 index 00000000..a36ee81d --- /dev/null +++ b/src/OpenIddict.Validation/OpenIddictValidationDefaults.cs @@ -0,0 +1,16 @@ +using AspNet.Security.OAuth.Validation; +using Microsoft.AspNetCore.Authentication; + +namespace OpenIddict.Validation +{ + /// + /// Exposes the default values used by the OpenIddict validation handler. + /// + public static class OpenIddictValidationDefaults + { + /// + /// Default value for . + /// + public const string AuthenticationScheme = OAuthValidationDefaults.AuthenticationScheme; + } +} diff --git a/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs b/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs index 2af3333f..d1145a6e 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs @@ -47,7 +47,7 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddScoped(provider => { var options = provider.GetRequiredService>() - .Get(OAuthValidationDefaults.AuthenticationScheme); + .Get(OpenIddictValidationDefaults.AuthenticationScheme); if (options == null) { @@ -86,12 +86,12 @@ namespace Microsoft.Extensions.DependencyInjection { // Note: this method is guaranteed to be idempotent. To prevent multiple schemes from being // registered (which would result in an exception being thrown), a manual check is made here. - if (options.SchemeMap.ContainsKey(OAuthValidationDefaults.AuthenticationScheme)) + if (options.SchemeMap.ContainsKey(OpenIddictValidationDefaults.AuthenticationScheme)) { return; } - options.AddScheme(OAuthValidationDefaults.AuthenticationScheme, scheme => + options.AddScheme(OpenIddictValidationDefaults.AuthenticationScheme, scheme => { scheme.HandlerType = typeof(OpenIddictValidationHandler); }); diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerInitializerTests.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerInitializerTests.cs index 4fd3a9fc..54360c09 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerInitializerTests.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerInitializerTests.cs @@ -282,7 +282,7 @@ namespace OpenIddict.Server.Tests { app.UseAuthentication(); - app.Run(context => context.ChallengeAsync(OpenIdConnectServerDefaults.AuthenticationScheme)); + app.Run(context => context.ChallengeAsync(OpenIddictServerDefaults.AuthenticationScheme)); }); return new TestServer(builder); diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs index afe4b383..ebfea6ec 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs @@ -727,7 +727,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -788,7 +788,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -846,7 +846,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -914,7 +914,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -979,7 +979,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -1056,7 +1056,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -1130,7 +1130,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -1222,7 +1222,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -1311,7 +1311,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -1415,7 +1415,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -1516,7 +1516,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -1597,7 +1597,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -1676,13 +1676,13 @@ namespace OpenIddict.Server.Tests public async Task HandleTokenRequest_RequestsAreNotHandledLocally(string flow) { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs index 331bec2b..94dba90f 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs @@ -237,13 +237,13 @@ namespace OpenIddict.Server.Tests public async Task HandleIntrospectionRequest_RequestIsRejectedWhenTokenIsNotAnAccessToken(string type) { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); ticket.SetTokenUsage(type); @@ -295,13 +295,13 @@ namespace OpenIddict.Server.Tests public async Task HandleIntrospectionRequest_RequestIsRejectedWhenAudienceIsMissing() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken); @@ -353,13 +353,13 @@ namespace OpenIddict.Server.Tests public async Task HandleIntrospectionRequest_RequestIsRejectedWhenClientIsNotAValidAudience() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetAudiences("Contoso"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -412,7 +412,7 @@ namespace OpenIddict.Server.Tests public async Task HandleIntrospectionRequest_RequestIsRejectedWhenReferenceTokenIsUnknown() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var manager = CreateTokenManager(instance => @@ -468,13 +468,13 @@ namespace OpenIddict.Server.Tests public async Task HandleIntrospectionRequest_RequestIsRejectedWhenReferenceTokenIsInvalid() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetAudiences("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs index c17cd42c..6d42a689 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs @@ -330,7 +330,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.AccessToken); @@ -368,7 +368,7 @@ namespace OpenIddict.Server.Tests mock.ValidFrom == DateTime.UtcNow.AddDays(-1) && mock.ValidTo == DateTime.UtcNow.AddDays(1)); - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.TokenUsage, OpenIdConnectConstants.TokenUsages.IdToken); var handler = new Mock(); @@ -411,7 +411,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -455,7 +455,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -504,7 +504,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs index cf36c521..d0f0ded1 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs @@ -82,13 +82,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeAccessToken_AccessTokenIsNotRetrievedFromDatabaseWhenReferenceTokensAreDisabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetAudiences("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -348,13 +348,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeAccessToken_ReturnsExpectedReferenceToken() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetAudiences("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -507,13 +507,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeAuthorizationCode_AuthorizationCodeIsNotRetrievedUsingHashWhenReferenceTokensAreDisabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -795,13 +795,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeAuthorizationCode_ReturnsExpectedReferenceToken() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); @@ -897,13 +897,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeAuthorizationCode_ReturnsNullForMissingTokenIdentifier() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); var format = new Mock>(); @@ -1013,13 +1013,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeAuthorizationCode_ReturnsExpectedToken() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -1158,13 +1158,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeRefreshToken_RefreshTokenIsNotRetrievedUsingHashWhenReferenceTokensAreDisabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -1345,13 +1345,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeRefreshToken_ReturnsExpectedReferenceToken() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); var format = new Mock>(); @@ -1420,13 +1420,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeRefreshToken_ReturnsNullForMissingTokenIdentifier() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); var format = new Mock>(); @@ -1486,13 +1486,13 @@ namespace OpenIddict.Server.Tests public async Task DeserializeRefreshToken_ReturnsExpectedToken() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -2132,7 +2132,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetScopes(OpenIdConnectConstants.Scopes.OpenId, OpenIdConnectConstants.Scopes.OfflineAccess); diff --git a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs index cd9c21b5..b9816a41 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs @@ -129,13 +129,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_AuthenticationPropertiesAreAutomaticallyRestored() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -200,13 +200,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_RefreshTokenIsIssuedForAuthorizationCodeRequestsWhenRollingTokensAreEnabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -282,13 +282,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_RefreshTokenIsAlwaysIssuedWhenRollingTokensAreEnabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -345,13 +345,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_RefreshTokenIsNotIssuedWhenRollingTokensAreDisabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -403,13 +403,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_AuthorizationCodeIsAutomaticallyRedeemed() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -480,13 +480,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_ReturnsErrorResponseWhenRedeemingAuthorizationCodeFails() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetPresenters("Fabrikam"); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -563,13 +563,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_RefreshTokenIsAutomaticallyRedeemedWhenRollingTokensAreEnabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -629,13 +629,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_ReturnsErrorResponseWhenRedeemingRefreshTokenFails() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -699,13 +699,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_RefreshTokenIsNotRedeemedWhenRollingTokensAreDisabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -757,13 +757,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_PreviousTokensAreAutomaticallyRevokedWhenRollingTokensAreEnabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -841,13 +841,13 @@ namespace OpenIddict.Server.Tests public async Task ProcessSigninResponse_PreviousTokensAreNotRevokedWhenRollingTokensAreDisabled() { // Arrange - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Bricoleur"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -920,7 +920,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -988,7 +988,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -1055,7 +1055,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("60FFF7EA-F98E-437B-937E-5073CC313103"); ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); @@ -1445,13 +1445,13 @@ namespace OpenIddict.Server.Tests return Task.CompletedTask; } - var identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictServerDefaults.AuthenticationScheme); identity.AddClaim(OpenIdConnectConstants.Claims.Subject, "Bob le Magnifique"); var ticket = new AuthenticationTicket( new ClaimsPrincipal(identity), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetScopes(request.GetScopes()); @@ -1477,7 +1477,7 @@ namespace OpenIddict.Server.Tests { if (request.HasParameter("deny-authorization")) { - return context.ForbidAsync(OpenIdConnectServerDefaults.AuthenticationScheme, ticket.Properties); + return context.ForbidAsync(OpenIddictServerDefaults.AuthenticationScheme, ticket.Properties); } if (request.HasParameter("do-not-flow-original-properties")) @@ -1493,7 +1493,7 @@ namespace OpenIddict.Server.Tests else if (request.IsLogoutRequest()) { - return context.SignOutAsync(OpenIdConnectServerDefaults.AuthenticationScheme, ticket.Properties); + return context.SignOutAsync(OpenIddictServerDefaults.AuthenticationScheme, ticket.Properties); } else if (request.IsUserinfoRequest()) diff --git a/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs b/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs index e0e83146..35dda1de 100644 --- a/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs +++ b/test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs @@ -693,7 +693,7 @@ namespace OpenIddict.Server.Tests var provider = services.BuildServiceProvider(); var options = provider.GetRequiredService>(); - return options.Get(OpenIdConnectServerDefaults.AuthenticationScheme); + return options.Get(OpenIddictServerDefaults.AuthenticationScheme); } } } diff --git a/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs b/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs index 5ce329b6..fdf7baca 100755 --- a/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs +++ b/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs @@ -375,7 +375,7 @@ namespace OpenIddict.Validation.Tests { builder.Configure(options => options.Events.OnRetrieveToken = context => { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Fabrikam")); context.Principal = new ClaimsPrincipal(identity); @@ -458,7 +458,7 @@ namespace OpenIddict.Validation.Tests { builder.Configure(options => options.Events.OnValidateToken = context => { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Contoso")); context.Principal = new ClaimsPrincipal(identity); @@ -611,19 +611,19 @@ namespace OpenIddict.Validation.Tests format.Setup(mock => mock.Unprotect(It.Is(token => token == "valid-token"))) .Returns(delegate { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Fabrikam")); var properties = new AuthenticationProperties(); return new AuthenticationTicket(new ClaimsPrincipal(identity), - properties, OAuthValidationDefaults.AuthenticationScheme); + properties, OpenIddictValidationDefaults.AuthenticationScheme); }); format.Setup(mock => mock.Unprotect(It.Is(token => token == "valid-token-with-scopes"))) .Returns(delegate { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Fabrikam")); var properties = new AuthenticationProperties(); @@ -631,13 +631,13 @@ namespace OpenIddict.Validation.Tests @"[""C54A8F5E-0387-43F4-BA43-FD4B50DC190D"",""5C57E3BD-9EFB-4224-9AB8-C8C5E009FFD7""]"; return new AuthenticationTicket(new ClaimsPrincipal(identity), - properties, OAuthValidationDefaults.AuthenticationScheme); + properties, OpenIddictValidationDefaults.AuthenticationScheme); }); format.Setup(mock => mock.Unprotect(It.Is(token => token == "valid-token-with-single-audience"))) .Returns(delegate { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Fabrikam")); var properties = new AuthenticationProperties(new Dictionary @@ -646,13 +646,13 @@ namespace OpenIddict.Validation.Tests }); return new AuthenticationTicket(new ClaimsPrincipal(identity), - properties, OAuthValidationDefaults.AuthenticationScheme); + properties, OpenIddictValidationDefaults.AuthenticationScheme); }); format.Setup(mock => mock.Unprotect(It.Is(token => token == "valid-token-with-multiple-audiences"))) .Returns(delegate { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Fabrikam")); var properties = new AuthenticationProperties(new Dictionary @@ -661,20 +661,20 @@ namespace OpenIddict.Validation.Tests }); return new AuthenticationTicket(new ClaimsPrincipal(identity), - properties, OAuthValidationDefaults.AuthenticationScheme); + properties, OpenIddictValidationDefaults.AuthenticationScheme); }); format.Setup(mock => mock.Unprotect(It.Is(token => token == "expired-token"))) .Returns(delegate { - var identity = new ClaimsIdentity(OAuthValidationDefaults.AuthenticationScheme); + var identity = new ClaimsIdentity(OpenIddictValidationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Subject, "Fabrikam")); var properties = new AuthenticationProperties(); properties.ExpiresUtc = DateTimeOffset.UtcNow - TimeSpan.FromDays(1); return new AuthenticationTicket(new ClaimsPrincipal(identity), - properties, OAuthValidationDefaults.AuthenticationScheme); + properties, OpenIddictValidationDefaults.AuthenticationScheme); }); var builder = new WebHostBuilder(); @@ -713,7 +713,7 @@ namespace OpenIddict.Validation.Tests { app.Map("/ticket", map => map.Run(async context => { - var result = await context.AuthenticateAsync(OAuthValidationDefaults.AuthenticationScheme); + var result = await context.AuthenticateAsync(OpenIddictValidationDefaults.AuthenticationScheme); if (result.Principal == null) { await context.ChallengeAsync(); @@ -745,15 +745,15 @@ namespace OpenIddict.Validation.Tests [OAuthValidationConstants.Properties.Scope] = "custom_scope", }); - return context.ChallengeAsync(OAuthValidationDefaults.AuthenticationScheme, properties); + return context.ChallengeAsync(OpenIddictValidationDefaults.AuthenticationScheme, properties); })); app.Run(async context => { - var result = await context.AuthenticateAsync(OAuthValidationDefaults.AuthenticationScheme); + var result = await context.AuthenticateAsync(OpenIddictValidationDefaults.AuthenticationScheme); if (result.Principal == null) { - await context.ChallengeAsync(OAuthValidationDefaults.AuthenticationScheme); + await context.ChallengeAsync(OpenIddictValidationDefaults.AuthenticationScheme); return; } @@ -761,7 +761,7 @@ namespace OpenIddict.Validation.Tests var subject = result.Principal.FindFirst(OAuthValidationConstants.Claims.Subject)?.Value; if (string.IsNullOrEmpty(subject)) { - await context.ChallengeAsync(OAuthValidationDefaults.AuthenticationScheme); + await context.ChallengeAsync(OpenIddictValidationDefaults.AuthenticationScheme); return; }