private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create connector instance using ConnectorBuilder. The call to LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory    = new OwinConnectorFactory();
            var connectorBuilder    = new ConnectorBuilder();
            var customAuthenticator = new CustomCKFinderAuthenticator();
            var connector           = connectorBuilder
                                      .LoadConfig()
                                      .SetRequestConfiguration(
                (request, config) =>
            {
                config.LoadConfig();
                var privateBackend = config.GetBackend("CKFinderPrivate");

                /*
                 * Create a key-value store provider to be used for saving CKFinder cache data.
                 */
                var keyValueStoreProvider = new FileSystemKeyValueStoreProvider(privateBackend);

                config.SetKeyValueStoreProvider(keyValueStoreProvider);
            })
                                      .SetAuthenticator(customAuthenticator)
                                      .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to web application pipeline.
             */
            app.UseConnector(connector);
        }
Beispiel #2
0
        private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create a connector instance using ConnectorBuilder. The call to the LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            /*
             * Create an instance of authenticator implemented in the previous step.
             */
            var customAuthenticator = new CustomCKFinderAuthenticator();

            connectorBuilder

            /*
             * Provide the global configuration.
             *
             * If you installed CKSource.CKFinder.Connector.Config you should load the static configuration
             * from XML:
             * connectorBuilder.LoadConfig();
             */
            .LoadConfig()
            .SetAuthenticator(customAuthenticator)
            .SetRequestConfiguration(
                (request, config) =>
            {
                // TODO: Do we need EntityFrameworkKeyValueStoreProvider?


                /*
                 *
                 * If you installed CKSource.CKFinder.Connector.KeyValue.EntityFramework, you may enable caching:
                 * config.SetKeyValueStoreProvider(
                 *     new EntityFrameworkKeyValueStoreProvider("CKFinderCacheConnection"));
                 */

                config.LoadConfig();
            }
                );

            /*
             * Build the connector middleware.
             */
            var connector = connectorBuilder
                            .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to the web application pipeline.
             */
            //app.Use(typeof(MyMiddleWare));
            app.UseConnector(connector);
        }
Beispiel #3
0
        private static void SetupConnector(IAppBuilder app)
        {
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            var customAuthenticator = new CKFinderAuthenticator();

            connectorBuilder
            .LoadConfig()
            .SetAuthenticator(customAuthenticator)
            .SetRequestConfiguration((request, config) => { config.LoadConfig(); });

            var connector = connectorBuilder.Build(connectorFactory);

            app.UseConnector(connector);
        }
Beispiel #4
0
        private static void SetupConnector(IAppBuilder builder)
        {
            var keyValueStoreProvider = new EntityFrameworkKeyValueStoreProvider("CacheConnectionString");
            var authenticator         = new ShaggysAuthenticator();

            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();
            var connector        = connectorBuilder
                                   .LoadConfig()
                                   .SetAuthenticator(authenticator)
                                   .SetRequestConfiguration(
                (request, config) =>
            {
                config.LoadConfig();
                config.SetKeyValueStoreProvider(keyValueStoreProvider);
            })
                                   .Build(connectorFactory);

            builder.UseConnector(connector);
        }
Beispiel #5
0
        private static void SetupConnector(IAppBuilder builder)
        {
            var keyValueStoreProvider = new EntityFrameworkKeyValueStoreProvider("CacheConnectionString");

            var allowedRoleMatcherTemplate = ConfigurationManager.AppSettings["ckfinderAllowedRole"];
            var authenticator = new RoleBasedAuthenticator(allowedRoleMatcherTemplate);

            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();
            var connector        = connectorBuilder
                                   .LoadConfig()
                                   .SetAuthenticator(authenticator)
                                   .SetRequestConfiguration(
                (request, config) =>
            {
                config.LoadConfig();
                config.SetKeyValueStoreProvider(keyValueStoreProvider);
            })
                                   .Build(connectorFactory);

            builder.UseConnector(connector);
        }
