public static CmsBuilder ConfigureSiaSkynet(this CmsBuilder builder, Func <StorageConfiguration> storageConfigFunc)
        {
            var services      = builder.Services;
            var Configuration = builder.Configuration;

            services.Configure <SkynetConfig>(Configuration.GetSection(nameof(SkynetConfig)));

            StorageConfiguration storageConfig = storageConfigFunc();

            if (storageConfig.ReadFiles)
            {
                services.AddTransient <IReadFile, CmsFileStorageService>();
            }
            if (storageConfig.WriteFiles)
            {
                services.AddTransient <IWriteFile, CmsFileStorageService>();
            }
            if (storageConfig.ReadCmsItems)
            {
                services.AddSingleton <IReadCmsItem, CmsItemStorageService>();
            }
            if (storageConfig.WriteCmsItems)
            {
                services.AddSingleton <IWriteCmsItem, CmsItemStorageService>();
            }

            return(builder);
        }
Example #2
0
        public static CmsBuilder UseJsonEditor(this CmsBuilder builder)
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            return(builder);
        }
        public static CmsBuilder ConfigureCosmosDB(this CmsBuilder builder, Func <StorageConfiguration> storageConfigFunc)
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            services.Configure <CosmosConfig>(Configuration.GetSection(nameof(CosmosConfig)));

            StorageConfiguration storageConfig = storageConfigFunc();

            services.AddTransient <CosmosService>();

            if (storageConfig.ReadCmsItems)
            {
                services.AddTransient <IReadCmsItem, CosmosWrapperService>();
            }
            if (storageConfig.WriteCmsItems)
            {
                services.AddTransient <IWriteCmsItem, CosmosWrapperService>();
            }

            var cosmosConfig = new CosmosConfig();

            Configuration.GetSection(nameof(CosmosConfig)).Bind(cosmosConfig);
            var cosmosConfigOptions = Options.Create <CosmosConfig>(cosmosConfig);

            var cosmosService = new CosmosService(cosmosConfigOptions, Options.Create(new CmsConfiguration()));

            cosmosService.InitializeContainer();

            return(builder);
        }
Example #4
0
        public static CmsBuilder ConfigureDynamicDataCmsAuthAzureAD(this CmsBuilder builder)
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            // Enable cookie authentication
            //services.AddMicrosoftIdentityWebAppAuthentication(Configuration);
            services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
            .AddMicrosoftIdentityWebApp(options =>
            {
                Configuration.Bind("AzureAD", options);
                options.Events ??= new OpenIdConnectEvents();
                options.Events.OnTokenValidated += OnTokenValidatedFunc;
            });

            services.AddHttpContextAccessor();

            //Add CmsUser to CmsConfiguration
            services.PostConfigure <CmsConfiguration>(x =>
            {
                var userSchema = JsonSchema.FromType(typeof(CmsUser), new NJsonSchema.Generation.JsonSchemaGeneratorSettings()
                {
                    //AllowReferencesWithProperties = true,
                    //AlwaysAllowAdditionalObjectProperties = true,
                    DefaultReferenceTypeNullHandling = NJsonSchema.Generation.ReferenceTypeNullHandling.NotNull,
                    GenerateAbstractProperties       = true,
                    FlattenInheritanceHierarchy      = true,
                });

                x.Schemas.Add(new SchemaLocation
                {
                    Key    = CmsUser.DefaultCmsSchemaType.ToString(),
                    Schema = userSchema.ToJson(),
                });

                x.MenuGroups.Add(new MenuGroup()
                {
                    Name      = "CMS",
                    MenuItems = new System.Collections.Generic.List <MenuItem>()
                    {
                        new MenuItem()
                        {
                            Key                = CmsUser.DefaultCmsType.ToString(),
                            SchemaKey          = CmsUser.DefaultCmsSchemaType.ToString(),
                            ListViewProperties = new List <ListViewProperty>()
                            {
                                new ListViewProperty()
                                {
                                    DisplayName = nameof(CmsUser.Email), Key = nameof(CmsUser.Email)
                                }
                            },
                            Name = "Users",
                        }
                    }
                });
            });

            return(builder);
        }
        public static CmsBuilder UseDynamicDataCMS(this IServiceCollection services, IConfiguration configuration)
        {
            var builder = new CmsBuilder(services, configuration)
                          .ConfigureCoreCms()
                          .ConfigureDynamicDataCmsServices();

            return(builder);
        }
        public static CmsBuilder ConfigureDynamicDataCmsAuthBasic(this CmsBuilder builder)
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            // Enable cookie authentication
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(x => x.LoginPath = "/auth/login");

            services.AddHttpContextAccessor();

            builder.AddInterceptor <EncryptPasswordInterceptor>();

            //Add CmsUser to CmsConfiguration
            services.PostConfigure <CmsConfiguration>(x =>
            {
                var userSchema = JsonSchema.FromType(typeof(CmsUser), new NJsonSchema.Generation.JsonSchemaGeneratorSettings()
                {
                    //AllowReferencesWithProperties = true,
                    //AlwaysAllowAdditionalObjectProperties = true,
                    DefaultReferenceTypeNullHandling = NJsonSchema.Generation.ReferenceTypeNullHandling.NotNull,
                    GenerateAbstractProperties       = true,
                    FlattenInheritanceHierarchy      = true,
                });
                userSchema.Properties[nameof(CmsUser.Password)].Format = "password";
                userSchema.Properties.Remove(nameof(CmsUser.PasswordEncrypted));

                x.Schemas.Add(new SchemaLocation
                {
                    Key    = CmsUser.DefaultCmsSchemaType.ToString(),
                    Schema = userSchema.ToJson(),
                });

                x.MenuGroups.Add(new MenuGroup()
                {
                    Name      = "CMS",
                    MenuItems = new System.Collections.Generic.List <MenuItem>()
                    {
                        new MenuItem()
                        {
                            Key                = CmsUser.DefaultCmsType.ToString(),
                            SchemaKey          = CmsUser.DefaultCmsSchemaType.ToString(),
                            ListViewProperties = new List <ListViewProperty>()
                            {
                                new ListViewProperty()
                                {
                                    DisplayName = nameof(CmsUser.Email), Key = nameof(CmsUser.Email)
                                }
                            },
                            Name = "Users",
                        }
                    }
                });
            });

            return(builder);
        }
        public static CmsBuilder ConfigureCoreCms(this CmsBuilder builder)
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            services.AddHttpClient();

            return(builder);
        }
        public static CmsBuilder ConfigureEntityFramework <Context, Model>(this CmsBuilder builder) where Context : DbContext where Model : class
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            services.AddTransient <IReadCmsItem, DatabaseService <Context, Model> >();
            services.AddTransient <IWriteCmsItem, DatabaseService <Context, Model> >();

            return(builder);
        }
