From 51919cb631f62040506266b46b19bc7a4d241d43 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 18 Jun 2019 23:30:47 -0700 Subject: [PATCH] Improve error message when no auth scheme specified (#11348) --- .../Authentication.Core/src/AuthenticationService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/Authentication.Core/src/AuthenticationService.cs b/src/Http/Authentication.Core/src/AuthenticationService.cs index bf10f47adf..7efce69ce8 100644 --- a/src/Http/Authentication.Core/src/AuthenticationService.cs +++ b/src/Http/Authentication.Core/src/AuthenticationService.cs @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Authentication scheme = defaultScheme?.Name; if (scheme == null) { - throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultAuthenticateScheme found."); + throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultAuthenticateScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action configureOptions)."); } } @@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Authentication scheme = defaultChallengeScheme?.Name; if (scheme == null) { - throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultChallengeScheme found."); + throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action configureOptions)."); } } @@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Authentication scheme = defaultForbidScheme?.Name; if (scheme == null) { - throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultForbidScheme found."); + throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultForbidScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action configureOptions)."); } } @@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Authentication scheme = defaultScheme?.Name; if (scheme == null) { - throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignInScheme found."); + throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignInScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action configureOptions)."); } } @@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Authentication scheme = defaultScheme?.Name; if (scheme == null) { - throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignOutScheme found."); + throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignOutScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action configureOptions)."); } }