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


C# IAppBuilder.UseWsFederationAuthentication方法代码示例

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


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

示例1: Configure

        public override void Configure(IAppBuilder app)
        {
            if (String.IsNullOrEmpty(FederationSettings.MetadataAddress))
            {
                throw new ArgumentException("Missing federation declaration in config", "FederationMetadataAddress");
            }

            if (String.IsNullOrEmpty(FederationSettings.Realm))
            {
                throw new ArgumentException("Missing federation declaration in config", "FederationRealm");

            }

            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
            {
                MetadataAddress = FederationSettings.MetadataAddress,
                Wtrealm = FederationSettings.Realm,
                Notifications = new WsFederationAuthenticationNotifications()
                {
                    RedirectToIdentityProvider = (context) =>
                    {
                        if (context.OwinContext.Response.StatusCode == (int)HttpStatusCode.Unauthorized && context.Request.Headers.ContainsKey("AuthNoRedirect"))
                        {
                            context.HandleResponse();
                        }

                        return Task.FromResult(0);
                    }
                }
            });
        }
开发者ID:dvgamer,项目名称:IIS.Git-Connector,代码行数:33,代码来源:FederationAuthenticationProvider.cs

示例2: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider()
            });

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
            {
                MetadataAddress = String.Format("https://{0}/wsfed/{1}/FederationMetadata/2007-06/FederationMetadata.xml", 
                    ConfigurationManager.AppSettings["auth0:Domain"], 
                    ConfigurationManager.AppSettings["auth0:ClientId"]),
                Wtrealm = "urn:" + ConfigurationManager.AppSettings["auth0:ApplicationName"],
                Notifications = new WsFederationAuthenticationNotifications
                {
                    SecurityTokenValidated = notification =>
                    {
                        notification.AuthenticationTicket.Identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "Auth0"));
                        return Task.FromResult(true);
                    }
                }
            });
        }
开发者ID:Raghus123,项目名称:auth0-aspnet-owin,代码行数:27,代码来源:Startup.cs

示例3: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app, IConfigurationProvider configProvider)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            // Primary authentication method for web site to Azure AD via the WsFederation below
            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            string federationMetadataAddress = configProvider.GetConfigurationSettingValue("ida.FederationMetadataAddress");
            string federationRealm = configProvider.GetConfigurationSettingValue("ida.FederationRealm");

            if (string.IsNullOrEmpty(federationMetadataAddress) || string.IsNullOrEmpty(federationRealm))
            {
                throw new ApplicationException("Config issue: Unable to load required federation values from web.config or other configuration source.");
            }

            // check for default values that will cause app to fail to startup with an unhelpful 404 exception
            if (federationMetadataAddress.StartsWith("-- ", StringComparison.Ordinal) ||
                federationRealm.StartsWith("-- ", StringComparison.Ordinal))
            {
                throw new ApplicationException("Config issue: Default federation values from web.config need to be overridden or replaced.");
            }

            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    MetadataAddress = federationMetadataAddress,
                    Wtrealm = federationRealm
                });

            string aadTenant = configProvider.GetConfigurationSettingValue("ida.AADTenant");
            string aadAudience = configProvider.GetConfigurationSettingValue("ida.AADAudience");

            if (string.IsNullOrEmpty(aadTenant) || string.IsNullOrEmpty(aadAudience))
            {
                throw new ApplicationException("Config issue: Unable to load required AAD values from web.config or other configuration source.");
            }

            // check for default values that will cause failure
            if (aadTenant.StartsWith("-- ", StringComparison.Ordinal) ||
                aadAudience.StartsWith("-- ", StringComparison.Ordinal))
            {
                throw new ApplicationException("Config issue: Default AAD values from web.config need to be overridden or replaced.");
            }

            // Fallback authentication method to allow "Authorization: Bearer <token>" in the header for WebAPI calls
            app.UseWindowsAzureActiveDirectoryBearerAuthentication(
                new WindowsAzureActiveDirectoryBearerAuthenticationOptions
                {
                    Tenant = aadTenant,
                    TokenValidationParameters = new TokenValidationParameters
                    {
                        ValidAudience = aadAudience,
                        RoleClaimType = "http://schemas.microsoft.com/identity/claims/scope" // Used to unwrap token roles and provide them to [Authorize(Roles="")] attributes
                    }
                });
        }
