Используя Identity Server 3, я пытаюсь настроить CORS в соответствии с документацией. . Когда я выполняю запрос GET
, я вижу, что ответ, полученный в Fiddler, правильный и не имеет заголовка Access-Control-Allow-Origin.
Вот код, используемый для настройки IdentityServerOptions
:
public void Configuration(IAppBuilder app)
{
var factory = InMemoryFactory.Create(
clients: Clients.Get(),
scopes: Scopes.Get());
var viewOptions = new DefaultViewServiceOptions();
viewOptions.Stylesheets.Add("/Content/site.css");
viewOptions.Scripts.Add("/Content/logon.js");
viewOptions.CacheViews = false;
factory.ConfigureDefaultViewService(viewOptions);
// This is where the CORS policy service is configured.
var corsPolicyService = new DefaultCorsPolicyService();
corsPolicyService.AllowAll = true;
factory.CorsPolicyService = new Registration<ICorsPolicyService>(corsPolicyService);
var userService = new LocalRegistrationUserService();
factory.UserService = new Registration<IUserService>(resolver => userService);
var options = new IdentityServerOptions
{
SiteName = "IdentityServer",
SigningCertificate = this.certificateProvider.Certificate,
Factory = factory,
RequireSsl = true,
// This is deprecated, but should still work according to the documentation.
// However using or not using it makes no change.
// CorsPolicy = CorsPolicy.AllowAll,
ProtocolLogoutUrls = logoutUrls,
AuthenticationOptions = new AuthenticationOptions()
{
EnableSignOutPrompt = false,
EnablePostSignOutAutoRedirect = true,
PostSignOutAutoRedirectDelay = 5,
},
};
app.Map("/core", idsrvApp =>
{
idsrvApp.UseIdentityServer(options);
});
}
Если я затем сделаю простой запрос GET
с другого сайта, я получу ответ:
HTTP/1.1 302 Found
Content-Length: 0
Location: https://federation.example.com/core/login?signin=2ce0b4f...71313af
Server: Microsoft-IIS/8.5
Set-Cookie: SignInMessage.2ce0b4f...A1D5NkPJQ; path=/core; secure; HttpOnly
X-Powered-By: ASP.NET
Date: Mon, 13 Jul 2015 12:00:00 GMT
Почему заголовок Access-Control-Allow-Origin не применяется?