任务被取消了

时间:2016-06-12 22:11:38

标签: identityserver3

我正在尝试在同一个启动中共同托管identityserver3和web api(用于使用Bearer令牌的用户管理)。但是我收到以下错误: 任务被取消了。 当尝试调用http://identity_local/core/.well-known/openid-configuration(identity_local指向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 = "http://identity_local/core",
                PublicOrigin = "http://identity_local",
                RequireSsl = false, //for now
                Factory = factory,
            };

            idsrvApp.UseIdentityServer(options);
        });

        app.Map("/admin", adminApp =>
        {
            adminApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority = "http://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)如果是这样,我做错了什么或我该怎么办才能解决上述问题。

1 个答案:

答案 0 :(得分:8)

在启动时,UseIdentityServerBearerTokenAuthentication尝试联系IdentityServer元数据端点,但由于服务器尚未运行,因此无法连接,因此出现错误。

对于这种情况,有一个名为DelayLoadMetadata的标记可以延迟加载元数据,直到第一次需要:https://identityserver.github.io/Documentation/docsv2/consuming/options.html

相关问题