diff --git a/samples/Mvc.Server/Controllers/AuthorizationController.cs b/samples/Mvc.Server/Controllers/AuthorizationController.cs index 464b9ada..12d98ce0 100644 --- a/samples/Mvc.Server/Controllers/AuthorizationController.cs +++ b/samples/Mvc.Server/Controllers/AuthorizationController.cs @@ -4,6 +4,7 @@ * the license and the contributors participating to this project. */ +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using AspNet.Security.OpenIdConnect.Extensions; @@ -42,6 +43,10 @@ namespace Mvc.Server { [Authorize, HttpGet("~/connect/authorize")] public async Task Authorize(OpenIdConnectRequest request) { + Debug.Assert(request.IsAuthorizationRequest(), + "The OpenIddict binder for ASP.NET Core MVC is not registered. " + + "Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); + // Retrieve the application details from the database. var application = await _applicationManager.FindByClientIdAsync(request.ClientId, HttpContext.RequestAborted); if (application == null) { @@ -63,6 +68,10 @@ namespace Mvc.Server { [Authorize, FormValueRequired("submit.Accept")] [HttpPost("~/connect/authorize"), ValidateAntiForgeryToken] public async Task Accept(OpenIdConnectRequest request) { + Debug.Assert(request.IsAuthorizationRequest(), + "The OpenIddict binder for ASP.NET Core MVC is not registered. " + + "Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); + // Retrieve the profile of the logged in user. var user = await _userManager.GetUserAsync(User); if (user == null) { @@ -92,6 +101,10 @@ namespace Mvc.Server { [HttpGet("~/connect/logout")] public IActionResult Logout(OpenIdConnectRequest request) { + Debug.Assert(request.IsLogoutRequest(), + "The OpenIddict binder for ASP.NET Core MVC is not registered. " + + "Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); + // Flow the request_id to allow OpenIddict to restore // the original logout request from the distributed cache. return View(new LogoutViewModel { @@ -118,6 +131,10 @@ namespace Mvc.Server { [HttpPost("~/connect/token"), Produces("application/json")] public async Task Exchange(OpenIdConnectRequest request) { + Debug.Assert(request.IsTokenRequest(), + "The OpenIddict binder for ASP.NET Core MVC is not registered. " + + "Make sure services.AddOpenIddict().AddMvcBinders() is correctly called."); + if (request.IsPasswordGrantType()) { var user = await _userManager.FindByNameAsync(request.Username); if (user == null) {