我正在尝试在同一启动中共同托管Identityserver3和Web api(用于使用Bearer令牌的用户管理).但是我收到以下错误: 任务已取消. 似乎在尝试调用 identity_local/core/.well时,启动时发生了任务取消-known/openid-configuration (identity_local指向本地主机).
I am trying to co-host identityserver3 and web api (for user management using Bearer tokens) in the same startup. However I get the following error: A task was canceled. It appears the task cancellation occurs on startup when trying to call identity_local/core/.well-known/openid-configuration (identity_local points to localhost).
我的启动如下:
app.Map("/core", idsrvApp => { var factory = new IdentityServerServiceFactory(); factory.UserService = new IdentityServer3.Core.Configuration.Registration<IUserService, UserService>(); factory.ScopeStore = new IdentityServer3.Core.Configuration.Registration<IScopeStore>(resolver => scopeStore); var options = new IdentityServerOptions { SigningCertificate = Certificate.Load(), IssuerUri = "identity_local/core", PublicOrigin = "identity_local", RequireSsl = false, //for now Factory = factory, }; idsrvApp.UseIdentityServer(options); }); app.Map("/admin", adminApp => { adminApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions { Authority = "identity_local/core", IssuerName = "identity_local", ValidationMode = ValidationMode.Local, RequiredScopes = new[] { "api", "roles" } }); adminApp.UseResourceAuthorization(new AuthorisationManager()); var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); adminApp.UseCors(CorsOptions.AllowAll); adminApp.UseWebApi(config); });有人知道a)是否可以在同一启动中同时运行b)如果是这样,我做错了什么或者我该怎么做才能解决上述问题.
Does anyone know if a) it is possible to have both in the same startup and b) if so, what have I done wrong or what can I do to remedy the above.
推荐答案在启动时,UseIdentityServerBearerTokenAuthentication尝试联系IdentityServer元数据端点,但是由于服务器尚未运行,它无法连接,因此出现错误.
At startup time the UseIdentityServerBearerTokenAuthentication tries to contact the IdentityServer metatadata endpoint, but since the server is not yet running it can't connect, thus an error.
在这种情况下,有一个名为DelayLoadMetadata的标志将元数据的加载延迟到第一次需要时: identityserver.github.io/Documentation/docsv2/using/options.html
For this situation, there's a flag called DelayLoadMetadata to delay load the metadata until the first time it's needed: identityserver.github.io/Documentation/docsv2/consuming/options.html
更多推荐
任务已取消
发布评论