Example #9
0
        public static CmsBuilder ConfigureMicrio(this CmsBuilder builder)
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            services.Configure <MicrioConfig>(Configuration.GetSection(nameof(MicrioConfig)));

            //Add micrio script to CmsConfiguration.EditScripts
            services.PostConfigure <CmsConfiguration>(x =>
            {
                x.EditScripts.Add("/_content/DynamicDataCMS.Module.Micrio/qms.micrio.js");
            });

            return(builder);
        }
        public static CmsBuilder ConfigureIpfs(this CmsBuilder builder, Func <StorageConfiguration> storageConfigFunc)
        {
            var services      = builder.Services;
            var Configuration = builder.Configuration;

            services.Configure <IpfsConfig>(Configuration.GetSection(nameof(IpfsConfig)));

            StorageConfiguration storageConfig = storageConfigFunc();

            if (storageConfig.ReadFiles)
            {
                services.AddTransient <IReadFile, CmsFileStorageService>();
            }
            if (storageConfig.WriteFiles)
            {
                services.AddTransient <IWriteFile, CmsFileStorageService>();
            }

            return(builder);
        }
Example #11
0
        public static CmsBuilder ConfigureDynamicDataCmsServices(this CmsBuilder builder, string cmsConfigFileName = "CmsConfiguration.json")
        {
            var Configuration = builder.Configuration;
            var services      = builder.Services;

            var cmsConfig = new ConfigurationBuilder()
                            //.SetBasePath(env.ContentRootPath)
                            .AddJsonFile(cmsConfigFileName)
                            .Build();

            //CmsConfiguration
            //services.Configure<CmsConfigLocation>(Configuration.GetSection(nameof(CmsConfigLocation)));
            services.Configure <CmsConfiguration>(cmsConfig);

            services.AddTransient <JsonSchemaService>();
            services.AddTransient <CmsTreeService>();
            services.AddTransient <ImageResizeService>();
            services.AddTransient <DataProviderWrapperService>();

            return(builder);
        }
Example #12
0
        public static CmsBuilder AddInterceptor <T>(this CmsBuilder builder) where T : class, IWriteCmsItemInterceptor
        {
            builder.Services.AddSingleton <IWriteCmsItemInterceptor, T>();

            return(builder);
        }
 public static CmsBuilder ConfigureSiaSkynet(this CmsBuilder builder)
 {
     return(builder.ConfigureSiaSkynet(() => new StorageConfiguration {
         WriteFiles = true, ReadFiles = true
     }));
 }