开发者ID:magoroku15,项目名称:azure-iot-predictive-maintenance,代码行数:56,代码来源:Startup.Auth.cs

示例4: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    Wtrealm = realm,
                    MetadataAddress = adfsMetadata
                });
        }
开发者ID:lovis-holdings,项目名称:lovis.management,代码行数:13,代码来源:Startup.Auth.cs

示例5: ConfigureWsFederationAuth

        public void ConfigureWsFederationAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
            {
                AuthenticationType = FedAuth,
                Wtrealm = ConfigurationManager.AppSettings["app:URI"],
                MetadataAddress = ConfigurationManager.AppSettings["wsFederation:MetadataEndpoint"],
            });
        }
开发者ID:AaronWells,项目名称:OwinClaims,代码行数:13,代码来源:Startup.WsFederation.cs

示例6: ConfigureIdentityProviders

        private void ConfigureIdentityProviders(IAppBuilder app, string signInAsType)
        {
            var wsFederation = new WsFederationAuthenticationOptions
            {
                AuthenticationType = "windows",
                Caption = "Windows",
                SignInAsAuthenticationType = signInAsType,

                MetadataAddress = "https://localhost:44333/windows",
                Wtrealm = "urn:idsrv3"
            };
            app.UseWsFederationAuthentication(wsFederation);
        }
开发者ID:dkaminski,项目名称:IdentityServer3.Samples,代码行数:13,代码来源:Startup.cs

示例7: ConfigureAdditionalIdentityProviders

 public static void ConfigureAdditionalIdentityProviders(IAppBuilder app, string signInAsType)
 {
     var windowsAuthentication = new WsFederationAuthenticationOptions
     {
         AuthenticationType = "windows",
         Caption = "Windows",
         SignInAsAuthenticationType = signInAsType,
         MetadataAddress = GlobalConfiguration.WinAdMetadataUri.ToString(),
         Wtrealm = "urn:idsrv3",
         Wreply = $"{GlobalConfiguration.AuthorityRoute}/callback",
         Notifications = GetWsFedAuthNotifications()
     };
     app.UseWsFederationAuthentication(windowsAuthentication);
 }
开发者ID:MAOliver,项目名称:Enterprise-Toolbox,代码行数:14,代码来源:ConfigurationFactory.cs

示例8: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    MetadataAddress = "http://localhost:29702/FederationMetadata",
                    Wtrealm = "urn:SupaDoopaRealm",
                    Wreply             = "http://localhost:16635/"
                }
            );
        }
开发者ID:BasLijten,项目名称:EmbeddedStsSample,代码行数:14,代码来源:Startup.cs

示例9: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
            {
                MetadataAddress = MVC_Owin_WsFederation.Configuration.CFS_METADATA,
                Wtrealm = MVC_Owin_WsFederation.Configuration.CFS_RP_REALM,

                SignInAsAuthenticationType = "Cookies"
            });
        }
开发者ID:radiantlogicinc,项目名称:.NET-Clients-for-CFS,代码行数:15,代码来源:Startup.cs

示例10: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
                {
                    MetadataAddress = Constants.BaseAddress + "/wsfed/metadata",
                    Wtrealm = "urn:owinrp",

                    SignInAsAuthenticationType = "Cookies"
                });
        }
开发者ID:ErikM040566,项目名称:Thinktecture.IdentityServer.v3,代码行数:15,代码来源:Startup.cs

示例11: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = UserAccountType.External,
                AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive,
            });

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = UserAccountType.Twitter,
                AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active,
            });

            app.UseCookieAuthentication(
                new CookieAuthenticationOptions
                {
                    AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType,
                    AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active
                });

            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    MetadataAddress = ConfigurationManager.AppSettings["FederationMetadataAddress"],
                    Wtrealm = ConfigurationManager.AppSettings["FederationWtrealm"],
                    SignInAsAuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
                });

            app.UseTwitterAuthentication(
                new TwitterAuthenticationOptions
               {
                   ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"],
                   ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"],
                   Provider = new Microsoft.Owin.Security.Twitter.TwitterAuthenticationProvider
                   {
                       OnAuthenticated = async context =>
                       {
                           context.Identity.AddClaim(new Claim("urn:twitter:accesstoken", context.AccessToken));
                           context.Identity.AddClaim(new Claim("urn:twitter:accesstokensecret", context.AccessTokenSecret));
                       }
                   },
                   SignInAsAuthenticationType = UserAccountType.External
               });
        }
