Не удалось загрузить http://localhost:5000/.well-known/openid-configuration: в запрошенном ресурсе отсутствует заголовокC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Не удалось загрузить http://localhost:5000/.well-known/openid-configuration: в запрошенном ресурсе отсутствует заголовок

Сообщение Anonymous »

Я новичок в Identityserver4, недавно я видел образец Quickstart8, предоставленный командой IdentityServer, в который включены 3 проекта: 1.Identityserver
2. Все Api 3.Client работают нормально в браузере, когда я развернул их в iis, они работают неправильно, отображается ошибка типа...

Изображение


Я использую клиент JavaScript...

Пожалуйста, помогите мне с этой проблемой.

Это мой код...

Api (startup.cs)

Код: Выделить всё

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace Api
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvcCore()
.AddAuthorization()
.AddJsonFormatters();
services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = "http://localhost:5000";
options.RequireHttpsMetadata = false;

options.ApiName = "api1";
});

services.AddCors(options =>
{
// this defines a CORS policy called "default"
options.AddPolicy("default", policy =>
{
policy.WithOrigins("http://localhost:5003")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
}

public void Configure(IApplicationBuilder app)
{
app.UseCors("default");

app.UseAuthentication();

app.UseMvc();
}
}


Api (контроллер удостоверений)

Код: Выделить всё

[Route("[controller]")]
[Authorize]
public class IdentityController : ControllerBase
{
[HttpGet]
public IActionResult Get()
{
return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
}
}
QuickstartIdentityServer (startup.cs)

Код: Выделить всё

 public class Startup
{

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

string connectionString = @"Data Source=DOTNET-Foo;Initial Catalog=IdentityServer4;Integrated Security=True";
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

// configure identity server with in-memory stores, keys, clients and scopes
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddTestUsers(Config.GetUsers())
// this adds the config data from DB (clients, resources)
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
});
// this adds the operational data from DB (codes, tokens, consents)
//.AddOperationalStore(options =>
//{
//    options.ConfigureDbContext = builder =>
//        builder.UseSqlServer(connectionString,
//            sql => sql.MigrationsAssembly(migrationsAssembly));

//    // this enables automatic token cleanup.  this is optional.
//    options.EnableTokenCleanup = true;
//    options.TokenCleanupInterval = 30;
//});

services.AddAuthentication()
.AddGoogle("Google", options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;

options.ClientId = "434483408261-55tc8n0cs4ff1fe21ea8df2o443v2iuc.apps.googleusercontent.com";
options.ClientSecret = "3gcoTrEDPPJ0ukn_aYYT6PWo";
})
.AddOpenIdConnect("oidc", "OpenID Connect", options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.SignOutScheme = IdentityServerConstants.SignoutScheme;

options.Authority = "https://demo.identityserver.io/";
options.ClientId = "implicit";

options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
};
});

}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
// IdentityServerDatabaseInitialization.InitializeDatabase(app);
}
app.UseIdentityServer();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
}
Я не могу получить доступ к http://localhost:5000/.well-known/openid-configuration
Изображение


Подробнее здесь: https://stackoverflow.com/questions/515 ... n-no-acces
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»