Beispiel #6
0
        private static void SetupConnector(IAppBuilder builder)
        {
            var allowedRoleMatcherTemplate = ConfigurationManager.AppSettings["ckfinderAllowedRole"];
            var authenticator = new RoleBasedAuthenticator(allowedRoleMatcherTemplate);

            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();
            var connector        = connectorBuilder
                                   .LoadConfig()
                                   .SetAuthenticator(authenticator)
                                   .SetRequestConfiguration(
                (request, config) =>
            {
                config.LoadConfig();

                var defaultBackend        = config.GetBackend("default");
                var keyValueStoreProvider = new FileSystemKeyValueStoreProvider(defaultBackend);
                config.SetKeyValueStoreProvider(keyValueStoreProvider);
            })
                                   .Build(connectorFactory);

            builder.UseConnector(connector);
        }
Beispiel #7
0
        private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create a connector instance using ConnectorBuilder. The call to the LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            /*
             * Create an instance of authenticator implemented in the previous step.
             */

            var customAuthenticator = new MyAuthenticator();

            connectorBuilder

            /*
             * Provide the global configuration.
             *
             * If you installed CKSource.CKFinder.Connector.Config, you should load the static configuration
             * from XML:
             * connectorBuilder.LoadConfig();
             */
            .SetAuthenticator(customAuthenticator)
            .LoadConfig()

            .SetRequestConfiguration(
                (request, config) =>
            {
                /*
                 * If you installed CKSource.CKFinder.Connector.Config, you might want to load the static
                 * configuration from XML as a base configuration to modify:
                 */
                config.LoadConfig();

                /*
                 * Configure settings per request.
                 *
                 * The minimal configuration has to include at least one backend, one resource type
                 * and one ACL rule.
                 *
                 * For example:
                 */
                config.AddBackend("default1", new LocalStorage(@"C:\files"));
                config.AddResourceType("images", builder => builder.SetBackend("default1", "images"));
                config.AddAclRule(new AclRule(
                                      new StringMatcher("*"),
                                      new StringMatcher("*"),
                                      new StringMatcher("*"),
                                      new Dictionary <Permission, PermissionType> {
                    { Permission.All, PermissionType.Allow }
                }));


                /*
                 * If you installed CKSource.CKFinder.Connector.KeyValue.FileSystem, you may enable caching:
                 */
                var defaultBackend = config.GetBackend("default1");
            }
                );

            /*
             * Build the connector middleware.
             */
            var connector = connectorBuilder
                            .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to the web application pipeline.
             */
            app.UseConnector(connector);
        }
Beispiel #8
0
        private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create a connector instance using ConnectorBuilder. The call to the LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            /*
             * Create an instance of authenticator implemented in the previous step.
             */
            var customAuthenticator = new CKFinderAuthenticator();

            connectorBuilder

            /*
             * Provide the global configuration.
             *
             * If you installed CKSource.CKFinder.Connector.Config you may load static configuration
             * from XML:
             * connectorBuilder.LoadConfig();
             */

            .SetAuthenticator(customAuthenticator)
            .SetRequestConfiguration(
                (request, config) =>
            {
                var instanceId = request.QueryParameters["id"].FirstOrDefault() ?? string.Empty;

                //var baseUrl = GetBaseUrlByInstanceId(instanceId);
                //config.AddProxyBackend("default", new LocalStorage(root));
                //config.AddProxyBackend("baseUrl", new LocalStorage(@"\ckfinder\userfiles\"));
                //config.AddResourceType("images", builder => builder.SetBackend("default", "images" ));
                config.LoadConfig();

                /*
                 * Configure settings per request.
                 *
                 * The minimal configuration has to include at least one backend, one resource type
                 * and one ACL rule.
                 *
                 * For example:
                 * config.AddBackend("default", new LocalStorage(@"C:\files"));
                 *
                 * config.AddAclRule(new AclRule(
                 *    new StringMatcher("*"),
                 *     new StringMatcher("*"),
                 *     new StringMatcher("*"),
                 *     new Dictionary<Permission, PermissionType> { { Permission.All, PermissionType.Allow } }));
                 *
                 * If you installed CKSource.CKFinder.Connector.Config, you may load the static configuration
                 * from XML:
                 * config.LoadConfig();
                 *
                 * If you installed CKSource.CKFinder.Connector.KeyValue.EntityFramework, you may enable caching:
                 * config.SetKeyValueStoreProvider(
                 *     new EntityFrameworkKeyValueStoreProvider("CKFinderCacheConnection"));
                 */
            }
                );

            /*
             * Build the connector middleware.
             */
            var connector = connectorBuilder
                            .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to the web application pipeline.
             */
            app.UseConnector(connector);
        }
Beispiel #9
0
        private static void SetupConnector(IAppBuilder app)
        {
            /*
             * Create a connector instance using ConnectorBuilder. The call to the LoadConfig() method
             * will configure the connector using CKFinder configuration options defined in Web.config.
             */
            var connectorFactory = new OwinConnectorFactory();
            var connectorBuilder = new ConnectorBuilder();

            /*
             * Create an instance of authenticator implemented in the previous step.
             */
            var customAuthenticator = new CustomCKFinderAuthenticator();

            connectorBuilder

            /*
             * Provide the global configuration.
             *
             * If you installed CKSource.CKFinder.Connector.Config you may load static configuration
             * from XML:
             * connectorBuilder.LoadConfig();
             */
            .LoadConfig()
            .SetAuthenticator(customAuthenticator)
            .SetRequestConfiguration(
                (request, config) =>
            {
                /* Add a local backend. */
                //config.AddProxyBackend("local", new LocalStorage(@"public/upload"));
                config.AddBackend("local", new LocalStorage(@"public/upload", "http://www.stampecreative.it/public/upload/"));
                /* Add a resource type that uses the local backend. */
                config.AddResourceType("Files", resourceBuilder => resourceBuilder.SetBackend("local", "files"));
                config.AddResourceType("Images", resourceBuilder => resourceBuilder.SetBackend("local", "images"));
                /* Give full access to all resource types at any path for all users. */
                config.AddAclRule(new AclRule(
                                      new StringMatcher("*"), new StringMatcher("/"), new StringMatcher("*"),
                                      new Dictionary <Permission, PermissionType>
                {
                    { Permission.FolderView, PermissionType.Allow },
                    { Permission.FolderCreate, PermissionType.Allow },
                    { Permission.FolderRename, PermissionType.Allow },
                    { Permission.FolderDelete, PermissionType.Allow },
                    { Permission.FileView, PermissionType.Allow },
                    { Permission.FileCreate, PermissionType.Allow },
                    { Permission.FileRename, PermissionType.Allow },
                    { Permission.FileDelete, PermissionType.Allow },
                    { Permission.ImageResize, PermissionType.Allow },
                    { Permission.ImageResizeCustom, PermissionType.Allow }
                }));
            });

            /*
             * Configure settings per request.
             *
             * The minimal configuration has to include at least one backend, one resource type
             * and one ACL rule.
             *
             * For example:
             * config.AddBackend("default", new LocalStorage(@"C:\files"));
             * config.AddResourceType("images", builder => builder.SetBackend("default", "images"));
             * config.AddAclRule(new AclRule(
             *     new StringMatcher("*"),
             *     new StringMatcher("*"),
             *     new StringMatcher("*"),
             *     new Dictionary<Permission, PermissionType> { { Permission.All, PermissionType.Allow } }));
             *
             * If you installed CKSource.CKFinder.Connector.Config, you may load the static configuration
             * from XML:
             * config.LoadConfig();
             *
             * If you installed CKSource.CKFinder.Connector.KeyValue.EntityFramework, you may enable caching:
             * config.SetKeyValueStoreProvider(
             *     new EntityFrameworkKeyValueStoreProvider("CKFinderCacheConnection"));
             */


            /*
             * Build the connector middleware.
             */
            var connector = connectorBuilder
                            .Build(connectorFactory);

            /*
             * Add the CKFinder connector middleware to the web application pipeline.
             */
            app.UseConnector(connector);
        }