IdentityServer / IdentityServer3.AccessTokenValidation

OWIN Middleware to validate access tokens from IdentityServer3
Apache License 2.0
90 stars 149 forks source link

"ScopeRequirementMiddleware.cs not found" error #30

Closed iltera closed 9 years ago

iltera commented 9 years ago

I am getting this error at the end of a WebApi controller which is decorated with Authorize attribute. Why do I get it? It shows the file paths of @brockallen's computer I guess :)

Locating source for 'c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs'. Checksum: MD5 {20 5d 3d 8e 5b ac e4 7c 85 72 34 3b 64 9 ab d0} The file 'c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs' does not exist. Looking in script documents for 'c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs'... Looking in the projects for 'c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs'. The file was not found in a project. Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\crt\src\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\crt\src\vccorlib\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\mfc\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\atl\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include'... The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs. The debugger could not locate the source file 'c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs'.

It just happens during debugging. If don't put a breakpoint in the controller, I don't get it. But the GET request to that controller gives an error anyway.

brockallen commented 9 years ago

That looks more like @leastprivilege 's machine.

As for why -- not sure. This is just during normal debugging? So it's not like there's an error, right?

iltera commented 9 years ago

No, there're no errors now. I forgot to add a table at the db, so EntityFramework wasn't please with the ajax request. After fixing it, that error also went away. Strange, though... Anyway, closing that issue.

marvin-hinkley commented 9 years ago

This may have to be re-opened. I am receiving an identical error in almost exactly the same scenario. The only difference is that I'm using my own custom identity provider.

The provider returns the correct, valid record and web api then goes to return it as usual. At that point, I receive the above mentioned error and visual studio prompts me to find "c:\etc\Dropbox\identity\IdentityServer3\AccessTokenValidation\source\AccessTokenValidation\ScopeRequirementMiddleware.cs" via a file dialog box.

There are no abnormalities present in the idsrv3 logs or the IIS logs, failed request trace logs. I have tried debugging on both IIS Express and local IIS with the same result.

Workflow:

  1. Angular client authenticates with IDSRV3 via implicit flow
  2. Angular client receives sub (unique user GUID) from userinfo endpoint
  3. Angular client requests extended user information from web API with sub
  4. Web API receives and processes request correctly until IDSRV3 validation throws above error
  5. Angular client receives HTTP 500 error
leastprivilege commented 9 years ago

That's the normal behavior when debugging - since VS can't find the source automatically it will prompt you. Have you tried running without a debugger?

marvin-hinkley commented 9 years ago

Although I am always leery of issues which mysteriously resolve themselves, this appears to have happened in this case. No changes in code, debugging, or environment. It just started working.

Any idea what might cause the erroneous behavior? it's obviously something fairly constant as both iltera's and my situation seem incredibly similar.

iltera commented 9 years ago

I am still only getting this behaviour when my controllers (WebApi) have issues of some kind (mostly EF). When I fix it debugger no longer enters the "ScopeRequirementMiddleware.cs" file anymore.

leastprivilege commented 9 years ago

It's a red herring. The middleware is on the call stack - hence the message. The error occurred somewhere else.