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


C# NancyContext.GetOwinEnvironment方法代码示例

本文整理汇总了C#中Nancy.NancyContext.GetOwinEnvironment方法的典型用法代码示例。如果您正苦于以下问题:C# NancyContext.GetOwinEnvironment方法的具体用法?C# NancyContext.GetOwinEnvironment怎么用?C# NancyContext.GetOwinEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.NancyContext的用法示例。


在下文中一共展示了NancyContext.GetOwinEnvironment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RequestStartup

 protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
 {
     base.RequestStartup(container, pipelines, context);
     var owinEnvironment = context.GetOwinEnvironment();
     var user = owinEnvironment["server.User"] as ClaimsPrincipal;
     context.CurrentUser = new DemoUserIdentity()
     {
         UserName = user.Identity.Name,
         Claims = user.Claims.Select(x => x.Value)
     };
 }
开发者ID:philjones88,项目名称:Owin.StatelessAuth,代码行数:11,代码来源:Bootstrapper.cs

示例2: RequestStartup

        protected override void RequestStartup(IContainer container, IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);
            var owinEnvironment = context.GetOwinEnvironment();
            if (!owinEnvironment.ContainsKey("server.User")) return;

            var user = owinEnvironment["server.User"] as ClaimsPrincipal;
            if (user != null && user.Identity.IsAuthenticated)
            {
                context.CurrentUser =
                    new CustomUserIdentity(Guid.Parse(user.Claims.Single(x => x.Type == ClaimTypes.NameIdentifier).Value),
                        user.Identity.Name, user.Claims.Select(x => x.Value));
            }
        }
开发者ID:joshilewis,项目名称:lending,代码行数:14,代码来源:BootStrapper.cs

示例3: RequestStartup

 protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
 {
     base.RequestStartup(container, pipelines, context);
     var owinEnvironment = context.GetOwinEnvironment();
     var user = owinEnvironment["server.User"] as ClaimsPrincipal;
     if (user != null)
     {
         context.CurrentUser = new DemoUserIdentity()
         {
             UserName = user.Identity.Name,
             Claims = user.Claims.Where(x => x.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Select(x => x.Value)
         };
     }
 }
开发者ID:jamescrowley,项目名称:Owin.StatelessAuth,代码行数:14,代码来源:Bootstrapper.cs

示例4: RequestStartup

        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);
            StaticConfiguration.DisableErrorTraces = false;
            var owinEnvironment = context.GetOwinEnvironment();
            var user = owinEnvironment["server.User"] as ClaimsPrincipal;
            if (user != null)
            {
                context.CurrentUser = new DemoUserIdentity
                {
                    UserName = user.Identity.Name,
                    Claims = user.Claims.Where(x => x.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Select(x => x.Value)
                };
            }

            pipelines.OnError.AddItemToEndOfPipeline((z, a) =>
            {
                return null;
            });
        }
开发者ID:neoms21,项目名称:FeelKnit.Service,代码行数:20,代码来源:BootStrapper.cs

示例5: FlowPrincipal

        private static Response FlowPrincipal(NancyContext context)
        {
            var env = context.GetOwinEnvironment();
            if (env == null) 
                return null;

            var principal = env.Get<IPrincipal>("server.User") as ClaimsPrincipal;
            if (principal != null)
                context.CurrentUser = new TheBenchUser(new TheBenchPrincipal(principal));

            return null;
        }
开发者ID:CumpsD,项目名称:CC.TheBench,代码行数:12,代码来源:Bootstrapper.cs


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