diff --git a/src/Security/Authentication/Cookies/src/CookieAuthenticationHandler.cs b/src/Security/Authentication/Cookies/src/CookieAuthenticationHandler.cs index ff6bb3cbca..25e0e3d039 100644 --- a/src/Security/Authentication/Cookies/src/CookieAuthenticationHandler.cs +++ b/src/Security/Authentication/Cookies/src/CookieAuthenticationHandler.cs @@ -334,7 +334,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var shouldRedirect = Options.LoginPath.HasValue && OriginalPath == Options.LoginPath; await ApplyHeaders(shouldRedirect, signedInContext.Properties); - Logger.SignedIn(Scheme.Name); + Logger.AuthenticationSchemeSignedIn(Scheme.Name); } protected async override Task HandleSignOutAsync(AuthenticationProperties properties) @@ -369,7 +369,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies var shouldRedirect = Options.LogoutPath.HasValue && OriginalPath == Options.LogoutPath; await ApplyHeaders(shouldRedirect, context.Properties); - Logger.SignedOut(Scheme.Name); + Logger.AuthenticationSchemeSignedOut(Scheme.Name); } private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationProperties properties) diff --git a/src/Security/Authentication/Cookies/src/LoggingExtensions.cs b/src/Security/Authentication/Cookies/src/LoggingExtensions.cs index d12735443f..a8a59f29dd 100644 --- a/src/Security/Authentication/Cookies/src/LoggingExtensions.cs +++ b/src/Security/Authentication/Cookies/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -7,29 +7,29 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _authSchemeSignedIn; - private static Action _authSchemeSignedOut; + private static Action _authenticationSchemeSignedIn; + private static Action _authenticationSchemeSignedOut; static LoggingExtensions() { - _authSchemeSignedIn = LoggerMessage.Define( - eventId: 10, + _authenticationSchemeSignedIn = LoggerMessage.Define( + eventId: new EventId(10, "AuthenticationSchemeSignedIn"), logLevel: LogLevel.Information, formatString: "AuthenticationScheme: {AuthenticationScheme} signed in."); - _authSchemeSignedOut = LoggerMessage.Define( - eventId: 11, + _authenticationSchemeSignedOut = LoggerMessage.Define( + eventId: new EventId(11, "AuthenticationSchemeSignedOut"), logLevel: LogLevel.Information, formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); } - public static void SignedIn(this ILogger logger, string authenticationScheme) + public static void AuthenticationSchemeSignedIn(this ILogger logger, string authenticationScheme) { - _authSchemeSignedIn(logger, authenticationScheme, null); + _authenticationSchemeSignedIn(logger, authenticationScheme, null); } - public static void SignedOut(this ILogger logger, string authenticationScheme) + public static void AuthenticationSchemeSignedOut(this ILogger logger, string authenticationScheme) { - _authSchemeSignedOut(logger, authenticationScheme, null); + _authenticationSchemeSignedOut(logger, authenticationScheme, null); } } } diff --git a/src/Security/Authentication/Core/src/LoggingExtensions.cs b/src/Security/Authentication/Core/src/LoggingExtensions.cs index 042bfabca3..75a1e3e6e3 100644 --- a/src/Security/Authentication/Core/src/LoggingExtensions.cs +++ b/src/Security/Authentication/Core/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -7,11 +7,11 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static readonly Action _authSchemeAuthenticated; - private static readonly Action _authSchemeNotAuthenticated; - private static readonly Action _authSchemeNotAuthenticatedWithFailure; - private static readonly Action _authSchemeChallenged; - private static readonly Action _authSchemeForbidden; + private static readonly Action _authenticationSchemeAuthenticated; + private static readonly Action _authenticationSchemeNotAuthenticated; + private static readonly Action _authenticationSchemeNotAuthenticatedWithFailure; + private static readonly Action _authenticationSchemeChallenged; + private static readonly Action _authenticationSchemeForbidden; private static readonly Action _remoteAuthenticationError; private static readonly Action _signInHandled; private static readonly Action _signInSkipped; @@ -25,86 +25,86 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { _remoteAuthenticationError = LoggerMessage.Define( - eventId: 4, + eventId: new EventId(4, "RemoteAuthenticationFailed"), logLevel: LogLevel.Information, formatString: "Error from RemoteAuthentication: {ErrorMessage}."); _signInHandled = LoggerMessage.Define( - eventId: 5, + eventId: new EventId(5, "SignInHandled"), logLevel: LogLevel.Debug, formatString: "The SigningIn event returned Handled."); _signInSkipped = LoggerMessage.Define( - eventId: 6, + eventId: new EventId(6, "SignInSkipped"), logLevel: LogLevel.Debug, formatString: "The SigningIn event returned Skipped."); - _authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( - eventId: 7, + _authenticationSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( + eventId: new EventId(7, "AuthenticationSchemeNotAuthenticatedWithFailure"), logLevel: LogLevel.Information, formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); - _authSchemeAuthenticated = LoggerMessage.Define( - eventId: 8, + _authenticationSchemeAuthenticated = LoggerMessage.Define( + eventId: new EventId(8, "AuthenticationSchemeAuthenticated"), logLevel: LogLevel.Debug, formatString: "AuthenticationScheme: {AuthenticationScheme} was successfully authenticated."); - _authSchemeNotAuthenticated = LoggerMessage.Define( - eventId: 9, + _authenticationSchemeNotAuthenticated = LoggerMessage.Define( + eventId: new EventId(9, "AuthenticationSchemeNotAuthenticated"), logLevel: LogLevel.Debug, formatString: "AuthenticationScheme: {AuthenticationScheme} was not authenticated."); - _authSchemeChallenged = LoggerMessage.Define( - eventId: 12, + _authenticationSchemeChallenged = LoggerMessage.Define( + eventId: new EventId(12, "AuthenticationSchemeChallenged"), logLevel: LogLevel.Information, formatString: "AuthenticationScheme: {AuthenticationScheme} was challenged."); - _authSchemeForbidden = LoggerMessage.Define( - eventId: 13, + _authenticationSchemeForbidden = LoggerMessage.Define( + eventId: new EventId(13, "AuthenticationSchemeForbidden"), logLevel: LogLevel.Information, formatString: "AuthenticationScheme: {AuthenticationScheme} was forbidden."); _correlationPropertyNotFound = LoggerMessage.Define( - eventId: 14, + eventId: new EventId(14, "CorrelationPropertyNotFound"), logLevel: LogLevel.Warning, formatString: "{CorrelationProperty} state property not found."); _correlationCookieNotFound = LoggerMessage.Define( - eventId: 15, + eventId: new EventId(15, "CorrelationCookieNotFound"), logLevel: LogLevel.Warning, formatString: "'{CorrelationCookieName}' cookie not found."); _unexpectedCorrelationCookieValue = LoggerMessage.Define( - eventId: 16, + eventId: new EventId(16, "UnexpectedCorrelationCookieValue"), logLevel: LogLevel.Warning, formatString: "The correlation cookie value '{CorrelationCookieName}' did not match the expected value '{CorrelationCookieValue}'."); _accessDeniedError = LoggerMessage.Define( - eventId: 17, + eventId: new EventId(17, "AccessDenied"), logLevel: LogLevel.Information, formatString: "Access was denied by the resource owner or by the remote server."); _accessDeniedContextHandled = LoggerMessage.Define( - eventId: 18, + eventId: new EventId(18, "AccessDeniedContextHandled"), logLevel: LogLevel.Debug, formatString: "The AccessDenied event returned Handled."); _accessDeniedContextSkipped = LoggerMessage.Define( - eventId: 19, + eventId: new EventId(19, "AccessDeniedContextSkipped"), logLevel: LogLevel.Debug, formatString: "The AccessDenied event returned Skipped."); } public static void AuthenticationSchemeAuthenticated(this ILogger logger, string authenticationScheme) { - _authSchemeAuthenticated(logger, authenticationScheme, null); + _authenticationSchemeAuthenticated(logger, authenticationScheme, null); } public static void AuthenticationSchemeNotAuthenticated(this ILogger logger, string authenticationScheme) { - _authSchemeNotAuthenticated(logger, authenticationScheme, null); + _authenticationSchemeNotAuthenticated(logger, authenticationScheme, null); } public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage) { - _authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); + _authenticationSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); } public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme) { - _authSchemeChallenged(logger, authenticationScheme, null); + _authenticationSchemeChallenged(logger, authenticationScheme, null); } public static void AuthenticationSchemeForbidden(this ILogger logger, string authenticationScheme) { - _authSchemeForbidden(logger, authenticationScheme, null); + _authenticationSchemeForbidden(logger, authenticationScheme, null); } public static void RemoteAuthenticationError(this ILogger logger, string errorMessage) @@ -112,12 +112,12 @@ namespace Microsoft.Extensions.Logging _remoteAuthenticationError(logger, errorMessage, null); } - public static void SigninHandled(this ILogger logger) + public static void SignInHandled(this ILogger logger) { _signInHandled(logger, null); } - public static void SigninSkipped(this ILogger logger) + public static void SignInSkipped(this ILogger logger) { _signInSkipped(logger, null); } diff --git a/src/Security/Authentication/Core/src/RemoteAuthenticationHandler.cs b/src/Security/Authentication/Core/src/RemoteAuthenticationHandler.cs index c72583b5ce..95ededd349 100644 --- a/src/Security/Authentication/Core/src/RemoteAuthenticationHandler.cs +++ b/src/Security/Authentication/Core/src/RemoteAuthenticationHandler.cs @@ -127,12 +127,12 @@ namespace Microsoft.AspNetCore.Authentication { if (ticketContext.Result.Handled) { - Logger.SigninHandled(); + Logger.SignInHandled(); return true; } else if (ticketContext.Result.Skipped) { - Logger.SigninSkipped(); + Logger.SignInSkipped(); return false; } } diff --git a/src/Security/Authentication/JwtBearer/src/LoggingExtensions.cs b/src/Security/Authentication/JwtBearer/src/LoggingExtensions.cs index 5c6ca088a8..c00b283086 100644 --- a/src/Security/Authentication/JwtBearer/src/LoggingExtensions.cs +++ b/src/Security/Authentication/JwtBearer/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -14,15 +14,15 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { _tokenValidationFailed = LoggerMessage.Define( - eventId: 1, + eventId: new EventId(1, "TokenValidationFailed"), logLevel: LogLevel.Information, formatString: "Failed to validate the token."); _tokenValidationSucceeded = LoggerMessage.Define( - eventId: 2, + eventId: new EventId(2, "TokenValidationSucceeded"), logLevel: LogLevel.Information, formatString: "Successfully validated the token."); _errorProcessingMessage = LoggerMessage.Define( - eventId: 3, + eventId: new EventId(3, "ProcessingMessageFailed"), logLevel: LogLevel.Error, formatString: "Exception occurred while processing message."); } diff --git a/src/Security/Authentication/OpenIdConnect/src/LoggingExtensions.cs b/src/Security/Authentication/OpenIdConnect/src/LoggingExtensions.cs index 224af87b6f..2994982521 100644 --- a/src/Security/Authentication/OpenIdConnect/src/LoggingExtensions.cs +++ b/src/Security/Authentication/OpenIdConnect/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -9,8 +9,8 @@ namespace Microsoft.Extensions.Logging { private static Action _redirectToIdentityProviderForSignOutHandledResponse; private static Action _redirectToIdentityProviderHandledResponse; - private static Action _signoutCallbackRedirectHandledResponse; - private static Action _signoutCallbackRedirectSkipped; + private static Action _signOutCallbackRedirectHandledResponse; + private static Action _signOutCallbackRedirectSkipped; private static Action _updatingConfiguration; private static Action _receivedIdToken; private static Action _redeemingCodeForTokens; @@ -55,209 +55,211 @@ namespace Microsoft.Extensions.Logging private static Action _remoteSignOut; private static Action _remoteSignOutSessionIdMissing; private static Action _remoteSignOutSessionIdInvalid; - private static Action _signOut; + private static Action _authenticationSchemeSignedOut; static LoggingExtensions() { // Final _redirectToIdentityProviderForSignOutHandledResponse = LoggerMessage.Define( - eventId: 1, + eventId: new EventId(1, "RedirectToIdentityProviderForSignOutHandledResponse"), logLevel: LogLevel.Debug, formatString: "RedirectToIdentityProviderForSignOut.HandledResponse"); _invalidLogoutQueryStringRedirectUrl = LoggerMessage.Define( - eventId: 3, + eventId: new EventId(3, "InvalidLogoutQueryStringRedirectUrl"), logLevel: LogLevel.Warning, formatString: "The query string for Logout is not a well-formed URI. Redirect URI: '{RedirectUrl}'."); _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync = LoggerMessage.Define( - eventId: 4, + eventId: new EventId(4, "EnteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync"), logLevel: LogLevel.Trace, formatString: "Entering {OpenIdConnectHandlerType}'s HandleUnauthorizedAsync."); _enteringOpenIdAuthenticationHandlerHandleSignOutAsync = LoggerMessage.Define( - eventId: 14, + eventId: new EventId(14, "EnteringOpenIdAuthenticationHandlerHandleSignOutAsync"), logLevel: LogLevel.Trace, formatString: "Entering {OpenIdConnectHandlerType}'s HandleSignOutAsync."); _postAuthenticationLocalRedirect = LoggerMessage.Define( - eventId: 5, + eventId: new EventId(5, "PostAuthenticationLocalRedirect"), logLevel: LogLevel.Trace, formatString: "Using properties.RedirectUri for 'local redirect' post authentication: '{RedirectUri}'."); _redirectToIdentityProviderHandledResponse = LoggerMessage.Define( - eventId: 6, + eventId: new EventId(6, "RedirectToIdentityProviderHandledResponse"), logLevel: LogLevel.Debug, formatString: "RedirectToIdentityProvider.HandledResponse"); _invalidAuthenticationRequestUrl = LoggerMessage.Define( - eventId: 8, + eventId: new EventId(8, "InvalidAuthenticationRequestUrl"), logLevel: LogLevel.Warning, formatString: "The redirect URI is not well-formed. The URI is: '{AuthenticationRequestUrl}'."); _enteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync = LoggerMessage.Define( - eventId: 9, + eventId: new EventId(9, "EnteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync"), logLevel: LogLevel.Trace, formatString: "Entering {OpenIdConnectHandlerType}'s HandleRemoteAuthenticateAsync."); _nullOrEmptyAuthorizationResponseState = LoggerMessage.Define( - eventId: 10, + eventId: new EventId(10, "NullOrEmptyAuthorizationResponseState"), logLevel: LogLevel.Debug, formatString: "message.State is null or empty."); _unableToReadAuthorizationResponseState = LoggerMessage.Define( - eventId: 11, + eventId: new EventId(11, "UnableToReadAuthorizationResponseState"), logLevel: LogLevel.Debug, formatString: "Unable to read the message.State."); _responseError = LoggerMessage.Define( - eventId: 12, + eventId: new EventId(12, "ResponseError"), logLevel: LogLevel.Error, formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}'."); _responseErrorWithStatusCode = LoggerMessage.Define( - eventId: 49, + eventId: new EventId(52, "ResponseErrorWithStatusCode"), logLevel: LogLevel.Error, formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}', status code '{StatusCode}'."); _updatingConfiguration = LoggerMessage.Define( - eventId: 13, + eventId: new EventId(13, "UpdatingConfiguration"), logLevel: LogLevel.Debug, formatString: "Updating configuration"); _tokenValidatedHandledResponse = LoggerMessage.Define( - eventId: 15, + eventId: new EventId(15, "TokenValidatedHandledResponse"), logLevel: LogLevel.Debug, formatString: "TokenValidated.HandledResponse"); _tokenValidatedSkipped = LoggerMessage.Define( - eventId: 16, + eventId: new EventId(16, "TokenValidatedSkipped"), logLevel: LogLevel.Debug, formatString: "TokenValidated.Skipped"); _exceptionProcessingMessage = LoggerMessage.Define( - eventId: 17, + eventId: new EventId(17, "ExceptionProcessingMessage"), logLevel: LogLevel.Error, formatString: "Exception occurred while processing message."); _configurationManagerRequestRefreshCalled = LoggerMessage.Define( - eventId: 18, + eventId: new EventId(18, "ConfigurationManagerRequestRefreshCalled"), logLevel: LogLevel.Debug, formatString: "Exception of type 'SecurityTokenSignatureKeyNotFoundException' thrown, Options.ConfigurationManager.RequestRefresh() called."); _redeemingCodeForTokens = LoggerMessage.Define( - eventId: 19, + eventId: new EventId(19, "RedeemingCodeForTokens"), logLevel: LogLevel.Debug, formatString: "Redeeming code for tokens."); _retrievingClaims = LoggerMessage.Define( - eventId: 20, + eventId: new EventId(20, "RetrievingClaims"), logLevel: LogLevel.Trace, formatString: "Retrieving claims from the user info endpoint."); _receivedIdToken = LoggerMessage.Define( - eventId: 21, + eventId: new EventId(21, "ReceivedIdToken"), logLevel: LogLevel.Debug, formatString: "Received 'id_token'"); _userInfoEndpointNotSet = LoggerMessage.Define( - eventId: 22, + eventId: new EventId(22, "UserInfoEndpointNotSet"), logLevel: LogLevel.Debug, formatString: "UserInfoEndpoint is not set. Claims cannot be retrieved."); _unableToProtectNonceCookie = LoggerMessage.Define( - eventId: 23, + eventId: new EventId(23, "UnableToProtectNonceCookie"), logLevel: LogLevel.Warning, formatString: "Failed to un-protect the nonce cookie."); _messageReceived = LoggerMessage.Define( - eventId: 24, + eventId: new EventId(24, "MessageReceived"), logLevel: LogLevel.Trace, formatString: "MessageReceived: '{RedirectUrl}'."); _messageReceivedContextHandledResponse = LoggerMessage.Define( - eventId: 25, + eventId: new EventId(25, "MessageReceivedContextHandledResponse"), logLevel: LogLevel.Debug, formatString: "MessageReceivedContext.HandledResponse"); _messageReceivedContextSkipped = LoggerMessage.Define( - eventId: 26, + eventId: new EventId(26, "MessageReceivedContextSkipped"), logLevel: LogLevel.Debug, formatString: "MessageReceivedContext.Skipped"); _authorizationCodeReceived = LoggerMessage.Define( - eventId: 27, + eventId: new EventId(27, "AuthorizationCodeReceived"), logLevel: LogLevel.Trace, formatString: "Authorization code received."); _authorizationCodeReceivedContextHandledResponse = LoggerMessage.Define( - eventId: 28, + eventId: new EventId(28, "AuthorizationCodeReceivedContextHandledResponse"), logLevel: LogLevel.Debug, formatString: "AuthorizationCodeReceivedContext.HandledResponse"); _authorizationCodeReceivedContextSkipped = LoggerMessage.Define( - eventId: 29, + eventId: new EventId(29, "AuthorizationCodeReceivedContextSkipped"), logLevel: LogLevel.Debug, formatString: "AuthorizationCodeReceivedContext.Skipped"); _tokenResponseReceived = LoggerMessage.Define( - eventId: 30, + eventId: new EventId(30, "TokenResponseReceived"), logLevel: LogLevel.Trace, formatString: "Token response received."); _tokenResponseReceivedHandledResponse = LoggerMessage.Define( - eventId: 31, + eventId: new EventId(31, "TokenResponseReceivedHandledResponse"), logLevel: LogLevel.Debug, formatString: "TokenResponseReceived.HandledResponse"); _tokenResponseReceivedSkipped = LoggerMessage.Define( - eventId: 32, + eventId: new EventId(32, "TokenResponseReceivedSkipped"), logLevel: LogLevel.Debug, formatString: "TokenResponseReceived.Skipped"); _postSignOutRedirect = LoggerMessage.Define( - eventId: 33, + eventId: new EventId(33, "PostSignOutRedirect"), logLevel: LogLevel.Trace, formatString: "Using properties.RedirectUri for redirect post authentication: '{RedirectUri}'."); _userInformationReceived = LoggerMessage.Define( - eventId: 35, - logLevel: LogLevel.Trace, - formatString: "User information received: {User}"); + eventId: new EventId(35, "UserInformationReceived"), + logLevel: LogLevel.Trace, + formatString: "User information received: {User}"); _userInformationReceivedHandledResponse = LoggerMessage.Define( - eventId: 36, + eventId: new EventId(36, "UserInformationReceivedHandledResponse"), logLevel: LogLevel.Debug, formatString: "The UserInformationReceived event returned Handled."); _userInformationReceivedSkipped = LoggerMessage.Define( - eventId: 37, + eventId: new EventId(37, "UserInformationReceivedSkipped"), logLevel: LogLevel.Debug, formatString: "The UserInformationReceived event returned Skipped."); _authenticationFailedContextHandledResponse = LoggerMessage.Define( - eventId: 38, + eventId: new EventId(38, "AuthenticationFailedContextHandledResponse"), logLevel: LogLevel.Debug, formatString: "AuthenticationFailedContext.HandledResponse"); _authenticationFailedContextSkipped = LoggerMessage.Define( - eventId: 39, + eventId: new EventId(39, "AuthenticationFailedContextSkipped"), logLevel: LogLevel.Debug, formatString: "AuthenticationFailedContext.Skipped"); _invalidSecurityTokenType = LoggerMessage.Define( - eventId: 40, - logLevel: LogLevel.Error, - formatString: "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{SecurityTokenType}'"); + eventId: new EventId(40, "InvalidSecurityTokenType"), + logLevel: LogLevel.Error, + formatString: "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{SecurityTokenType}'"); _unableToValidateIdToken = LoggerMessage.Define( - eventId: 41, - logLevel: LogLevel.Error, - formatString: "Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); + eventId: new EventId(41, "UnableToValidateIdToken"), + logLevel: LogLevel.Error, + formatString: "Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); _accessTokenNotAvailable = LoggerMessage.Define( - eventId: 42, - logLevel: LogLevel.Debug, - formatString: "The access_token is not available. Claims cannot be retrieved."); + eventId: new EventId(42, "AccessTokenNotAvailable"), + logLevel: LogLevel.Debug, + formatString: "The access_token is not available. Claims cannot be retrieved."); _unableToReadIdToken = LoggerMessage.Define( - eventId: 43, - logLevel: LogLevel.Error, - formatString: "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); + eventId: new EventId(43, "UnableToReadIdToken"), + logLevel: LogLevel.Error, + formatString: "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'."); _remoteSignOutHandledResponse = LoggerMessage.Define( - eventId: 44, - logLevel: LogLevel.Debug, - formatString: "RemoteSignOutContext.HandledResponse"); + eventId: new EventId(44, "RemoteSignOutHandledResponse"), + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.HandledResponse"); _remoteSignOutSkipped = LoggerMessage.Define( - eventId: 45, - logLevel: LogLevel.Debug, - formatString: "RemoteSignOutContext.Skipped"); + eventId: new EventId(45, "RemoteSignOutSkipped"), + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.Skipped"); _remoteSignOut = LoggerMessage.Define( - eventId: 46, - logLevel: LogLevel.Information, - formatString: "Remote signout request processed."); + eventId: new EventId(46, "RemoteSignOut"), + logLevel: LogLevel.Information, + formatString: "Remote signout request processed."); _remoteSignOutSessionIdMissing = LoggerMessage.Define( - eventId: 47, - logLevel: LogLevel.Error, - formatString: "The remote signout request was ignored because the 'sid' parameter " + + eventId: new EventId(47, "RemoteSignOutSessionIdMissing"), + logLevel: LogLevel.Error, + formatString: "The remote signout request was ignored because the 'sid' parameter " + "was missing, which may indicate an unsolicited logout."); _remoteSignOutSessionIdInvalid = LoggerMessage.Define( - eventId: 48, - logLevel: LogLevel.Error, - formatString: "The remote signout request was ignored because the 'sid' parameter didn't match " + + eventId: new EventId(48, "RemoteSignOutSessionIdInvalid"), + logLevel: LogLevel.Error, + formatString: "The remote signout request was ignored because the 'sid' parameter didn't match " + "the expected value, which may indicate an unsolicited logout."); - _signOut = LoggerMessage.Define( - eventId: 49, - logLevel: LogLevel.Information, - formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); - _signoutCallbackRedirectHandledResponse = LoggerMessage.Define( - eventId: 50, + _authenticationSchemeSignedOut = LoggerMessage.Define( + eventId: new EventId(49, "AuthenticationSchemeSignedOut"), + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); + _signOutCallbackRedirectHandledResponse = LoggerMessage.Define( + eventId: new EventId(50, "SignOutCallbackRedirectHandledResponse"), logLevel: LogLevel.Debug, formatString: "RedirectToSignedOutRedirectUri.HandledResponse"); - _signoutCallbackRedirectSkipped = LoggerMessage.Define( - eventId: 51, + _signOutCallbackRedirectSkipped = LoggerMessage.Define( + eventId: new EventId(51, "SignOutCallbackRedirectSkipped"), logLevel: LogLevel.Debug, formatString: "RedirectToSignedOutRedirectUri.Skipped"); + + // EventId 52 is used by ResponseErrorWithStatusCode } public static void UpdatingConfiguration(this ILogger logger) @@ -355,14 +357,14 @@ namespace Microsoft.Extensions.Logging _redirectToIdentityProviderHandledResponse(logger, null); } - public static void SignoutCallbackRedirectHandledResponse(this ILogger logger) + public static void SignOutCallbackRedirectHandledResponse(this ILogger logger) { - _signoutCallbackRedirectHandledResponse(logger, null); + _signOutCallbackRedirectHandledResponse(logger, null); } - public static void SignoutCallbackRedirectSkipped(this ILogger logger) + public static void SignOutCallbackRedirectSkipped(this ILogger logger) { - _signoutCallbackRedirectSkipped(logger, null); + _signOutCallbackRedirectSkipped(logger, null); } public static void UserInformationReceivedHandledResponse(this ILogger logger) @@ -500,9 +502,9 @@ namespace Microsoft.Extensions.Logging _remoteSignOutSessionIdInvalid(logger, null); } - public static void SignedOut(this ILogger logger, string authenticationScheme) + public static void AuthenticationSchemeSignedOut(this ILogger logger, string authenticationScheme) { - _signOut(logger, authenticationScheme, null); + _authenticationSchemeSignedOut(logger, authenticationScheme, null); } } } diff --git a/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectHandler.cs b/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectHandler.cs index 8b0b72428a..dddb10dda5 100644 --- a/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectHandler.cs +++ b/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectHandler.cs @@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect throw new NotImplementedException($"An unsupported authentication method has been configured: {Options.AuthenticationMethod}"); } - Logger.SignedOut(Scheme.Name); + Logger.AuthenticationSchemeSignedOut(Scheme.Name); } /// @@ -276,12 +276,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { if (signOut.Result.Handled) { - Logger.SignoutCallbackRedirectHandledResponse(); + Logger.SignOutCallbackRedirectHandledResponse(); return true; } if (signOut.Result.Skipped) { - Logger.SignoutCallbackRedirectSkipped(); + Logger.SignOutCallbackRedirectSkipped(); return false; } if (signOut.Result.Failure != null) diff --git a/src/Security/Authentication/Twitter/src/LoggingExtensions.cs b/src/Security/Authentication/Twitter/src/LoggingExtensions.cs index 2a2cd5da79..69fdfe143e 100644 --- a/src/Security/Authentication/Twitter/src/LoggingExtensions.cs +++ b/src/Security/Authentication/Twitter/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -14,15 +14,15 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { _obtainRequestToken = LoggerMessage.Define( - eventId: 1, + eventId: new EventId(1, "ObtainRequestToken"), logLevel: LogLevel.Debug, formatString: "ObtainRequestToken"); _obtainAccessToken = LoggerMessage.Define( - eventId: 2, + eventId: new EventId(2, "ObtainAccessToken"), logLevel: LogLevel.Debug, formatString: "ObtainAccessToken"); _retrieveUserDetails = LoggerMessage.Define( - eventId: 3, + eventId: new EventId(3, "RetrieveUserDetails"), logLevel: LogLevel.Debug, formatString: "RetrieveUserDetails"); diff --git a/src/Security/Authentication/WsFederation/src/LoggingExtensions.cs b/src/Security/Authentication/WsFederation/src/LoggingExtensions.cs index e28b7e15b0..270dd6ffce 100644 --- a/src/Security/Authentication/WsFederation/src/LoggingExtensions.cs +++ b/src/Security/Authentication/WsFederation/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _signInWithoutWresult; + private static Action _signInWithoutWResult; private static Action _signInWithoutToken; private static Action _exceptionProcessingMessage; private static Action _malformedRedirectUri; @@ -17,39 +17,39 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { - _signInWithoutWresult = LoggerMessage.Define( - eventId: 1, + _signInWithoutWResult = LoggerMessage.Define( + eventId: new EventId(1, "SignInWithoutWResult"), logLevel: LogLevel.Debug, formatString: "Received a sign-in message without a WResult."); _signInWithoutToken = LoggerMessage.Define( - eventId: 2, + eventId: new EventId(2, "SignInWithoutToken"), logLevel: LogLevel.Debug, formatString: "Received a sign-in message without a token."); _exceptionProcessingMessage = LoggerMessage.Define( - eventId: 3, + eventId: new EventId(3, "ExceptionProcessingMessage"), logLevel: LogLevel.Error, formatString: "Exception occurred while processing message."); _malformedRedirectUri = LoggerMessage.Define( - eventId: 4, + eventId: new EventId(4, "MalformedRedirectUri"), logLevel: LogLevel.Warning, formatString: "The sign-out redirect URI '{0}' is malformed."); _remoteSignOutHandledResponse = LoggerMessage.Define( - eventId: 5, + eventId: new EventId(5, "RemoteSignOutHandledResponse"), logLevel: LogLevel.Debug, formatString: "RemoteSignOutContext.HandledResponse"); _remoteSignOutSkipped = LoggerMessage.Define( - eventId: 6, + eventId: new EventId(6, "RemoteSignOutSkipped"), logLevel: LogLevel.Debug, formatString: "RemoteSignOutContext.Skipped"); _remoteSignOut = LoggerMessage.Define( - eventId: 7, + eventId: new EventId(7, "RemoteSignOut"), logLevel: LogLevel.Information, formatString: "Remote signout request processed."); } - public static void SignInWithoutWresult(this ILogger logger) + public static void SignInWithoutWResult(this ILogger logger) { - _signInWithoutWresult(logger, null); + _signInWithoutWResult(logger, null); } public static void SignInWithoutToken(this ILogger logger) diff --git a/src/Security/Authentication/WsFederation/src/WsFederationHandler.cs b/src/Security/Authentication/WsFederation/src/WsFederationHandler.cs index c4bb8fff74..6e1f59a44f 100644 --- a/src/Security/Authentication/WsFederation/src/WsFederationHandler.cs +++ b/src/Security/Authentication/WsFederation/src/WsFederationHandler.cs @@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Authentication.WsFederation if (wsFederationMessage.Wresult == null) { - Logger.SignInWithoutWresult(); + Logger.SignInWithoutWResult(); return HandleRequestResult.Fail(Resources.SignInMessageWresultIsMissing, properties); } diff --git a/src/Security/Authorization/Core/src/LoggingExtensions.cs b/src/Security/Authorization/Core/src/LoggingExtensions.cs index 386df85e09..e31d88161d 100644 --- a/src/Security/Authorization/Core/src/LoggingExtensions.cs +++ b/src/Security/Authorization/Core/src/LoggingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -13,11 +13,11 @@ namespace Microsoft.Extensions.Logging static LoggingExtensions() { _userAuthorizationSucceeded = LoggerMessage.Define( - eventId: 1, + eventId: new EventId(1, "UserAuthorizationSucceeded"), logLevel: LogLevel.Information, formatString: "Authorization was successful."); _userAuthorizationFailed = LoggerMessage.Define( - eventId: 2, + eventId: new EventId(2, "UserAuthorizationFailed"), logLevel: LogLevel.Information, formatString: "Authorization failed."); }