Skip to content

Commit 60592eb

Browse files
Merge pull request #566 from TransactionProcessing/task/#557_trace_review
trace improvements
2 parents 4ab7417 + f06fd50 commit 60592eb

25 files changed

Lines changed: 118 additions & 53 deletions

File tree

48 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Certificates/aspnetapp-web-api.pfx

48 Bytes
Binary file not shown.

SecurityService.BusinessLogic/RequestHandlers/UserRequestHandler.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.AspNetCore.Identity;
2020
using Microsoft.EntityFrameworkCore;
2121
using Requests;
22+
using SecurityService.Models;
2223
using Shared.Exceptions;
2324
using Shared.General;
2425
using Shared.Logger;
@@ -27,7 +28,7 @@
2728
public class UserRequestHandler : IRequestHandler<CreateUserRequest>,
2829
IRequestHandler<GetUserRequest, UserDetails>,
2930
IRequestHandler<GetUsersRequest, List<UserDetails>>,
30-
IRequestHandler<ChangeUserPasswordRequest, (Boolean, String)>,
31+
IRequestHandler<ChangeUserPasswordRequest, ChangeUserPasswordResult>,
3132
IRequestHandler<ConfirmUserEmailAddressRequest, Boolean>,
3233
IRequestHandler<ProcessPasswordResetConfirmationRequest, String>,
3334
IRequestHandler<ProcessPasswordResetRequest>,
@@ -229,15 +230,15 @@ public async Task<List<UserDetails>> Handle(GetUsersRequest request, Cancellatio
229230
return response;
230231
}
231232

