簡體   English   中英

IdentityServer4發現文檔返回404

[英]IdentityServer4 discovery document returns 404

我正在遵循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 

這是我采取的步驟:

  1. 創建了一個新的MVC項目dotnet new mvc
  2. 添加了ID Server dotnet add package IdentityServer4
  3. 通過添加修改我的服務配置

      services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryApiResources(Config.GetApiResources()) .AddInMemoryClients(Config.GetClients()); 
  4. 創建的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而不是發現文檔。 有任何想法嗎?

步驟列表中缺少的是在StartupConfigure方法內部添加UseIdentityServer 它包含在官方文檔中 ,看起來像這樣:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    // ...

    app.UseIdentityServer();
    app.UseMvc(...);
}

UseIdentityServer將IdentityServer中間件添加到ASP.NET Core管道中。 它的職責之一是為。眾所周知的端點服務。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM