コード例 #1
0
        private static IFluentCspOptions UseCspSandbox(this IFluentCspOptions configurer, WebOptions.HostingOptions.CspOptions.CspDirectiveSandbox cspDirectiveSandbox)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            if (cspDirectiveSandbox == null)
            {
                throw new ArgumentNullException(nameof(cspDirectiveSandbox));
            }

            if (!cspDirectiveSandbox.IsEnabled)
            {
                return(configurer);
            }

            configurer
            .Sandbox(y =>
            {
                if (cspDirectiveSandbox.AllowForms)
                {
                    y.AllowForms();
                }

                if (cspDirectiveSandbox.AllowModals)
                {
                    y.AllowModals();
                }

                if (cspDirectiveSandbox.AllowOrientationLock)
                {
                    y.AllowOrientationLock();
                }

                if (cspDirectiveSandbox.AllowPointerLock)
                {
                    y.AllowPointerLock();
                }

                if (cspDirectiveSandbox.AllowPopups)
                {
                    y.AllowPopups();
                }

                if (cspDirectiveSandbox.AllowPopupsToEscapeSandbox)
                {
                    y.AllowPopupsToEscapeSandbox();
                }

                if (cspDirectiveSandbox.AllowPresentation)
                {
                    y.AllowPresentation();
                }

                if (cspDirectiveSandbox.AllowSameOrigin)
                {
                    y.AllowSameOrigin();
                }

                if (cspDirectiveSandbox.AllowScripts)
                {
                    y.AllowScripts();
                }

                if (cspDirectiveSandbox.AllowTopNavigation)
                {
                    y.AllowTopNavigation();
                }
            });

            return(configurer);
        }