232-
public async Task<(Boolean, String)> Handle(ChangeUserPasswordRequest request, CancellationToken cancellationToken){
233+
public async Task<ChangeUserPasswordResult> Handle(ChangeUserPasswordRequest request, CancellationToken cancellationToken){
233234
// Find the user based on the user name passed in
234235
IdentityUser user = await this.UserManager.FindByNameAsync(request.UserName);
235236

236237
if (user == null){
237238
// TODO: Redirect to a success page so the user doesnt know if the username is correct or not,
238239
// this prevents giving away info to a potential hacker...
239240
// TODO: maybe log something here...
240-
return (false, String.Empty);
241+
return new ChangeUserPasswordResult { IsSuccessful = false };
241242
}
242243

243244
IdentityResult result = await this.UserManager.ChangePasswordAsync(user,
@@ -246,39 +247,39 @@ public async Task<List<UserDetails>> Handle(GetUsersRequest request, Cancellatio
246247

247248
if (result.Succeeded == false){
248249
// Log any errors
249-
Logger.LogWarning($"Errors during password change for user [{request.UserName} and Client [{request.ClientId}]");
250+
Logger.LogInformation($"Errors during password change for user [{request.UserName} and Client [{request.ClientId}]");
250251
foreach (IdentityError identityError in result.Errors){
251-
Logger.LogWarning($"Code {identityError.Code} Description {identityError.Description}");
252+
Logger.LogInformation($"Code {identityError.Code} Description {identityError.Description}");
252253
}
253254
}
254255

255256
// build the redirect uri
256257
Client client = await this.ConfigurationDbContext.Clients.SingleOrDefaultAsync(c => c.ClientId == request.ClientId, cancellationToken:cancellationToken);
257258

258259
if (client == null){
259-
Logger.LogWarning($"Client not found for clientId {request.ClientId}");
260+
Logger.LogInformation($"Client not found for clientId {request.ClientId}");
260261
// TODO: need to redirect somewhere...
261-
return (false, String.Empty);
262+
return new ChangeUserPasswordResult { IsSuccessful = false };
262263
}
263264

264-
Logger.LogWarning($"Client uri {client.ClientUri}");
265-
return (true, client.ClientUri);
265+
Logger.LogDebug($"Client uri {client.ClientUri}");
266+
return new ChangeUserPasswordResult { IsSuccessful = true, RedirectUri = client.ClientUri};
266267
}
267268

268269
public async Task<Boolean> Handle(ConfirmUserEmailAddressRequest request, CancellationToken cancellationToken){
269270
IdentityUser identityUser = await this.UserManager.FindByNameAsync(request.UserName);
270271

271272
if (identityUser == null){
272-
Logger.LogWarning($"No user found with username {request.UserName}");
273+
Logger.LogInformation($"No user found with username {request.UserName}");
273274
return false;
274275
}
275276

276277
IdentityResult result = await this.UserManager.ConfirmEmailAsync(identityUser, request.ConfirmEmailToken);
277278

278279
if (result.Succeeded == false){
279-
Logger.LogWarning($"Errors during confirm email for user [{request.UserName}");
280+
Logger.LogInformation($"Errors during confirm email for user [{request.UserName}");
280281
foreach (IdentityError identityError in result.Errors){
281-
Logger.LogWarning($"Code {identityError.Code} Description {identityError.Description}");
282+
Logger.LogInformation($"Code {identityError.Code} Description {identityError.Description}");
282283
}
283284
}
284285

@@ -293,7 +294,7 @@ public async Task<String> Handle(ProcessPasswordResetConfirmationRequest request
293294
// TODO: Redirect to a success page so the user doesnt know if the username is correct or not,
294295
// this prevents giving away info to a potential hacker...
295296
// TODO: maybe log something here...
296-
Logger.LogWarning($"user not found for username {request.Username}");
297+
Logger.LogInformation($"user not found for username {request.Username}");
297298
return String.Empty;
298299
}
299300

@@ -302,17 +303,17 @@ public async Task<String> Handle(ProcessPasswordResetConfirmationRequest request
302303
// handle the result...
303304
if (result.Succeeded == false){
304305
// Log any errors
305-
Logger.LogWarning($"Errors during password reset for user [{request.Username} and Client [{request.ClientId}]");
306+
Logger.LogInformation($"Errors during password reset for user [{request.Username} and Client [{request.ClientId}]");
306307
foreach (IdentityError identityError in result.Errors){
307-
Logger.LogWarning($"Code {identityError.Code} Description {identityError.Description}");
308+
Logger.LogInformation($"Code {identityError.Code} Description {identityError.Description}");
308309
}
309310
}
310311

311312
// build the redirect uri
312313
Client client = await this.ConfigurationDbContext.Clients.SingleOrDefaultAsync(c => c.ClientId == request.ClientId, cancellationToken:cancellationToken);
313314

314315
if (client == null){
315-
Logger.LogWarning($"Client not found for clientId {request.ClientId}");
316+
Logger.LogInformation($"Client not found for clientId {request.ClientId}");
316317
// TODO: need to redirect somewhere...
317318
return String.Empty;
318319
}

SecurityService.BusinessLogic/Requests/ChangeUserPasswordRequest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
namespace SecurityService.BusinessLogic.Requests
88
{
99
using MediatR;
10+
using SecurityService.Models;
1011

11-
public class ChangeUserPasswordRequest :IRequest<(Boolean,String)>
12+
public class ChangeUserPasswordRequest :IRequest<ChangeUserPasswordResult>
1213
{
1314
public String UserName{ get; }
1415
public String CurrentPassword{ get; }

SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.3" />
1010
<PackageReference Include="Duende.IdentityServer.Storage" Version="7.0.3" />
1111
<PackageReference Include="MediatR" Version="12.2.0" />
12-
<PackageReference Include="MessagingService.Client" Version="2024.3.1" />
12+
<PackageReference Include="MessagingService.Client" Version="2024.4.2" />
1313
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
1414
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.3" />
1515
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.3" />
16-
<PackageReference Include="Shared" Version="2024.4.1" />
16+
<PackageReference Include="Shared" Version="2024.7.1" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

SecurityService.Client/SecurityService.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="ClientProxyBase" Version="2024.4.1" />
9+
<PackageReference Include="ClientProxyBase" Version="2024.7.1" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

SecurityService.Database/SecurityService.Database.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
</PackageReference>
2323
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
24-
<PackageReference Include="Shared" Version="2024.4.1" />
24+
<PackageReference Include="Shared" Version="2024.7.1" />
2525
</ItemGroup>
2626
<ItemGroup>
2727
<Folder Include="DbContexts\" />

SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!--<PackageReference Include="Reqnroll" Version="1.0.1" />-->
1919
<!--<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="1.0.1" />
2020
<PackageReference Include="Reqnroll.xUnit" Version="1.0.1" />-->
21-
<PackageReference Include="Shared.IntegrationTesting" Version="2024.4.1" />
21+
<PackageReference Include="Shared.IntegrationTesting" Version="2024.7.1" />
2222
<!--<PackageReference Include="Shouldly" Version="4.2.1" />-->
2323
<!--<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
2424
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)