diff --git a/samples/Mvc.Server/Controllers/AuthorizationController.cs b/samples/Mvc.Server/Controllers/AuthorizationController.cs index 64eed5ac..1f4212c3 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.Http.Authentication; @@ -23,6 +22,7 @@ using Mvc.Server.ViewModels.Shared; using OpenIddict.Abstractions; using OpenIddict.Core; using OpenIddict.Models; +using OpenIddict.Server; namespace Mvc.Server { @@ -106,7 +106,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 @@ -137,7 +137,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 @@ -224,7 +224,7 @@ namespace Mvc.Server { // Retrieve the claims principal stored in the authorization code/refresh token. var info = await HttpContext.Authentication.GetAuthenticateInfoAsync( - OpenIdConnectServerDefaults.AuthenticationScheme); + 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 @@ -275,7 +275,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 94642400..5f5c8ec7 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(ActiveAuthenticationSchemes = OAuthValidationDefaults.AuthenticationScheme)] + [Authorize(ActiveAuthenticationSchemes = OpenIddictValidationDefaults.AuthenticationScheme)] [HttpGet("message")] public async Task GetMessage() { diff --git a/src/OpenIddict.Server/OpenIddictServerDefaults.cs b/src/OpenIddict.Server/OpenIddictServerDefaults.cs new file mode 100644 index 00000000..c2f2dd3b --- /dev/null +++ b/src/OpenIddict.Server/OpenIddictServerDefaults.cs @@ -0,0 +1,16 @@ +using AspNet.Security.OpenIdConnect.Server; +using Microsoft.AspNetCore.Builder; + +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.Validation/OpenIddictValidationDefaults.cs b/src/OpenIddict.Validation/OpenIddictValidationDefaults.cs new file mode 100644 index 00000000..e8ab0028 --- /dev/null +++ b/src/OpenIddict.Validation/OpenIddictValidationDefaults.cs @@ -0,0 +1,16 @@ +using AspNet.Security.OAuth.Validation; +using Microsoft.AspNetCore.Builder; + +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/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs index 080e6182..75add952 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Exchange.cs @@ -729,7 +729,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"); @@ -790,7 +790,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); @@ -848,7 +848,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"); @@ -916,7 +916,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); @@ -981,7 +981,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"); @@ -1058,7 +1058,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); @@ -1132,7 +1132,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"); @@ -1224,7 +1224,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); @@ -1313,7 +1313,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"); @@ -1417,7 +1417,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); @@ -1518,7 +1518,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"); @@ -1599,7 +1599,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); @@ -1678,13 +1678,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 4c3fd00a..0ee0790d 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Introspection.cs @@ -239,13 +239,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); @@ -297,13 +297,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); @@ -355,13 +355,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"); @@ -414,7 +414,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 => @@ -470,13 +470,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 ce13cf9b..c613cee8 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Revocation.cs @@ -332,7 +332,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); @@ -370,7 +370,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(); @@ -413,7 +413,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -457,7 +457,7 @@ namespace OpenIddict.Server.Tests var ticket = new AuthenticationTicket( new ClaimsPrincipal(), new AuthenticationProperties(), - OpenIdConnectServerDefaults.AuthenticationScheme); + OpenIddictServerDefaults.AuthenticationScheme); ticket.SetTokenId("3E228451-1555-46F7-A471-951EFBA23A56"); @@ -506,7 +506,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 cdbecb94..6af93624 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.Serialization.cs @@ -84,13 +84,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"); @@ -350,13 +350,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"); @@ -509,13 +509,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"); @@ -797,13 +797,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"); @@ -899,13 +899,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>(); @@ -1015,13 +1015,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"); @@ -1160,13 +1160,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"); @@ -1347,13 +1347,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>(); @@ -1422,13 +1422,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>(); @@ -1488,13 +1488,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"); @@ -2134,7 +2134,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 20a5f583..b900cfe8 100644 --- a/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs +++ b/test/OpenIddict.Server.Tests/Internal/OpenIddictServerProviderTests.cs @@ -130,13 +130,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); @@ -201,13 +201,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"); @@ -283,13 +283,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); @@ -346,13 +346,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); @@ -404,13 +404,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"); @@ -481,13 +481,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"); @@ -564,13 +564,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); @@ -630,13 +630,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); @@ -700,13 +700,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); @@ -758,13 +758,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); @@ -842,13 +842,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); @@ -921,7 +921,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); @@ -989,7 +989,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); @@ -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); @@ -1447,13 +1447,13 @@ namespace OpenIddict.Server.Tests return Task.FromResult(0); } - 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()); @@ -1479,7 +1479,7 @@ namespace OpenIddict.Server.Tests { if (request.HasParameter("deny-authorization")) { - return context.Authentication.ForbidAsync(OpenIdConnectServerDefaults.AuthenticationScheme, ticket.Properties); + return context.Authentication.ForbidAsync(OpenIddictServerDefaults.AuthenticationScheme, ticket.Properties); } if (request.HasParameter("do-not-flow-original-properties")) @@ -1495,7 +1495,7 @@ namespace OpenIddict.Server.Tests else if (request.IsLogoutRequest()) { - return context.Authentication.SignOutAsync(OpenIdConnectServerDefaults.AuthenticationScheme, ticket.Properties); + return context.Authentication.SignOutAsync(OpenIddictServerDefaults.AuthenticationScheme, ticket.Properties); } else if (request.IsUserinfoRequest()) diff --git a/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs b/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs index 1ebc54f2..8dc11d07 100644 --- a/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs +++ b/test/OpenIddict.Validation.Tests/OpenIddictValidationHandlerTests.cs @@ -683,19 +683,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(); @@ -703,13 +703,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 @@ -718,13 +718,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 @@ -733,20 +733,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(); @@ -789,7 +789,7 @@ namespace OpenIddict.Validation.Tests app.Map("/ticket", map => map.Run(async context => { - var ticket = new AuthenticateContext(OAuthValidationDefaults.AuthenticationScheme); + var ticket = new AuthenticateContext(OpenIddictValidationDefaults.AuthenticationScheme); await context.Authentication.AuthenticateAsync(ticket); if (!ticket.Accepted || ticket.Principal == null || ticket.Properties == null) @@ -823,7 +823,7 @@ namespace OpenIddict.Validation.Tests [OAuthValidationConstants.Properties.Scope] = "custom_scope", }); - return context.Authentication.ChallengeAsync(OAuthValidationDefaults.AuthenticationScheme, properties); + return context.Authentication.ChallengeAsync(OpenIddictValidationDefaults.AuthenticationScheme, properties); })); app.Run(context =>