Closed jamal closed 7 years ago
Are you sure it's not a caching issue in the middleware in the API? For example, if you change something and restart the app, the in-mem key is changed and then the web api is still using the prior cached one.
@brockallen Yeah, I checked a few times to make sure this was not the case. Even switched to using a cert file instead of using temporary signing.
In that case, I don't know. More debugging is needed. Do the samples work for you? Also, can you see the keys in the discovery document?
Still an issue?
Yes. Still an issue. I have the same problem. If you configure "AddMvcCore" instead of "AddMvc" to get it to work. I had sort of the same configuration as the IdentityServer4.Sample Javascript client example.
Perhaps a Mvc configuration issue?
What happens when you add app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
before app.UseMvc(
?
You are missing the Authority property in the code sample above.
services.AddMvc()
instead of services.AddMvcCore().AddAuthorization().AddJsonFormatters()
as demonstrated in the branch mvc works fine.
The order in configure as demonstrated in the branch order in configure does not work.
Perhaps there should be documentation about the order?
Which order?
Of course the authentication MW must come before MVC. The pipeline is a linked list.
Or is there a different issue?
Yes, well, it was not obvious to someone who is new to MVC core that's how it works.
Yes, well, it was not obvious to someone who is new to MVC core that's how it works.
That's one of the most fundamental aspects of the middleware/pipeline design. That's beyond our purview, IMO.
I apologize about the delay in response to this ticket. I agree that documenting the order is not necessary, this is a well understood concept for anyone who has worked with a similar Middleware model.
I also wanted to add that my issue isn't due to the order. UseMvc is the last directive in my configuration. I will have to try AddMvcCore instead and see if it makes a difference.
In the meantime, I have worked around the issue by configuring the JwtBearer middleware directly, so IS is only handling the token endpoint in my case for now.
So are you saying the the MS JWT MW can validate the token - but ours can't.
This would surprise me - since internally we are using the MS JWT MW.
I'm trying to set up IdentityServer4.AccessTokenValidation, but it's failing to validate the signature from a token generated by by IdentityServer.
Here's the error and stacktrace
The token I am using:
I attempted using both an X509 cert and the temporary cert, but both fail with the same issue. I was able to manually set up the MS JWT Middleware with the X509 cert and get that working, but using the IS4 Middleware failed.
Here's an example of what I mean: