Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew committed Oct 30, 2024
0 parents commit d174fe6
Show file tree
Hide file tree
Showing 86 changed files with 74,964 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
13 changes: 13 additions & 0 deletions .idea/.idea.SecureDesignProject/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.SecureDesignProject/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Controllers/AuthController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using SecureDesignProject.Models;

namespace SecureDesignProject.Controllers;

public class AuthController : Controller
{
private readonly ILogger<HomeController> _logger;

public AuthController(ILogger<HomeController> logger)
{
_logger = logger;
}

public IActionResult Login()
{
return View();
}

public IActionResult Register()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
31 changes: 31 additions & 0 deletions Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using SecureDesignProject.Models;

namespace SecureDesignProject.Controllers;

public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}

public IActionResult Index()
{
return View();
}

public IActionResult Privacy()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["SecureDesignProject.csproj", "./"]
RUN dotnet restore "SecureDesignProject.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet build "SecureDesignProject.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "SecureDesignProject.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SecureDesignProject.dll"]
32 changes: 32 additions & 0 deletions Migrations/1_create_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- Create Database

CREATE DATABASE HealthServiceDb

CREATE TABLE Account(
AccountId UNIQUEIDENTIFIER NOT NULL,
Email VARCHAR(MAX) NOT NULL UNIQUE,
HashedPassword VARCHAR(MAX) NOT NULL,
Name VARCHAR(MAX) NOT NULL,

PRIMARY KEY (AccountId)
);

CREATE TABLE Patients(
PatientId UNIQUEIDENTIFIER NOT NULL,

PRIMARY KEY (PatientId)
);

CREATE TABLE Caregivers(
CaregiverId UNIQUEIDENTIFIER NOT NULL,

PRIMARY KEY (CaregiverId)
);

CREATE TABLE Caregiver_Patients(
PatientId UNIQUEIDENTIFIER NOT NULL,
CaregiverId UNIQUEIDENTIFIER NOT NULL,

FOREIGN KEY (PatientId) REFERENCES Patients(PatientId),
FOREIGN KEY (CaregiverId) REFERENCES Caregivers(CaregiverId)
);
7 changes: 7 additions & 0 deletions Models/Auth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SecureDesign.Models;

public record LoginDetails
{
public string Email { get; init; }
public string Password { get; init; }
};
8 changes: 8 additions & 0 deletions Models/ErrorViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SecureDesignProject.Models;

public class ErrorViewModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
31 changes: 31 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");

app.MapControllerRoute(
name: "login",
pattern: "{controller=Auth}/{action=Login}/{id?}");

app.Run();
38 changes: 38 additions & 0 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:64008",
"sslPort": 44351
}
},
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7049;http://localhost:5133",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5133",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
10 changes: 10 additions & 0 deletions SecureDesignProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

</Project>
21 changes: 21 additions & 0 deletions SecureDesignProject.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureDesignProject", "SecureDesignProject.csproj", "{46765F06-2B8D-47A4-A8D4-8961DA4BC3E9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0795778D-8CE5-49EC-9478-281BAC42556D}"
ProjectSection(SolutionItems) = preProject
compose.yaml = compose.yaml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{46765F06-2B8D-47A4-A8D4-8961DA4BC3E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46765F06-2B8D-47A4-A8D4-8961DA4BC3E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46765F06-2B8D-47A4-A8D4-8961DA4BC3E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46765F06-2B8D-47A4-A8D4-8961DA4BC3E9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
18 changes: 18 additions & 0 deletions Views/Auth/Login.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@{
ViewData["Title"] = "Login";
}

<h1>@ViewData["Title"]</h1>
<br/>

<form method="POST" action="/Auth/SessionToken">

<p class="m-3">Enter username and password:</p>

<input placeholder="Username" id="username" type="text" class="form-control m-3 w-auto"/>

<input placeholder="Password" id="password" type="password" class="form-control m-3 w-auto"/>

<button type="submit" class="btn btn-primary m-3">Login</button>

</form>
8 changes: 8 additions & 0 deletions Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@{
ViewData["Title"] = "Home Page";
}

<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
6 changes: 6 additions & 0 deletions Views/Home/Privacy.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>

<p>Use this page to detail your site's privacy policy.</p>
25 changes: 25 additions & 0 deletions Views/Shared/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
Loading

0 comments on commit d174fe6

Please sign in to comment.