Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/authentication #1

Merged
merged 13 commits into from
Aug 13, 2024
808 changes: 808 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions Summer1403-Project-Group01-Backend.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "src\Domain\Domain.csproj", "{84F8DBE3-ACF4-49A7-AB89-97A97BF6C351}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "src\Infrastructure\Infrastructure.csproj", "{B358A8CE-2718-4056-94AA-D5A40DD67AEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "src\Application\Application.csproj", "{90C204C7-AB46-45E5-9AE0-912800436545}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web", "src\Web\Web.csproj", "{961DAD51-ECA7-4389-8CD8-04DC47720E37}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{84F8DBE3-ACF4-49A7-AB89-97A97BF6C351}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84F8DBE3-ACF4-49A7-AB89-97A97BF6C351}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84F8DBE3-ACF4-49A7-AB89-97A97BF6C351}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84F8DBE3-ACF4-49A7-AB89-97A97BF6C351}.Release|Any CPU.Build.0 = Release|Any CPU
{B358A8CE-2718-4056-94AA-D5A40DD67AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B358A8CE-2718-4056-94AA-D5A40DD67AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B358A8CE-2718-4056-94AA-D5A40DD67AEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B358A8CE-2718-4056-94AA-D5A40DD67AEF}.Release|Any CPU.Build.0 = Release|Any CPU
{90C204C7-AB46-45E5-9AE0-912800436545}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90C204C7-AB46-45E5-9AE0-912800436545}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90C204C7-AB46-45E5-9AE0-912800436545}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90C204C7-AB46-45E5-9AE0-912800436545}.Release|Any CPU.Build.0 = Release|Any CPU
{961DAD51-ECA7-4389-8CD8-04DC47720E37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{961DAD51-ECA7-4389-8CD8-04DC47720E37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{961DAD51-ECA7-4389-8CD8-04DC47720E37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{961DAD51-ECA7-4389-8CD8-04DC47720E37}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
5 changes: 5 additions & 0 deletions src/Application/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Application;

public class Class1
{
}
5 changes: 5 additions & 0 deletions src/Domain/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Domain;

public class Class1
{
}
8 changes: 8 additions & 0 deletions src/Domain/Constants/AppRoles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Domain.Constants;

public static class AppRoles
{
public const string Admin = nameof(Admin);
public const string DataAdmin = nameof(DataAdmin);
public const string DataAnalyst = nameof(DataAnalyst);
}
17 changes: 17 additions & 0 deletions src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" />
</ItemGroup>

<ItemGroup>
<Folder Include="Entities\" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions src/Infrastructure/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using Domain.Constants;
using Infrastructure.Entities;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Infrastructure.Data;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> dbContextOptions)
: IdentityDbContext<AppUser>(dbContextOptions)
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
List<IdentityRole> roles =
[
new IdentityRole { Name = AppRoles.Admin, NormalizedName = AppRoles.Admin.ToUpper()},
new IdentityRole { Name = AppRoles.DataAdmin, NormalizedName = AppRoles.DataAdmin.ToUpper()},
new IdentityRole { Name = AppRoles.DataAnalyst, NormalizedName = AppRoles.DataAnalyst.ToUpper()}
];
modelBuilder.Entity<IdentityRole>().HasData(roles);
}
}
7 changes: 7 additions & 0 deletions src/Infrastructure/Entities/AppUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.AspNetCore.Identity;

namespace Infrastructure.Entities;
public class AppUser : IdentityUser
{

}
23 changes: 23 additions & 0 deletions src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>

</Project>
Loading
Loading