// Token: 0x06001439 RID: 5177 RVA: 0x0004A0D8 File Offset: 0x000482D8 private void OnAuthenticateRequest(object source, EventArgs e) { ExTraceGlobals.AccessCheckTracer.TraceDebug(0L, "Start OnAuthenticateRequest"); HttpApplication httpApplication = (HttpApplication)source; HttpContext context = httpApplication.Context; UserToken userToken = context.CurrentUserToken(); if (this.IsDelegatedAuth(context)) { ExTraceGlobals.AccessCheckTracer.TraceDebug(0L, "Delegated auth, let delegated auth module handle the request"); } else { if (context.Request.IsAuthenticated && userToken.HasCommonAccessToken) { try { if (userToken.HasCommonAccessToken && ProxySecurityContextModule.AuthenticationTypes.ContainsKey(userToken.AuthenticationType)) { string text = ProxySecurityContextModule.AuthenticationTypes[userToken.AuthenticationType]; if (context.User != null && context.User.Identity != null) { context.Items["AuthType"] = context.User.Identity.AuthenticationType; if (!context.Items.Contains("AuthenticatedUser")) { context.Items["AuthenticatedUser"] = context.User.Identity.Name; } else { HttpLogger.SafeAppendGenericInfo("User.Identity", context.User.Identity.Name); } } ExTraceGlobals.AccessCheckTracer.TraceDebug <AuthenticationType, string>(0L, "Token Type = {0}, AuthenticationType = {1}.", userToken.AuthenticationType, text); ExAssert.RetailAssert(context.User != null && context.User.Identity != null && context.User.Identity.Name != null, "HttpContext.User.Identity.Name should not be null."); GenericIdentity identity = new GenericIdentity(context.User.Identity.Name.ToLower(), text); context.User = new GenericPrincipal(identity, new string[0]); ProxySecurityContextModule.SendAuthenticationDataToWinRM(context, userToken); } goto IL_201; } catch (Exception ex) { HttpModuleHelper.EndPowerShellRequestWithFriendlyError(context, FailureCategory.ProxySecurityContext, "Exception", ex.ToString(), "ProxySecurityContextModule", KnownException.IsUnhandledException(ex)); goto IL_201; } } ExTraceGlobals.AccessCheckTracer.TraceDebug(0L, "Request is Unauthorized."); WinRMInfo.SetFailureCategoryInfo(context.Response.Headers, FailureCategory.ProxySecurityContext, "Unauthorized"); context.Response.StatusCode = 401; httpApplication.CompleteRequest(); } IL_201: ExTraceGlobals.AccessCheckTracer.TraceDebug(0L, "Exit OnAuthenticateRequest"); }
private void ThrottleRequest(HttpContext context) { ExTraceGlobals.HttpModuleTracer.TraceFunction((long)this.GetHashCode(), "[ThrottlingHttpModule::ThrottleRequest] Enter"); WinRMInfo winRMInfo = context.Items["X-RemotePS-WinRMInfo"] as WinRMInfo; if (winRMInfo == null) { ExTraceGlobals.HttpModuleTracer.TraceDebug((long)this.GetHashCode(), "[ThrottlingHttpModule::ThrottleRequest] WinRMInfo = null."); return; } string action = winRMInfo.Action; if (string.IsNullOrEmpty(action)) { ExTraceGlobals.HttpModuleTracer.TraceDebug((long)this.GetHashCode(), "[ThrottlingHttpModule::ThrottleRequest] WinRMInfo.Action = null."); return; } if (!action.EndsWith(":Command", StringComparison.OrdinalIgnoreCase) && !action.Equals("Command", StringComparison.OrdinalIgnoreCase)) { ExTraceGlobals.HttpModuleTracer.TraceDebug <string>((long)this.GetHashCode(), "[ThrottlingHttpModule::ThrottleRequest] Not Command Request. WinRMInfo.Action = {0}.", action); return; } IPowerShellBudget powerShellBudget = null; OverBudgetException ex = null; try { try { using (new MonitoredScope("ThrottlingHttpModule", "GetBudget", HttpModuleHelper.HttpPerfMonitors)) { powerShellBudget = this.GetBudget(context); } if (powerShellBudget == null) { ExTraceGlobals.HttpModuleTracer.TraceDebug((long)this.GetHashCode(), "[ThrottlingHttpModule::ThrottleRequest] budget = null."); return; } using (new MonitoredScope("ThrottlingHttpModule", "CheckBudgetAndStartCmdlet", HttpModuleHelper.HttpPerfMonitors)) { powerShellBudget.StartCmdlet(null); powerShellBudget.TryCheckOverBudget(CostType.CMDLET, out ex); } } finally { if (powerShellBudget != null) { powerShellBudget.Dispose(); } } if (ex != null) { string windowsLiveId = context.CurrentUserToken().WindowsLiveId; if (windowsLiveId != null) { FailFastUserCache.Instance.AddUserToCache(windowsLiveId, BlockedType.NewRequest, TimeSpan.Zero); HttpLogger.SafeAppendColumn(RpsCommonMetadata.ContributeToFailFast, "AuthZ-UserSelf", LoggerHelper.GetContributeToFailFastValue("User", windowsLiveId, BlockedType.NewRequest.ToString(), -1.0)); } HttpModuleHelper.EndPowerShellRequestWithFriendlyError(context, FailureCategory.AuthZ, ex.GetType().Name, Strings.ErrorOperationTarpitting(ex.BackoffTime / 1000) + string.Format("{2}Policy: {0}; {2}Snapshot: {1}", ex.ThrottlingPolicyDN, ex.Snapshot, Environment.NewLine), "ThrottlingHttpModule", false); } } catch (Exception ex2) { if (!(ex2 is ThreadAbortException)) { HttpLogger.SafeAppendGenericError("ThrottlingHttpModule", ex2, new Func <Exception, bool>(KnownException.IsUnhandledException)); ExTraceGlobals.HttpModuleTracer.TraceError <Exception>((long)this.GetHashCode(), "[ThrottlingHttpModule::ThrottleRequest] Get un-Excpected Exception. {0}", ex2); } } }