This commit is contained in:
Murat Girgin 2017-07-03 15:42:40 -07:00
parent 96f6436a67
commit 66b939725e
2 changed files with 14 additions and 0 deletions

View File

@ -142,6 +142,10 @@ namespace Microsoft.AspNetCore.Authentication
Logger.AuthenticationSchemeNotAuthenticated(Scheme.Name);
}
}
else if (result?.Failure != null)
{
Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Scheme.Name, result.Failure.Message);
}
return result;
}

View File

@ -9,6 +9,7 @@ namespace Microsoft.Extensions.Logging
{
private static Action<ILogger, string, Exception> _authSchemeAuthenticated;
private static Action<ILogger, string, Exception> _authSchemeNotAuthenticated;
private static Action<ILogger, string, string, Exception> _authSchemeNotAuthenticatedWithFailure;
private static Action<ILogger, string, Exception> _authSchemeChallenged;
private static Action<ILogger, string, Exception> _authSchemeForbidden;
private static Action<ILogger, string, Exception> _remoteAuthenticationError;
@ -32,6 +33,10 @@ namespace Microsoft.Extensions.Logging
eventId: 6,
logLevel: LogLevel.Debug,
formatString: "The SigningIn event returned Skipped.");
_authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define<string, string>(
eventId: 7,
logLevel: LogLevel.Information,
formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}");
_authSchemeAuthenticated = LoggerMessage.Define<string>(
eventId: 8,
logLevel: LogLevel.Information,
@ -72,6 +77,11 @@ namespace Microsoft.Extensions.Logging
_authSchemeNotAuthenticated(logger, authenticationScheme, null);
}
public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage)
{
_authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null);
}
public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme)
{
_authSchemeChallenged(logger, authenticationScheme, null);