Пример #1
0
        private void UpdateWarning()
        {
            var isSessionElevated = SessionElevationManager.IsSessionTokenElevated(ApplicationNames.Console);

            var controlContent = string.Empty;
            var hidePanel      = false;
            var tokenAction    = SessionElevationManager.GetToken(ApplicationNames.Console).Action;

            switch (tokenAction)
            {
            case (SessionElevationManager.TokenDefinition.ElevationAction.Allow):
                // it is always elevated
                hidePanel = true;
                break;

            case (SessionElevationManager.TokenDefinition.ElevationAction.Password):
                // show that session elevation can be dropped
                controlContent = HtmlUtil.RenderControl(isSessionElevated ? ElevatedPanel : ElevationRequiredPanel);
                break;

            case (SessionElevationManager.TokenDefinition.ElevationAction.Block):
                controlContent = HtmlUtil.RenderControl(ElevationBlockedPanel);
                break;
            }

            InfoPanel.InnerHtml = controlContent;
            InfoPanel.Visible   = !hidePanel;
            SheerResponse.Eval($"cognifide.powershell.showInfoPanel({(!hidePanel).ToString().ToLower()});");
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (Sitecore.Context.ClientPage.IsEvent)
            {
                return;
            }
            AppName = WebUtil.GetQueryString("app");
            var actionName = WebUtil.GetQueryString("action");

            if (string.IsNullOrEmpty(actionName))
            {
                actionName = SessionElevationManager.ExecuteAction;
            }
            UserName.Text = Sitecore.Context.User?.Name ?? string.Empty;
            HttpContext.Current.Response.AddHeader("X-UA-Compatible", "IE=edge");
            DialogDescription.Text    = Translate.Text(DialogDescription.Text, actionName);
            DialogMessage.Text        = Translate.Text(DialogMessage.Text, actionName);
            DialogMessageConfirm.Text = Translate.Text(DialogMessageConfirm.Text, actionName);

            var tokenAction = SessionElevationManager.GetToken(AppName).Action;

            if (tokenAction == SessionElevationManager.TokenDefinition.ElevationAction.Confirm)
            {
                PasswordLabel.Visible        = false;
                PasswordBox.Visible          = false;
                DialogMessage.Visible        = false;
                DialogMessageConfirm.Visible = true;
            }
        }
Пример #3
0
        private void UpdateWarning(string updateFromMessage = "")
        {
            var isSessionElevated = SessionElevationManager.IsSessionTokenElevated(ApplicationNames.ISE);

            var controlContent = string.Empty;
            var hidePanel      = false;
            var tokenAction    = SessionElevationManager.GetToken(ApplicationNames.ISE).Action;

            switch (tokenAction)
            {
            case SessionElevationManager.TokenDefinition.ElevationAction.Allow:
                // it is always elevated
                hidePanel = true;
                break;

            case SessionElevationManager.TokenDefinition.ElevationAction.Password:
            case SessionElevationManager.TokenDefinition.ElevationAction.Confirm:
                // show that session elevation can be dropped
                if (isSessionElevated)
                {
                    controlContent = HtmlUtil.RenderControl(ElevatedPanel);
                }
                else
                {
                    if (WasElevated)
                    {
                        // we're cool devs know that session will need to be elevated.
                        hidePanel = true;
                    }
                    else
                    {
                        controlContent = HtmlUtil.RenderControl(ElevationRequiredPanel);
                    }
                }
                break;

            case SessionElevationManager.TokenDefinition.ElevationAction.Block:
                controlContent = HtmlUtil.RenderControl(ElevationBlockedPanel);
                break;
            }

            InfoPanel.InnerHtml = controlContent;
            InfoPanel.Visible   = !hidePanel;
            SheerResponse.Eval($"spe.showInfoPanel({(!hidePanel).ToString().ToLower()}, '{updateFromMessage}');");
        }
Пример #4
0
        protected void OkClick()
        {
            var validateUser = true;
            var tokenAction  = SessionElevationManager.GetToken(AppName).Action;

            if (tokenAction == SessionElevationManager.TokenDefinition.ElevationAction.Confirm)
            {
                validateUser = false;
            }

            if (!validateUser || Membership.ValidateUser(Sitecore.Context.User?.Name ?? string.Empty, PasswordBox.Value))
            {
                SessionElevationManager.ElevateSessionToken(AppName);
                SheerResponse.CloseWindow();
            }
            else
            {
                SheerResponse.Alert(Texts.PowerShellSessionElevation_Could_not_validate);
            }
        }
Пример #5
0
        protected virtual void ElevateSession(ClientPipelineArgs args)
        {
            var isSessionElevated = SessionElevationManager.IsSessionTokenElevated(ApplicationNames.Console);
            var tokenAction       = SessionElevationManager.GetToken(ApplicationNames.Console).Action;

            if (!isSessionElevated)
            {
                if (tokenAction == SessionElevationManager.TokenDefinition.ElevationAction.Block)
                {
                    SheerResponse.Eval(@"$ise(function() { cognifide.powershell.bootstrap(true); });");
                }
                else
                {
                    Context.ClientPage.Start(this, nameof(SessionElevationPipeline));
                }
            }
            else
            {
                SheerResponse.Eval(@"$ise(function() { cognifide.powershell.bootstrap(false); });");
            }
        }