我正在遵循ID Server 4的快速入门,但有一个例外,我在使用.NET Core 2.1.302的Mac上工作。我以某种方式导航到http://localhost:5000/.well-known/openid-configuration
时得到404:
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:5000/.well-known/openid-configuration
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.108ms 404
这是我采取的步骤:
dotnet new mvc
dotnet add package IdentityServer4
通过添加修改了我的服务配置
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients());
使用以下代码创建Config.cs:
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("api1", "My API")
};
}
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" }
}
};
当我导航到http://localhost:5000/.well-known/openid-configuration时,我得到的是404而不是发现文档。有什么想法吗?
答案 0 :(得分:7)
步骤列表中缺少的是在UseIdentityServer
的{{1}}方法中添加Startup
。官方docs对此进行了介绍,看起来像这样:
Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// ...
app.UseIdentityServer();
app.UseMvc(...);
}
将IdentityServer中间件添加到ASP.NET Core管道中。它的职责之一是为。众所周知的端点服务。