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


C# IApplicationBuilder.UseIdentityServerAuthentication方法代码示例

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


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

示例1: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();

            app.UseCors(policy =>
            {
                policy.WithOrigins(
                    "http://localhost:28895", 
                    "http://localhost:7017");

                policy.AllowAnyHeader();
                policy.AllowAnyMethod();
            });

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            app.UseIdentityServerAuthentication(options =>
            {
                options.Authority = Clients.Constants.BaseAddress;
                options.ScopeName = "api1";
                options.ScopeSecret = "secret";

                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = true;
            });

            app.UseMvc();
        }
开发者ID:jvanrhyn,项目名称:IdentityServer4.Samples,代码行数:30,代码来源:Startup.cs

示例2: Configure

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(LogLevel.Verbose);
            loggerFactory.AddDebug(LogLevel.Verbose);
            
            ILogger log = loggerFactory.CreateLogger("testlog");
            log.LogInformation("AppSettings:AllowedOrigins: " + string.Join(" , ", Configuration.Get<string[]>("AppSettings:AllowedOrigins")));
            
            
            app.UseStaticFiles();

            app.UseCors(builder =>
            {
                builder.WithOrigins(Configuration.Get<string[]>("AppSettings:AllowedOrigins")) // TODO: revisit and check if this can be more strict and still allow preflight OPTION requests
                    .AllowAnyMethod()
                    .AllowAnyHeader();
            });



            app.UseIISPlatformHandler();

   
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            app.UseIdentityServerAuthentication(options =>
            {
                options.Authority = "http://localhost:5020";
                options.ScopeName = "openid";
                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = true;
            });

            app.UseMvc();
        }
开发者ID:gerry123,项目名称:g42,代码行数:35,代码来源:Startup.cs

示例3: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
            {
                Authority = "http://localhost:47627",
                RequireHttpsMetadata = false,

                ScopeName = "gabMileageApi",
                AutomaticAuthenticate = true
            });

            app.UseMvc();
        }
开发者ID:gabrewer,项目名称:gabMileage,代码行数:19,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseCors("corsGlobalPolicy");

            app.UseStaticFiles();

            IdentityServerAuthenticationOptions identityServerAuthenticationOptions = new IdentityServerAuthenticationOptions();
            identityServerAuthenticationOptions.Authority = "https://localhost:44318/";
            identityServerAuthenticationOptions.AllowedScopes = new List<string> { "securedFiles" };
            identityServerAuthenticationOptions.ApiSecret = "securedFilesSecret";
            identityServerAuthenticationOptions.ApiName = "securedFiles";
            identityServerAuthenticationOptions.AutomaticAuthenticate = true;
            // required if you want to return a 403 and not a 401 for forbidden responses
            identityServerAuthenticationOptions.AutomaticChallenge = true;

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            app.UseIdentityServerAuthentication(identityServerAuthenticationOptions);

            app.UseMvc();
        }
开发者ID:damienbod,项目名称:AspNet5IdentityServerAngularImplicitFlow,代码行数:23,代码来源:Startup.cs

示例5: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IAntiforgery antiforgery, IHostingEnvironment env,
            ILoggerFactory loggerFactory)
        {
            app.UseIdentity() 
                .UseDeveloperAuthAuthentication(
                    new DeveloperAuthOptions()
                    {
                        ConsumerKey = "uWkHwFNbklXgsLHYzLfRXcThw",
                        ConsumerSecret = "2kyg9WdUiJuU2HeWYJEuvwzaJWoweLadTgG3i0oHI5FeNjD5Iv"
                    })
                .UseTwitter2Authentication(
                    new Twitter2Options()
                    {
                        ConsumerKey = "uWkHwFNbklXgsLHYzLfRXcThw",
                        ConsumerSecret = "2kyg9WdUiJuU2HeWYJEuvwzaJWoweLadTgG3i0oHI5FeNjD5Iv"
                    });

            app.AddAllConfigureRegistrants();
            app.UseCookieAuthentication(options =>
            {
                options.LoginPath = new PathString("/Identity/Account/Login");
                options.LogoutPath = new PathString("/Identity/Account/LogOff");
            });

            /*
            app.UseProtectFolder(new ProtectFolderOptions
            {
                Path = "/Elm",
                PolicyName = "Authenticated"
            });
            */
            app.UseProtectLocalOnly(new ProtectLocalOnlyOptions());
            app.UseProtectPath(new ProtectPathOptions
            {
                PolicyName = "Authenticated"
            });

            app.UseElmPage(); // Shows the logs at the specified path
            app.UseElmCapture(); // Adds the ElmLoggerProvider

            loggerFactory.AddSerilog();
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                        .CreateScope())
                    {
#if ENTITY_IDENTITY
                        serviceScope.ServiceProvider.GetService<Pingo.Authorization.Models.ApplicationDbContext>()
                            .Database.Migrate();
#endif
                    }
                }
                catch
                {
                }
            }

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            // due to an JWT defect we cannot be an IdentityServer4 and provide APIs 
            //app.UseIdentityServer();

            app.UseCors(policy =>
            {
                policy.WithOrigins(
                    "http://localhost:28895",
                    "http://localhost:14016",
                    "http://localhost:7017");

                policy.AllowAnyHeader();
                policy.AllowAnyMethod();
            });
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            app.UseIdentityServerAuthentication(options =>
            {
                options.Authority = WebApplication1.IdentityServerClients.Configuration.Constants.BaseAddress;
                options.ScopeName = "api1";
                options.ScopeSecret = "secret";

                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = true;
            });

            app.UseStaticFiles();

//.........这里部分代码省略.........
开发者ID:ghstahl,项目名称:vNext.Jan2016Web,代码行数:101,代码来源:Startup.cs

示例6: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseCors(policy =>
            {
                policy.WithOrigins("http://localhost:28895", "http://localhost:7017");
                policy.AllowAnyHeader();
                policy.AllowAnyMethod();
            });

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            app.UseIdentityServerAuthentication(options =>
            {
                //Url of the IT4GOV.IdentityServer
                options.Authority = URLS.Idt_url;
                options.ScopeName = "api1";
                options.ScopeSecret = "secret";

                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = true;
            });

            app.UseMvc();
        }
开发者ID:Charmatzis,项目名称:IT4GOV,代码行数:33,代码来源:Startup.cs

示例7: UseIdentityServerSecurity

        private void UseIdentityServerSecurity(IApplicationBuilder app)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimFilter.Clear();

            app.UseIdentityServerAuthentication(options =>
            {
                options.Authority = "http://localhost:5001/";
                options.ScopeName = "api";
                options.ScopeSecret = "apisecret";

                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = true;
            });
        }
开发者ID:thinktecture,项目名称:nodejs-aspnetcore-webapi,代码行数:14,代码来源:Startup.cs


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