Browse Source

Update the client and validation stacks to log requests and responses

pull/1476/head 4.0.0-preview1
Kévin Chalet 4 years ago
parent
commit
9c1bdfb288
  1. 30
      src/OpenIddict.Abstractions/OpenIddictResources.resx
  2. 17
      src/OpenIddict.Client/OpenIddictClientService.cs
  3. 13
      src/OpenIddict.Validation/OpenIddictValidationService.cs

30
src/OpenIddict.Abstractions/OpenIddictResources.resx

@ -2293,6 +2293,36 @@ This may indicate that the hashed entry is corrupted or malformed.</value>
<data name="ID6185" xml:space="preserve">
<value>An unsupported {StatusCode} response was returned by the remote HTTP server: {ContentType} {Payload}.</value>
</data>
<data name="ID6186" xml:space="preserve">
<value>The configuration request was successfully sent to {Address}: {Request}.</value>
</data>
<data name="ID6187" xml:space="preserve">
<value>The configuration response returned by {Address} was successfully extracted: {Response}.</value>
</data>
<data name="ID6188" xml:space="preserve">
<value>The cryptography request was successfully sent to {Address}: {Request}.</value>
</data>
<data name="ID6189" xml:space="preserve">
<value>The cryptography response returned by {Address} was successfully extracted: {Response}.</value>
</data>
<data name="ID6190" xml:space="preserve">
<value>The introspection request was successfully sent to {Address}: {Request}.</value>
</data>
<data name="ID6191" xml:space="preserve">
<value>The introspection response returned by {Address} was successfully extracted: {Response}.</value>
</data>
<data name="ID6192" xml:space="preserve">
<value>The token request was successfully sent to {Address}: {Request}.</value>
</data>
<data name="ID6193" xml:space="preserve">
<value>The token response returned by {Address} was successfully extracted: {Response}.</value>
</data>
<data name="ID6194" xml:space="preserve">
<value>The userinfo request was successfully sent to {Address}: {Request}.</value>
</data>
<data name="ID6195" xml:space="preserve">
<value>The userinfo response returned by {Address} was successfully extracted: {Response}.</value>
</data>
<data name="ID8000" xml:space="preserve">
<value>https://documentation.openiddict.com/errors/{0}</value>
</data>

17
src/OpenIddict.Client/OpenIddictClientService.cs

@ -7,6 +7,7 @@
using System.Diagnostics;
using System.Security.Claims;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
namespace OpenIddict.Client;
@ -111,6 +112,8 @@ public class OpenIddictClientService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6186), context.Address, context.Request);
return context.Request;
}
@ -135,6 +138,8 @@ public class OpenIddictClientService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6187), context.Address, context.Response);
return context.Response;
}
@ -266,6 +271,8 @@ public class OpenIddictClientService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6188), context.Address, context.Request);
return context.Request;
}
@ -290,6 +297,8 @@ public class OpenIddictClientService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6189), context.Address, context.Response);
return context.Response;
}
@ -686,6 +695,8 @@ public class OpenIddictClientService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6192), context.Address, context.Request);
return context.Request;
}
@ -711,6 +722,8 @@ public class OpenIddictClientService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6193), context.Address, context.Response);
return context.Response;
}
@ -853,6 +866,8 @@ public class OpenIddictClientService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6194), context.Address, context.Request);
return context.Request;
}
@ -878,6 +893,8 @@ public class OpenIddictClientService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6195), context.Address, context.Response);
return (context.Response, context.UserinfoToken);
}

13
src/OpenIddict.Validation/OpenIddictValidationService.cs

@ -7,6 +7,7 @@
using System.Diagnostics;
using System.Security.Claims;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
namespace OpenIddict.Validation;
@ -100,6 +101,8 @@ public class OpenIddictValidationService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6186), context.Address, context.Request);
return context.Request;
}
@ -122,6 +125,8 @@ public class OpenIddictValidationService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6187), context.Address, context.Response);
return context.Response;
}
@ -240,6 +245,8 @@ public class OpenIddictValidationService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6188), context.Address, context.Request);
return context.Request;
}
@ -262,6 +269,8 @@ public class OpenIddictValidationService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6189), context.Address, context.Response);
return context.Response;
}
@ -398,6 +407,8 @@ public class OpenIddictValidationService
context.Error, context.ErrorDescription, context.ErrorUri);
}
context.Logger.LogInformation(SR.GetResourceString(SR.ID6190), context.Address, context.Request);
return context.Request;
}
@ -420,6 +431,8 @@ public class OpenIddictValidationService
Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID4007));
context.Logger.LogInformation(SR.GetResourceString(SR.ID6191), context.Address, context.Response);
return context.Response;
}

Loading…
Cancel
Save