Example #1
0
        public override void ConfigureServices(IServiceCollection services)
        {
            var connectionString = _configuration.GetValue <string>("OrchardCore.DataProtection.Azure:ConnectionString");

            if (!string.IsNullOrWhiteSpace(connectionString))
            {
                services.AddDataProtection().PersistKeysToAzureBlobStorage(GetBlobContainer(connectionString), GetBlobName());
            }
            else
            {
                _logger.LogCritical("No connection string was supplied for OrchardCore.DataProtection.Azure. Ensure that an application setting containing a valid Azure Storage connection string is available at `Modules:OrchardCore.DataProtection.Azure:ConnectionString`.");
            }
        }
Example #2
0
        public override void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions <AzureQueueOptions>();
            var connectionString = _shellConfiguration.GetValue("ThisNetWorks_OrchardCore_Azure_Queues:ConnectionString", String.Empty);
            var createQueues     = _shellConfiguration.GetValue("ThisNetWorks_OrchardCore_Azure_Queues:CreateQueues", false);

            services.Configure <AzureQueueOptions>(x => {
                x.ConnectionString = connectionString;
                x.CreateQueues     = createQueues;
            });

            services.AddSingleton <IAzureQueueService, AzureQueueService>();
            services.AddSingleton <IAzureQueueResolver, AzureQueueResolver>();
            services.AddScoped <IModularTenantEvents, CreateQueuesEvent>();
        }
Example #3
0
        public override void ConfigureServices(IServiceCollection services)
        {
            services.Configure <TemplateOptions>(o =>
            {
                o.MemberAccessStrategy.Register <MarkdownBodyPartViewModel>();
                o.MemberAccessStrategy.Register <MarkdownFieldViewModel>();
            })
            .AddLiquidFilter <Markdownify>("markdownify");

            // Markdown Part
            services.AddContentPart <MarkdownBodyPart>()
            .UseDisplayDriver <MarkdownBodyPartDisplayDriver>()
            .AddHandler <MarkdownBodyPartHandler>();

            services.AddScoped <IContentTypePartDefinitionDisplayDriver, MarkdownBodyPartSettingsDisplayDriver>();
            services.AddScoped <IDataMigration, Migrations>();
            services.AddScoped <IContentPartIndexHandler, MarkdownBodyPartIndexHandler>();

            // Markdown Field
            services.AddContentField <MarkdownField>()
            .UseDisplayDriver <MarkdownFieldDisplayDriver>();

            services.AddScoped <IContentPartFieldDefinitionDisplayDriver, MarkdownFieldSettingsDriver>();
            services.AddScoped <IContentFieldIndexHandler, MarkdownFieldIndexHandler>();

            services.AddOptions <MarkdownPipelineOptions>();
            services.ConfigureMarkdownPipeline((pipeline) =>
            {
                var extensions = _shellConfiguration.GetValue("OrchardCore_Markdown:Extensions", DefaultMarkdownExtensions);
                pipeline.Configure(extensions);
            });

            services.AddScoped <IMarkdownService, DefaultMarkdownService>();
        }
Example #4
0
        public override void Configure(IApplicationBuilder app, IRouteBuilder routes, IServiceProvider serviceProvider)
        {
            var exposeExceptions = _configuration.GetValue(
                $"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.ExposeExceptions)}",
                _hostingEnvironment.IsDevelopment());

            app.UseMiddleware <GraphQLMiddleware>(new GraphQLSettings
            {
                BuildUserContext = ctx => new GraphQLContext
                {
                    User            = ctx.User,
                    ServiceProvider = ctx.RequestServices,
                },
                ExposeExceptions = exposeExceptions
            });
        }
