-
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 #18 from zeroject/development
All services has been made and docker compose
- Loading branch information
Showing
134 changed files
with
3,788 additions
and
308 deletions.
There are no files selected for viewing
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,30 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md | ||
!**/.gitignore | ||
!.git/HEAD | ||
!.git/config | ||
!.git/packed-refs | ||
!.git/refs/heads/** |
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,44 @@ | ||
name: Build Docker Compose and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-release: | ||
name: Build Docker Compose and Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Build Docker Compose | ||
run: docker-compose build | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Push Docker Compose Image | ||
run: | | ||
docker-compose push | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ github.run_number }} | ||
release_name: Release v${{ github.run_number }} | ||
body: | | ||
Release for Docker Compose build. | ||
draft: false | ||
prerelease: false |
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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
<UserSecretsId>91784e22-c11d-473e-89d8-06b1c112882b</UserSecretsId> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AutoMapper" Version="13.0.1" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" /> | ||
<PackageReference Include="Seq.Extensions.Logging" Version="8.0.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> | ||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="BE\" /> | ||
<ProjectReference Include="..\Domain\Domain.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
namespace AuthenticationService.BE | ||
{ | ||
/// <summary> | ||
/// for validating. login. and EF purposes | ||
/// </summary> | ||
public class Login | ||
{ | ||
/// <summary> | ||
/// primary key for the user table | ||
/// </summary> | ||
public int Id { get; set; } | ||
|
||
/// <summary> | ||
/// identifier for the user | ||
/// </summary> | ||
required public string Username { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
required public string Password { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public virtual ICollection<Token>? Tokens { get; set; } | ||
} | ||
} |
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,41 @@ | ||
namespace AuthenticationService.BE | ||
{ | ||
/// <summary> | ||
/// EF Core object to hold token data linked to a user | ||
/// </summary> | ||
public class Token | ||
{ | ||
/// <summary> | ||
/// primary key for the token table | ||
/// </summary> | ||
public int Id { get; set; } | ||
|
||
/// <summary> | ||
/// the token string | ||
/// </summary> | ||
public required string JwtToken { get; set; } | ||
|
||
/// <summary> | ||
/// the user id linked to the token | ||
/// </summary> | ||
public int UserId { get; set; } | ||
|
||
/// <summary> | ||
/// time the token was created | ||
/// </summary> | ||
public DateTime CreatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// constructor for JwtToken to set the time the token was created | ||
/// </summary> | ||
public Token() | ||
{ | ||
CreatedAt = DateTime.Now; | ||
} | ||
|
||
/// <summary> | ||
/// ef magic to link the token to the user | ||
/// </summary> | ||
public virtual Login? User { get; set; } | ||
} | ||
} |
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
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,25 @@ | ||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | ||
USER app | ||
WORKDIR /app | ||
EXPOSE 8080 | ||
EXPOSE 8081 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
ARG BUILD_CONFIGURATION=Release | ||
WORKDIR /src | ||
COPY ["AuthenticationService/AuthenticationService.csproj", "AuthenticationService/"] | ||
RUN dotnet restore "./AuthenticationService/AuthenticationService.csproj" | ||
COPY . . | ||
WORKDIR "/src/AuthenticationService" | ||
RUN dotnet build "./AuthenticationService.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
||
FROM build AS publish | ||
ARG BUILD_CONFIGURATION=Release | ||
RUN dotnet publish "./AuthenticationService.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "AuthenticationService.dll"] |
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 AuthenticationService.BE; | ||
|
||
namespace AuthenticationService.Interfaces | ||
{ | ||
/// | ||
public interface IAuthRepo | ||
{ | ||
/// <summary> | ||
/// retrieves a user by their token | ||
/// </summary> | ||
/// <returns></returns> | ||
public Login GetUserByToken(string token); | ||
|
||
/// <summary> | ||
/// retrieves a user by their username to validate their password | ||
/// </summary> | ||
/// <param name="username"></param> | ||
/// <returns></returns> | ||
public Login GetUsersByUsername(string username); | ||
|
||
/// <summary> | ||
/// adds a token to the database | ||
/// </summary> | ||
/// <param name="token"></param> | ||
public void AddTokenToLogin(Token token); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="login"></param> | ||
/// <returns></returns> | ||
public Login AddLogin(Login login); | ||
|
||
public void Rebuild(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
AuthenticationService/Interfaces/IAuthValidationService.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,40 @@ | ||
using AuthenticationService.BE; | ||
using AuthenticationService.Dto; | ||
|
||
namespace AuthenticationService.Interfaces | ||
{ | ||
public interface IAuthValidationService | ||
{ | ||
/// <summary> | ||
/// validates a user by their username and password | ||
/// </summary> | ||
/// <param name="username"></param> | ||
/// <param name="password"></param> | ||
/// <returns>bool True if user is valid, false if user is not</returns> | ||
public bool ValidateUserByCredentials(string username, string password); | ||
|
||
/// <summary> | ||
/// validates a user by their token | ||
/// </summary> | ||
public bool ValidateUserByToken(string token); | ||
|
||
/// <summary> | ||
/// sets a token for a user in the database and returns the token | ||
/// </summary> | ||
public string LoginUser(LoginDto loginDto); | ||
|
||
/// <summary> | ||
/// registers a new user in the database | ||
/// </summary> | ||
/// <param name="loginDto"></param> | ||
/// <returns></returns> | ||
public LoginDto RegisterNewLogin(LoginDto loginDto); | ||
|
||
/// <summary> | ||
/// rebuilds the database | ||
/// </summary> | ||
public void Rebuild(); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.