开发者ID:openlab,项目名称:ODAF-OpenTurf,代码行数:47,代码来源:Startup.Auth.cs

示例12: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            var notifications = new WsFederationAuthenticationNotifications
            {
                SecurityTokenReceived = (context) =>
                {
                    Debug.WriteLine("SecurityTokenReceived");
                    return Task.CompletedTask;
                },

                AuthenticationFailed = (context) =>
                {
                    Debug.WriteLine("AuthenticationFailed");
                    return Task.CompletedTask;
                },

                MessageReceived = (context) =>
                {
                    Debug.WriteLine("MessageReceived");
                    return Task.CompletedTask;
                },

                RedirectToIdentityProvider = (context) =>
                {
                    Debug.WriteLine("RedirectToIdentityProvider");
                    return Task.CompletedTask;
                },

                SecurityTokenValidated = (context) =>
                {
                    Debug.WriteLine("SecurityTokenValidated");
                    return Task.CompletedTask;
                }
            };

            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    Notifications = notifications,
                    Wtrealm = _realm,
                    MetadataAddress = _adfsMetadata
                });
        }
开发者ID:mchudinov,项目名称:AspMvcACSOwin,代码行数:46,代码来源:Startup.Auth.cs

示例13: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(
                new CookieAuthenticationOptions
                {
                    AuthenticationType =
                       CookieAuthenticationDefaults.AuthenticationType
                });
            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    MetadataAddress = "https://login.microsoftonline.com/2c2a63d4-465c-464d-b7f5-6ccfd0dce5b8/federationmetadata/2007-06/federationmetadata.xml",
                    Wtrealm = "https://testService.local/",
                });

            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
        }
开发者ID:Drakraq,项目名称:ASP.NET-MVC,代码行数:17,代码来源:Startup.cs

示例14: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType,
            });

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
            {
                MetadataAddress = IdentityUrl + "/wsfed/metadata",
                Wtrealm = ServerUrl,
                SignOutWreply = ServerUrl,
                SignInAsAuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType,
                UseTokenLifetime = false,
                Notifications = new WsFederationAuthenticationNotifications
                {
                    RedirectToIdentityProvider = ctx =>
                    {
                        if (ctx.OwinContext.Response.StatusCode == 401 &&
                             ctx.OwinContext.Authentication.User.Identity.IsAuthenticated)
                        {
                            ctx.OwinContext.Response.StatusCode = 403;
                            ctx.HandleResponse();
                        }
                        return Task.FromResult(0);
                    },
                    SecurityTokenValidated = ctx =>
                    {
                        //ctx.AuthenticationTicket.Properties.IsPersistent = true; //Always False. Will remember when closing browser, but should only happen when user ticks Remember Me
                        var isPersistent = ctx.AuthenticationTicket.Properties.IsPersistent;//Should vary based on remember me-checkbox? 

                        var redirectUri = new Uri(ctx.AuthenticationTicket.Properties.RedirectUri, UriKind.RelativeOrAbsolute);
                        if (redirectUri.IsAbsoluteUri)
                            ctx.AuthenticationTicket.Properties.RedirectUri = redirectUri.PathAndQuery;

                        return Task.FromResult(0);
                    }
                }
            });

            app.UseStageMarker(PipelineStage.Authenticate);

            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Name;
        }
开发者ID:Arthyon,项目名称:IdentityServer3.WsFederationReproduction,代码行数:45,代码来源:ClientStartup.cs

示例15: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions {AuthenticationType = "cookies"});

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
            {
                Wtrealm = "urn:encryptedrealmV2",
                MetadataAddress = "https://localhost:44388/wsfed/metadata",
                Wreply = "https://localhost:44344/",
                SignInAsAuthenticationType = "cookies",
                TokenValidationParameters = new TokenValidationParameters
                {
                    AuthenticationType = "cookies",
                    ClientDecryptionTokens =
                        new ReadOnlyCollection<SecurityToken>(new List<SecurityToken>
                        {
                            new X509SecurityToken(Cert.LoadEncrypting())
                        })
                }
            });
        }
开发者ID:scottbrady91,项目名称:Blog-Example-Classes,代码行数:21,代码来源:Startup.cs


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