Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debug OWIN auth middleware

Is there a way to debug OWIN middleware from extensions like WindowsAzureActiveDirectoryBearerAuthenticationOptions and see exactly why the request was rejected (e.g. no token, wrong resource id, invalid signature, …) ?

like image 532
xtofs Avatar asked Mar 03 '17 23:03

xtofs


1 Answers

One thing you can do is enable logging in OWIN:

<configuration>
  <system.diagnostics>
    <switches>
      <add name="Microsoft.Owin" value="Verbose" />
    </switches>
  </system.diagnostics>
</configuration>

I sent an expired token to my API and got this in the Output:

Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationMiddleware Error: 0 : Authentication failed

System.IdentityModel.Tokens.SecurityTokenExpiredException: IDX10223: Lifetime validation failed. The token is expired.

More info about configuring OWIN logging: http://www.tugberkugurlu.com/archive/logging-in-the-owin-world-with-microsoft-owin--introduction.

like image 51
juunas Avatar answered Sep 29 '22 02:09

juunas