当前位置: 首页>>代码示例>>C#>>正文


C# Forms.FormsAuthenticationConfiguration类代码示例

本文整理汇总了C#中Nancy.Authentication.Forms.FormsAuthenticationConfiguration的典型用法代码示例。如果您正苦于以下问题:C# FormsAuthenticationConfiguration类的具体用法?C# FormsAuthenticationConfiguration怎么用?C# FormsAuthenticationConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FormsAuthenticationConfiguration类属于Nancy.Authentication.Forms命名空间,在下文中一共展示了FormsAuthenticationConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplicationConfiguration

        public static void ApplicationConfiguration(TinyIoCContainer container, IPipelines pipelines)
        {
            var cryptographyConfiguration = new CryptographyConfiguration(
                new RijndaelEncryptionProvider(new PassphraseKeyGenerator("SuperSecretPass", new byte[] {1, 2, 3, 4, 5, 6, 7, 8})),
                new DefaultHmacProvider(new PassphraseKeyGenerator("UberSuperSecure", new byte[] {1, 2, 3, 4, 5, 6, 7, 8})));

            pipelines.AfterRequest.AddItemToEndOfPipeline(x =>
                {
                    x.Response.Headers.Add("Access-Control-Allow-Origin", "*");
                    x.Response.Headers.Add("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE,OPTIONS");
                });

            var formsAuthentication = new FormsAuthenticationConfiguration()
                {
                    CryptographyConfiguration = cryptographyConfiguration,
                    RedirectUrl = "~/weblogin",
                    UserMapper = container.Resolve<IUserMapper>(),
                };

            Nancy.Json.JsonSettings.MaxJsonLength = int.MaxValue;

            FormsAuthentication.Enable(pipelines, formsAuthentication);
            GlobalHost.DependencyResolver = new TinyIoCDependencyResolver(container);

            container.Register(typeof (StartableManager), new StartableManager(container));
        }
开发者ID:henrikrtfm,项目名称:Seerefine,代码行数:26,代码来源:Bootstrapper.cs

示例2: FixtureSetup

 public void FixtureSetup()
 {
     var formsAuthenticationConfiguration = new FormsAuthenticationConfiguration()
         {
             RedirectUrl = "~/login",
             UserMapper = new FakeUserMapper(new UserService())
         };
     var configuration = A.Fake<IRazorConfiguration>();
     var bootstrapper = new ConfigurableBootstrapper(config =>
         {
             config.Module<UsersModule>();
             config.Module<LoginModule>();
             config.ViewEngine(new RazorViewEngine(configuration));
         });
     var bootstrapper2 = new ConfigurableBootstrapper(config =>
         {
             config.Module<UsersModule>();
             config.Module<LoginModule>();
             config.ViewEngine(new RazorViewEngine(configuration));
             config.RequestStartup((x, pipelines, z) => FormsAuthentication.Enable(pipelines, formsAuthenticationConfiguration));
         });
     _notLoggedInBrowser = new Browser(bootstrapper);
     _loggedInBrowserResponse = new Browser(bootstrapper2).Post("/login", x =>
         {
             x.HttpRequest();
             x.FormValue("Username", "Chris1");
             x.FormValue("Password", "123");
         });
 }
开发者ID:chrissie1,项目名称:NancyVB,代码行数:29,代码来源:TestUsersModule.cs

示例3: Enable

        /// <summary>
        /// Enables forms authentication for the application
        /// </summary>
        /// <param name="pipelines">Pipelines to add handlers to (usually "this")</param>
        /// <param name="configuration">Forms authentication configuration</param>
        public static void Enable(IPipelines pipelines, FormsAuthenticationConfiguration configuration)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (!configuration.IsValid)
            {
                throw new ArgumentException("Configuration is invalid", "configuration");
            }

            currentConfiguration = configuration;

            pipelines.BeforeRequest.AddItemToStartOfPipeline(GetLoadAuthenticationHook(configuration));
            if (!configuration.DisableRedirect)
            {
                pipelines.AfterRequest.AddItemToEndOfPipeline(GetRedirectToLoginHook(configuration));
            }
        }
开发者ID:rahulchrty,项目名称:Nancy,代码行数:30,代码来源:FormsAuthentication.cs

示例4: RequestStartup

        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    RedirectUrl = "~/login",
                    UserMapper = container.Resolve<IUserMapper>(),
                };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
            CookieBasedSessions.Enable(pipelines);

            pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx =>
                {
                    if (Helper.Settings.Instance.Client.CanConnect)
                        return null;
                    else
                    {
                        if (String.Compare(ctx.Request.Path, "/notavailable", true) == 0)
                        {
                            return null;
                        }
                        return new RedirectResponse("/notavailable");
                    }
                });

            base.RequestStartup(container, pipelines, context);
        }
开发者ID:ChrisK91,项目名称:CWSRestart,代码行数:28,代码来源:ApplicationBootstrapper.cs

示例5: RequestStartup

        //protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
        //{
        //    // We don't call "base" here to prevent auto-discovery of
        //    // types/dependencies
        //}
        //protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
        //{
        //    base.ConfigureRequestContainer(container, context);
        //    // Here we register our user mapper as a per-request singleton.
        //    // As this is now per-request we could inject a request scoped
        //    // database "context" or other request scoped services.
        //    container.Register<IUserMapper, UserDatabase>();
        //}
        protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context)
        {
            // At request startup we modify the request pipelines to
            // include forms authentication - passing in our now request
            // scoped user name mapper.
            //
            // The pipelines passed in here are specific to this request,
            // so we can add/remove/update items in them as we please.
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    RedirectUrl = "~/login",
                    UserMapper = requestContainer.Resolve<IUserMapper>(),
                };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);

            pipelines.AfterRequest.AddItemToEndOfPipeline(x =>
            {
                if (x.CurrentUser != null)
                    x.ViewBag.CurrentUserName = x.CurrentUser.UserName;
                else
                    x.ViewBag.CurrentUserName = null;
            });
        }
开发者ID:howframework,项目名称:Nancy,代码行数:38,代码来源:FormsAuthBootstrapper.cs

示例6: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            CookieBasedSessions.Enable(pipelines);

            Conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("views/", viewName));

            Conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("assets", @"assets")
            );

            container.Register<IFlexUserStore, FlexMembershipUserStore<User, Role>>();
            container.Register(typeof(IDocumentStore), InitDocStore());
            container.Register(typeof(IDocumentSession), (c, overloads) =>
                c.Resolve<IDocumentStore>().OpenSession());

            var cryptographyConfiguration = new CryptographyConfiguration(
                new RijndaelEncryptionProvider(new PassphraseKeyGenerator(Configuration.EncryptionKey, new byte[] { 8, 2, 10, 4, 68, 120, 7, 14 })),
                new DefaultHmacProvider(new PassphraseKeyGenerator(Configuration.HmacKey, new byte[] { 1, 20, 73, 49, 25, 106, 78, 86 })));

            var authenticationConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    CryptographyConfiguration = cryptographyConfiguration,
                    RedirectUrl = "/login",
                    UserMapper = container.Resolve<IUserMapper>(),
                };

            FormsAuthentication.Enable(pipelines, authenticationConfiguration);

            FlexMembershipProvider.RegisterClient(
                new GoogleOpenIdClient(),
                "Google", new Dictionary<string, object>());
        }
开发者ID:julianjelfs,项目名称:geeks-nancy,代码行数:35,代码来源:Bootstrap.cs

示例7: Enable

        /// <summary>
        /// Enables forms authentication for a module
        /// </summary>
        /// <param name="module">Module to add handlers to (usually "this")</param>
        /// <param name="configuration">Forms authentication configuration</param>
        public static void Enable(INancyModule module, FormsAuthenticationConfiguration configuration)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            configuration.EnsureConfigurationIsValid();

            module.RequiresAuthentication();

            currentConfiguration = configuration;

            module.Before.AddItemToStartOfPipeline(GetLoadAuthenticationHook(configuration));

            if (!configuration.DisableRedirect)
            {
                module.After.AddItemToEndOfPipeline(GetRedirectToLoginHook(configuration));
            }
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:30,代码来源:FormsAuthentication.cs

示例8: ApplicationStartup

        /// <summary>
        /// Initialise the bootstrapper - can be used for adding pre/post hooks and
        ///             any other initialisation tasks that aren't specifically container setup
        ///             related
        /// </summary>
        /// <param name="container">Container instance for resolving types if required.</param>
        /// <param name="pipelines">The pipelines used in this application.</param>
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            this.SetupDatabaseConnection();

            base.ApplicationStartup(container, pipelines);

            StaticConfiguration.EnableRequestTracing = true;

            pipelines.OnError += (ctx, ex) =>
            {
                Logger.Trace(ex, "On error message was triggered: {0}", ex.Message);
                return null;
            };

            SetUpTrackingCodes();

            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    RedirectUrl = "~/login",
                    UserMapper = container.Resolve<IUserMapper>()
                };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
        }
开发者ID:ajvorobiev,项目名称:DotNancyTemplate,代码行数:32,代码来源:Bootstrapper.cs

