本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
//.........这里部分代码省略.........
示例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();
}
示例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;
});
}