Example #5
0
        public override void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IDependencyResolver, RequestServicesDependencyResolver>();
            services.AddSingleton <IDocumentExecuter, SerialDocumentExecuter>();
            services.AddSingleton <IDocumentWriter, DocumentWriter>();
            services.AddSingleton <ISchemaFactory, SchemaService>();
            services.AddScoped <IValidationRule, MaxNumberOfResultsValidationRule>();

            services.AddScoped <IPermissionProvider, Permissions>();
            services.AddTransient <INavigationProvider, AdminMenu>();

            services.AddOptions <GraphQLSettings>().Configure(c =>
            {
                var exposeExceptions = _configuration.GetValue(
                    $"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.ExposeExceptions)}",
                    _hostingEnvironment.IsDevelopment());

                var maxNumberOfResultsValidationMode = _configuration.GetValue <MaxNumberOfResultsValidationMode?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxNumberOfResultsValidationMode)}")
                                                       ?? MaxNumberOfResultsValidationMode.Default;

                if (maxNumberOfResultsValidationMode == MaxNumberOfResultsValidationMode.Default)
                {
                    maxNumberOfResultsValidationMode = _hostingEnvironment.IsDevelopment() ? MaxNumberOfResultsValidationMode.Enabled : MaxNumberOfResultsValidationMode.Disabled;
                }

                c.BuildUserContext = ctx => new GraphQLContext
                {
                    HttpContext     = ctx,
                    User            = ctx.User,
                    ServiceProvider = ctx.RequestServices,
                };
                c.ExposeExceptions   = exposeExceptions;
                c.MaxDepth           = _configuration.GetValue <int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxDepth)}") ?? 20;
                c.MaxComplexity      = _configuration.GetValue <int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxComplexity)}");
                c.FieldImpact        = _configuration.GetValue <int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.FieldImpact)}");
                c.MaxNumberOfResults = _configuration.GetValue <int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxNumberOfResults)}") ?? 1000;
                c.MaxNumberOfResultsValidationMode = maxNumberOfResultsValidationMode;
                c.DefaultNumberOfResults           = _configuration.GetValue <int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.DefaultNumberOfResults)}") ?? 100;
            });
        }
Example #6
0
 public ConfigurationMethodProvider(IShellConfiguration configuration)
 {
     _globalMethod = new GlobalMethod
     {
         Name   = "configuration",
         Method = serviceprovider => (Func <string, object, object>)((key, defaultValue) => configuration.GetValue <object>(key, defaultValue))
     };
 }
        public override void ConfigureServices(IServiceCollection services)
        {
            var swaggerUiClientSecret = _shellConfiguration.GetValue <string>("SwaggerUiClientSecret");

            services.AddContentPart <SamplePart>()
            .UseDisplayDriver <SamplePartDisplayDriver>()
            .AddHandler <SamplePartHandler>();

            services.AddScoped <IContentPartDefinitionDisplayDriver, SamplePartSettingsDisplayDriver>();
            services.AddScoped <IDataMigration, Migrations>();

            services.Configure <OpenApiOptions>(o =>
            {
                // This only includes fields that are used in parts.
                o.ContentTypes.IncludeAllFields = false;

                // This is a sample of how to use OpenID Connect with OpenAPI.
                o.Middleware.GeneratorOptions.Add((generator, serviceProvider) =>
                {
                    generator.AddSecurity("bearer", Enumerable.Empty <string>(), new OpenApiSecurityScheme
                    {
                        Type        = OpenApiSecuritySchemeType.OAuth2,
                        Description = "OpenID Connect",
                        Flow        = OpenApiOAuth2Flow.AccessCode,
                        Flows       = new OpenApiOAuthFlows()
                        {
                            AuthorizationCode = new OpenApiOAuthFlow()
                            {
                                Scopes = new Dictionary <string, string>
                                {
                                    { "openid", "OpenID" },
                                    { "profile", "Profile" },
                                    { "roles", "Roles" }
                                },
                                AuthorizationUrl = "/connect/authorize",
                                TokenUrl         = "/connect/token"
                            },
                        }
                    });
                    generator.OperationProcessors.Add(
                        new AspNetCoreOperationSecurityScopeProcessor("bearer"));
                });
                o.Middleware.SwaggerUi3Settings = (swagger) =>
                {
                    swagger.OAuth2Client = new OAuth2ClientSettings
                    {
                        ClientId     = "openapi_auth_code_flow",
                        ClientSecret = swaggerUiClientSecret
                    };
                };
            });

            services.Configure <GraphQLContentOptions>(o =>
            {
                // Because there is an extra field added to this part, and an issue with duplicate fields
                // TODO remove when issue resolved.
                o.ConfigurePart <HtmlBodyPart>(part =>
                {
                    part.Hidden = true;
                });
            });
        }