示例9: NancyAuthMiddleware

 public NancyAuthMiddleware(Func<IDictionary<string, object>, Task> next,
     FormsAuthenticationConfiguration formsAuthenticationConfiguration, 
     IUserManager userManager)
 {
     _next = next;
     _formsAuthenticationConfiguration = formsAuthenticationConfiguration;
     _userManager = userManager;
 }
开发者ID:ThomasWeiss,项目名称:NancyFormsAuthToClaimsPrincipalMiddleware,代码行数:8,代码来源:NancyAuthMiddleware.cs

示例10: InitialiseInternal

        protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
        {
            base.InitialiseInternal(container);
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    Passphrase = "SuperSecretPass",
                    Salt = "AndVinegarCrisps",
                    HmacPassphrase = "UberSuperSecure",
                    RedirectUrl = "/authentication/login",
                    UsernameMapper = container.Resolve<IUsernameMapper>(),
                };

            FormsAuthentication.Enable(this, formsAuthConfiguration);

            BeforeRequest += ctx =>
            {
                var rootPathProvider =
                    container.Resolve<IRootPathProvider>();

                var staticFileExtensions =
                    new Dictionary<string, string>
                    {
                        { "jpg", "image/jpg" },
                        { "png", "image/png" },
                        { "gif", "image/gif" },
                        { "css", "text/css" },
                        { "js",  "text/javascript" }
                    };

                var requestedExtension =
                    Path.GetExtension(ctx.Request.Uri);

                if (!string.IsNullOrEmpty(requestedExtension))
                {
                    var extensionWithoutDot =
                        requestedExtension.Substring(1);

                    if (staticFileExtensions.Keys.Any(x => x.Equals(extensionWithoutDot, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        var fileName =
                            Path.GetFileName(ctx.Request.Uri);

                        if (fileName == null)
                        {
                            return null;
                        }

                        var filePath =
                            Path.Combine(rootPathProvider.GetRootPath(), "content", fileName);

                        return !File.Exists(filePath) ? null : new StaticFileResponse(filePath, staticFileExtensions[extensionWithoutDot]);
                    }
                }

                return null;
            };
        }
开发者ID:GraemeF,项目名称:NerdBeers,代码行数:58,代码来源:Bootstrapper.cs

示例11: RequestStartup

 protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) {
     base.RequestStartup(container, pipelines, context);
     var formsAuthConfiguration =
         new FormsAuthenticationConfiguration {
             RedirectUrl = "~/login",
             UserMapper = new UserMapper(),
         };
     FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
 }
开发者ID:slieser,项目名称:sandbox,代码行数:9,代码来源:Bootstrapper.cs

示例12: RequestStartup

 protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context)
 {
     var formsAuthConfiguration = new FormsAuthenticationConfiguration
     {
         RedirectUrl = "~/",
         UserMapper = requestContainer.Resolve<IUserMapper>(),
     };
     FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
 }
开发者ID:nathanchere,项目名称:Nancy.Demo.FormsAuthentication.Ajax,代码行数:9,代码来源:Bootstrapper.cs

示例13: RequestStartup

 protected override void RequestStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
 {
     base.RequestStartup(container, pipelines, context);
     var formsAuthConfiguration = new FormsAuthenticationConfiguration()
     {
         RedirectUrl = "/login", //認証失敗時のリダイレクト先
         UserMapper = container.Resolve<IUserMapper>()
     };
     FormsAuthentication.Enable(pipelines, formsAuthConfiguration);  //フォーム認証の有効化
 }
开发者ID:ken200,项目名称:Tokenken2,代码行数:10,代码来源:MyBootstrapper.cs

示例14: FormsAuthenticationRequestStartup

        private void FormsAuthenticationRequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            var config = new FormsAuthenticationConfiguration
                             {
                                 RedirectUrl = "~/login",
                                 UserMapper = container.Resolve<IUserMapper>()
                             };

            FormsAuthentication.Enable(pipelines, config);
        }
开发者ID:prabirshrestha,项目名称:backbone-js-on-nancy,代码行数:10,代码来源:Bootstrapper.cs

示例15: RequestStartup

		protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
		{
			base.RequestStartup(container, pipelines, context);

			var authConfig = new FormsAuthenticationConfiguration()
			{
				RedirectUrl = "/login",
				UserMapper = container.Resolve<IUserMapper>(),
			};
			FormsAuthentication.Enable(ApplicationPipelines, authConfig);
		}
开发者ID:dgg,项目名称:Dgg.10gen_M101,代码行数:11,代码来源:Bootstrapper.cs


注:本文中的Nancy.Authentication.Forms.FormsAuthenticationConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。