hi i am facing a weird problem , CORS is working for all other functions except for one with [authorize] attribute. i am using openiddict for authorization with JWTmiddleware. Server is hosted on IIS8 and client application is in angular2. It displays following error.
XMLHttpRequest cannot load example.com/resource. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:58056' is therefore not allowed access.
Let me know if you want to see any specific code or need more information on it.
app.UseStaticFiles();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
loggerFactory.AddConsole();
app.UseIdentity();
app.UseSession();
app.UseGoogleAuthentication(new GoogleOptions
{
ClientId = "862227465575-q1spfclcfvflg4tpesfkle4e0jc3q987.apps.googleusercontent.com",
ClientSecret = "ozzg2VvH2TYbSbBYWE_HIYG5"
});
app.UseTwitterAuthentication(new TwitterOptions
{
ConsumerKey = "6XaCTaLbMqfj6ww3zvZ5g",
ConsumerSecret = "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI"
});
app.UseCors("AllowSpecificOrigin");
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
RequireHttpsMetadata = false
});
app.UseOpenIddict();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "spa-fallback",
template: "{*url}",
defaults: new { controller = "Home", action = "Index" });
});
Exception
Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException: IDX10 501: Signature validation failed. Unable to match 'kid': '7FG4SQ4TIATESTLI-ZDHTL RYPWIEDU_RA1FVG91D', token: '{"alg":"RS256","typ":"JWT","kid":"7FG4SQ4TIATESTLI-ZDHTLRYPWIEDU_RA1FVG9 1D"}