-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from steve-bang/dev
Merge CICD
- Loading branch information
Showing
802 changed files
with
47,855 additions
and
2,890 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@Host = https://localhost:7159/api/v1/auth | ||
|
||
|
||
### Register | ||
POST {{Host}}/register | ||
Accept: application/json | ||
Content-Type: application/json | ||
|
||
{ | ||
"emailAddress" : "[email protected]", | ||
"password" : "password", | ||
"confirmPassword" : "password" | ||
} | ||
|
||
### Login user | ||
POST {{Host}}/login | ||
Accept: application/json | ||
Content-Type: application/json | ||
|
||
{ | ||
"emailAddress" : "[email protected]", | ||
"password" : "password" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@Host = https://localhost:7159/api/v1/roles | ||
@UserId = a9ad6829-10f7-404e-224f-08dd2274641d | ||
|
||
|
||
### Add new role | ||
POST {{Host}} | ||
Accept: application/json | ||
Content-Type: application/json | ||
|
||
{ | ||
"name" : "Contributor", | ||
"description" : "Grants full access to manage all resources, but does not allow you to assign roles in Azure RBAC, manage assignments in Azure Blueprints, or share image galleries." | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@Host = https://localhost:7159/api/v1/users | ||
@UserId = a9ad6829-10f7-404e-224f-08dd2274641d | ||
@BearerToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImE5YWQ2ODI5LTEwZjctNDA0ZS0yMjRmLTA4ZGQyMjc0NjQxZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6Im1yc3RldmVAZXhhbXBsZS5jb20iLCJleHAiOjE3MzU4NTUzNjUsImlzcyI6Imh0dHBzOi8vYXV0aHplcm8uY29tIiwiYXVkIjoiaHR0cHM6Ly9hdXRoemVyby5jb20ifQ.Rag8ymY4KWBBBLsHdbPC-M95EgrrjC4HUS7hzHihDWU | ||
|
||
|
||
### Get user by Id | ||
GET {{Host}}/{{UserId}} | ||
Accept: application/json | ||
Content-Type: application/json | ||
Authorization: Bearer {{BearerToken}} | ||
|
||
|
||
|
||
### Update user's data by Id | ||
PATCH {{Host}}/{{UserId}} | ||
Accept: application/json | ||
Content-Type: application/json | ||
Authorization: Bearer {{BearerToken}} | ||
|
||
{ | ||
"firstName" : "Steve", | ||
"lastName" : "Smith", | ||
"bio": "I am a software developer", | ||
"avatarUrl": "https://example.com/avatar.jpg" | ||
} | ||
|
||
|
||
### Assign roles to user | ||
POST {{Host}}/{{UserId}}/roles | ||
Accept: application/json | ||
Content-Type: application/json | ||
Authorization: Bearer {{BearerToken}} | ||
|
||
{ | ||
"roles": ["760a2dfc-7114-47dd-d257-08dd297fd518", "327db532-0652-479b-d258-08dd297fd518"] | ||
} | ||
|
||
### Get user's roles | ||
GET {{Host}}/{{UserId}}/roles | ||
Accept: application/json | ||
Content-Type: application/json | ||
Authorization: Bearer {{BearerToken}} | ||
|
||
|
||
### Remove roles from user | ||
DELETE {{Host}}/{{UserId}}/roles | ||
Accept: application/json | ||
Content-Type: application/json | ||
Authorization: Bearer {{BearerToken}} | ||
|
||
{ | ||
"roles": ["760a2dfc-7114-47dd-d257-08dd297fd518"] | ||
} | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
| ||
Microsoft (R) SQLServerAgent 16.0.4165.4 | ||
Copyright (C) 2022 Microsoft Corporation. All rights reserved. | ||
|
||
SQLAgent is disabled | ||
SQLAgent is exiting |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 0 additions & 14 deletions
14
...untService/AuthAero.AccountService.Application/AuthAero.AccountService.Application.csproj
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/AuthZero.AccountService/AuthAero.AccountService.Application/Class1.cs
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-8 KB
...e/AuthAero.AccountService.Application/bin/Debug/net8.0/AuthZero.AccountService.Domain.dll
Binary file not shown.
Binary file removed
BIN
-22.5 KB
...ro.AccountService.Application/bin/Debug/net8.0/AuthZero.AccountService.Infrastructure.dll
Binary file not shown.
1 change: 0 additions & 1 deletion
1
...Application/obj/Debug/net8.0/AuthAero.AccountService.Application.AssemblyInfoInputs.cache
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...lication/obj/Debug/net8.0/AuthAero.AccountService.Application.csproj.FileListAbsolute.txt
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...untService/AuthZero.AccountService.Application/AuthZero.AccountService.Application.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../../AuthZero.AppHost.Shared/AuthZero.AppHost.Shared.csproj" /> | ||
<ProjectReference Include="../../AuthZero.Shared/AuthZero.Shared.csproj" /> | ||
<ProjectReference Include="../AuthZero.AccountService.Domain/AuthZero.AccountService.Domain.csproj" /> | ||
<ProjectReference Include="../AuthZero.AccountService.Infrastructure/AuthZero.AccountService.Infrastructure.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Aspire.Confluent.Kafka" Version="9.0.0" /> | ||
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
29 changes: 29 additions & 0 deletions
29
src/AuthZero.AccountService/AuthZero.AccountService.Application/DependencyInjection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using AuthZero.AppHost.Shared.Constants; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace AuthZero.AccountService.Application; | ||
|
||
public static class DependencyInjection | ||
{ | ||
public static IHostApplicationBuilder AddApplication(this IHostApplicationBuilder builder) | ||
{ | ||
// Add the MediatR services | ||
builder.Services.AddMediatR(config => | ||
{ | ||
// Register all the handlers from the current assembly | ||
config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly); | ||
|
||
// Register the ValidationBehavior | ||
//config.AddOpenBehavior(typeof(ValidationBehaviour<,>)); | ||
}); | ||
|
||
// Add the Kafka services | ||
builder.AddKafkaProducer<string, string>(Names.KafkaMessages); | ||
|
||
// Add Redis services | ||
builder.AddRedisDistributedCache("caching"); | ||
|
||
return builder; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...rvice/AuthZero.AccountService.Application/DomainEventHandlers/UserRegisterEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
|
||
using AuthZero.AccountService.Domain.Events; | ||
using AuthZero.AppHost.Shared.Messages; | ||
using Confluent.Kafka; | ||
|
||
|
||
namespace AuthZero.AccountService.Application.DomainEventHandlers; | ||
|
||
|
||
|
||
public class UserRegisterEventHandler( | ||
IProducer<string, string> _messageProducer | ||
) : INotificationHandler<UserRegisterEvent> | ||
{ | ||
|
||
public async Task Handle(UserRegisterEvent notification, CancellationToken cancellationToken) | ||
{ | ||
var message = new Message<string, string>{ Key = notification.User.Id.ToString(), Value = notification.User.EmailAddress, Timestamp = new Timestamp(DateTimeOffset.UtcNow) }; | ||
|
||
var result = await _messageProducer.ProduceAsync(Topics.UserRegisterSuccess, message); | ||
|
||
if (result.Status != PersistenceStatus.Persisted) | ||
{ | ||
throw new Exception("Failed to produce message"); | ||
} | ||
|
||
Console.WriteLine($"Produced message to topic {result.Topic}, partition {result.Partition}, offset {result.Offset}"); | ||
|
||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ro.AccountService/AuthZero.AccountService.Application/Features/Commands/AddRoleCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
public record AddRoleCommand( | ||
string Name, | ||
string Description | ||
) : IRequest<Guid>; |
20 changes: 20 additions & 0 deletions
20
...untService/AuthZero.AccountService.Application/Features/Commands/AddRoleCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
using AuthZero.AccountService.Domain.AggregatesModel; | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
public class AddRoleCommandHandler( | ||
IRoleRepository _roleRepository | ||
) : IRequestHandler<AddRoleCommand, Guid> | ||
{ | ||
public async Task<Guid> Handle(AddRoleCommand request, CancellationToken cancellationToken) | ||
{ | ||
|
||
|
||
var role = await _roleRepository.AddAsync(new Role(request.Name, request.Description)); | ||
|
||
await _roleRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); | ||
|
||
return role.Id; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...AccountService/AuthZero.AccountService.Application/Features/Commands/AssignRoleCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
public record AssignRoleCommand( | ||
Guid UserId, | ||
Guid[] Roles | ||
) : IRequest<bool>; |
36 changes: 36 additions & 0 deletions
36
...Service/AuthZero.AccountService.Application/Features/Commands/AssignRoleCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
using AuthZero.AccountService.Domain.AggregatesModel; | ||
using AuthZero.Shared.Exceptions; | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
public record AssignRoleCommandHandler( | ||
IRoleRepository _roleRepository, | ||
IUserRepository _userRepository | ||
) : IRequestHandler<AssignRoleCommand, bool> | ||
{ | ||
|
||
public async Task<bool> Handle(AssignRoleCommand request, CancellationToken cancellationToken) | ||
{ | ||
var user = await _userRepository.GetByIdAsync(request.UserId); | ||
if (user == null) | ||
{ | ||
throw new NotFoundDataException(nameof(User), "User.NotFound"); | ||
} | ||
|
||
var roles = await _roleRepository.GetRolesByIdsAsync(request.Roles); | ||
|
||
if (roles == null) | ||
{ | ||
throw new NotFoundDataException(nameof(Role), "Role.NotFound"); | ||
} | ||
|
||
user.AssignRoles(roles); | ||
|
||
_userRepository.Update(user); | ||
|
||
bool result = await _userRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); | ||
|
||
return result; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...o.AccountService/AuthZero.AccountService.Application/Features/Commands/EditUserCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
public record EditUserCommand( | ||
Guid Id, | ||
string AvatarUrl, | ||
string Bio, | ||
string FirstName, | ||
string LastName | ||
) : IRequest<bool>; |
28 changes: 28 additions & 0 deletions
28
...ntService/AuthZero.AccountService.Application/Features/Commands/EditUserCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
using AuthZero.Shared.Exceptions; | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
public class EditUserCommandHandler( | ||
IUserRepository _userRepository | ||
) : IRequestHandler<EditUserCommand, bool> | ||
{ | ||
public async Task<bool> Handle(EditUserCommand request, CancellationToken cancellationToken) | ||
{ | ||
User? user = await _userRepository.GetByIdAsync(request.Id); | ||
|
||
if(user is null) | ||
throw new NotFoundDataException("User", "User.NotFound"); | ||
|
||
user.Edit( | ||
avatarUrl: request.AvatarUrl, | ||
bio: request.Bio, | ||
firstName: request.FirstName, | ||
lastName: request.LastName | ||
); | ||
|
||
await _userRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); | ||
|
||
return true; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
....AccountService/AuthZero.AccountService.Application/Features/Commands/LoginUserCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
namespace AuthZero.AccountService.Application.Features.Commands; | ||
|
||
/// <summary> | ||
/// Login a user. | ||
/// </summary> | ||
/// <param name="EmailAddress">The email address of the user.</param> | ||
/// <param name="Password">The password of the user.</param> | ||
public record LoginUserCommand( | ||
string EmailAddress, | ||
string Password | ||
) : IRequest<ResultUserLoginSuccess>; |
Oops, something went wrong.