Browse Source

Update exception messages to point to the new OpenIddict services APIs

pull/620/head
Kévin Chalet 8 years ago
parent
commit
0e5b0cec66
  1. 6
      samples/Mvc.Server/Controllers/AuthorizationController.cs
  2. 28
      src/OpenIddict.Core/OpenIddictCoreExtensions.cs
  3. 12
      src/OpenIddict.Server/Internal/OpenIddictServerInitializer.cs
  4. 12
      test/OpenIddict.Server.Tests/Internal/OpenIddictServerInitializerTests.cs

6
samples/Mvc.Server/Controllers/AuthorizationController.cs

@ -50,7 +50,7 @@ namespace Mvc.Server
{ {
Debug.Assert(request.IsAuthorizationRequest(), Debug.Assert(request.IsAuthorizationRequest(),
"The OpenIddict binder for ASP.NET Core MVC is not registered. " + "The OpenIddict binder for ASP.NET Core MVC is not registered. " +
"Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); "Make sure services.AddOpenIddict().AddServer().UseMvc() is correctly called.");
// Retrieve the application details from the database. // Retrieve the application details from the database.
var application = await _applicationManager.FindByClientIdAsync(request.ClientId); var application = await _applicationManager.FindByClientIdAsync(request.ClientId);
@ -79,7 +79,7 @@ namespace Mvc.Server
{ {
Debug.Assert(request.IsAuthorizationRequest(), Debug.Assert(request.IsAuthorizationRequest(),
"The OpenIddict binder for ASP.NET Core MVC is not registered. " + "The OpenIddict binder for ASP.NET Core MVC is not registered. " +
"Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); "Make sure services.AddOpenIddict().AddServer().UseMvc() is correctly called.");
// Retrieve the profile of the logged in user. // Retrieve the profile of the logged in user.
var user = await _userManager.GetUserAsync(User); var user = await _userManager.GetUserAsync(User);
@ -116,7 +116,7 @@ namespace Mvc.Server
{ {
Debug.Assert(request.IsLogoutRequest(), Debug.Assert(request.IsLogoutRequest(),
"The OpenIddict binder for ASP.NET Core MVC is not registered. " + "The OpenIddict binder for ASP.NET Core MVC is not registered. " +
"Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); "Make sure services.AddOpenIddict().AddServer().UseMvc() is correctly called.");
// Flow the request_id to allow OpenIddict to restore // Flow the request_id to allow OpenIddict to restore
// the original logout request from the distributed cache. // the original logout request from the distributed cache.

28
src/OpenIddict.Core/OpenIddictCoreExtensions.cs

@ -49,9 +49,10 @@ namespace Microsoft.Extensions.DependencyInjection
if (options.DefaultApplicationType == null) if (options.DefaultApplicationType == null)
{ {
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("The default application type must be configured for the non-generic services to work correctly.") .Append("No default application entity type was configured in the OpenIddict core options, ")
.Append("To configure the entities, use either 'services.AddOpenIddict().AddCore().UseDefaultModels()' ") .AppendLine("which generally indicates that no application store was registered in the DI container.")
.Append("or 'services.AddOpenIddict().AddCore().UseCustomModels()'.") .Append("To register the Entity Framework Core stores, reference the 'OpenIddict.EntityFrameworkCore' ")
.Append("package and call 'services.AddOpenIddict().AddCore().UseEntityFrameworkCore()'.")
.ToString()); .ToString());
} }
@ -65,9 +66,10 @@ namespace Microsoft.Extensions.DependencyInjection
if (options.DefaultAuthorizationType == null) if (options.DefaultAuthorizationType == null)
{ {
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("The default authorization type must be configured for the non-generic services to work correctly.") .Append("No default authorization entity type was configured in the OpenIddict core options, ")
.Append("To configure the entities, use either 'services.AddOpenIddict().AddCore().UseDefaultModels()' ") .AppendLine("which generally indicates that no authorization store was registered in the DI container.")
.Append("or 'services.AddOpenIddict().AddCore().UseCustomModels()'.") .Append("To register the Entity Framework Core stores, reference the 'OpenIddict.EntityFrameworkCore' ")
.Append("package and call 'services.AddOpenIddict().AddCore().UseEntityFrameworkCore()'.")
.ToString()); .ToString());
} }
@ -81,9 +83,10 @@ namespace Microsoft.Extensions.DependencyInjection
if (options.DefaultScopeType == null) if (options.DefaultScopeType == null)
{ {
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("The default scope type must be configured for the non-generic services to work correctly.") .Append("No default scope entity type was configured in the OpenIddict core options, ")
.Append("To configure the entities, use either 'services.AddOpenIddict().AddCore().UseDefaultModels()' ") .AppendLine("which generally indicates that no scope store was registered in the DI container.")
.Append("or 'services.AddOpenIddict().AddCore().UseCustomModels()'.") .Append("To register the Entity Framework Core stores, reference the 'OpenIddict.EntityFrameworkCore' ")
.Append("package and call 'services.AddOpenIddict().AddCore().UseEntityFrameworkCore()'.")
.ToString()); .ToString());
} }
@ -97,9 +100,10 @@ namespace Microsoft.Extensions.DependencyInjection
if (options.DefaultTokenType == null) if (options.DefaultTokenType == null)
{ {
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("The default token type must be configured for the non-generic services to work correctly.") .Append("No default token entity type was configured in the OpenIddict core options, ")
.Append("To configure the entities, use either 'services.AddOpenIddict().AddCore().UseDefaultModels()' ") .AppendLine("which generally indicates that no token store was registered in the DI container.")
.Append("or 'services.AddOpenIddict().AddCore().UseCustomModels()'.") .Append("To register the Entity Framework Core stores, reference the 'OpenIddict.EntityFrameworkCore' ")
.Append("package and call 'services.AddOpenIddict().AddCore().UseEntityFrameworkCore()'.")
.ToString()); .ToString());
} }

12
src/OpenIddict.Server/Internal/OpenIddictServerInitializer.cs

@ -179,9 +179,9 @@ namespace OpenIddict.Server
{ {
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("At least one signing key must be registered when using JWT as the access token format.") .AppendLine("At least one signing key must be registered when using JWT as the access token format.")
.Append("Consider registering a X.509 certificate using 'services.AddOpenIddict().AddSigningCertificate()' ") .Append("Consider registering a certificate using 'services.AddOpenIddict().AddServer().AddSigningCertificate()' ")
.Append("or 'services.AddOpenIddict().AddDevelopmentSigningCertificate()' or call ") .Append("or 'services.AddOpenIddict().AddServer().AddDevelopmentSigningCertificate()' or call ")
.Append("'services.AddOpenIddict().AddEphemeralSigningKey()' to use an ephemeral key.") .Append("'services.AddOpenIddict().AddServer().AddEphemeralSigningKey()' to use an ephemeral key.")
.ToString()); .ToString());
} }
@ -191,9 +191,9 @@ namespace OpenIddict.Server
{ {
throw new InvalidOperationException(new StringBuilder() throw new InvalidOperationException(new StringBuilder()
.AppendLine("At least one asymmetric signing key must be registered when enabling the implicit flow.") .AppendLine("At least one asymmetric signing key must be registered when enabling the implicit flow.")
.Append("Consider registering a X.509 certificate using 'services.AddOpenIddict().AddSigningCertificate()' ") .Append("Consider registering a certificate using 'services.AddOpenIddict().AddServer().AddSigningCertificate()' ")
.Append("or 'services.AddOpenIddict().AddDevelopmentSigningCertificate()' or call ") .Append("or 'services.AddOpenIddict().AddServer().AddDevelopmentSigningCertificate()' or call ")
.Append("'services.AddOpenIddict().AddEphemeralSigningKey()' to use an ephemeral key.") .Append("'services.AddOpenIddict().AddServer().AddEphemeralSigningKey()' to use an ephemeral key.")
.ToString()); .ToString());
} }

12
test/OpenIddict.Server.Tests/Internal/OpenIddictServerInitializerTests.cs

@ -272,9 +272,9 @@ namespace OpenIddict.Server.Tests
Assert.Equal(new StringBuilder() Assert.Equal(new StringBuilder()
.AppendLine("At least one signing key must be registered when using JWT as the access token format.") .AppendLine("At least one signing key must be registered when using JWT as the access token format.")
.Append("Consider registering a X.509 certificate using 'services.AddOpenIddict().AddSigningCertificate()' ") .Append("Consider registering a certificate using 'services.AddOpenIddict().AddServer().AddSigningCertificate()' ")
.Append("or 'services.AddOpenIddict().AddDevelopmentSigningCertificate()' or call ") .Append("or 'services.AddOpenIddict().AddServer().AddDevelopmentSigningCertificate()' or call ")
.Append("'services.AddOpenIddict().AddEphemeralSigningKey()' to use an ephemeral key.") .Append("'services.AddOpenIddict().AddServer().AddEphemeralSigningKey()' to use an ephemeral key.")
.ToString(), exception.Message); .ToString(), exception.Message);
} }
@ -298,9 +298,9 @@ namespace OpenIddict.Server.Tests
Assert.Equal(new StringBuilder() Assert.Equal(new StringBuilder()
.AppendLine("At least one asymmetric signing key must be registered when enabling the implicit flow.") .AppendLine("At least one asymmetric signing key must be registered when enabling the implicit flow.")
.Append("Consider registering a X.509 certificate using 'services.AddOpenIddict().AddSigningCertificate()' ") .Append("Consider registering a certificate using 'services.AddOpenIddict().AddServer().AddSigningCertificate()' ")
.Append("or 'services.AddOpenIddict().AddDevelopmentSigningCertificate()' or call ") .Append("or 'services.AddOpenIddict().AddServer().AddDevelopmentSigningCertificate()' or call ")
.Append("'services.AddOpenIddict().AddEphemeralSigningKey()' to use an ephemeral key.") .Append("'services.AddOpenIddict().AddServer().AddEphemeralSigningKey()' to use an ephemeral key.")
.ToString(), exception.Message); .ToString(), exception.Message);
} }

Loading…
Cancel
Save