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

working on real identity / auth #30

Merged
merged 27 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5858720
working on real identity / auth
Aaronontheweb May 6, 2024
80470dc
cleanup
Aaronontheweb May 6, 2024
93e641a
reorganized folders
Aaronontheweb May 6, 2024
b98704a
fix centralized packages
Aaronontheweb May 6, 2024
a4d3b65
fixed project reference error
Aaronontheweb May 6, 2024
bf79362
migrated all identity functionality to SQL Server
Aaronontheweb May 6, 2024
349bd3d
fix issues with email sending
Aaronontheweb May 6, 2024
d16b608
finally have auth working
Aaronontheweb May 6, 2024
60ca19e
defining some shared types
Aaronontheweb May 6, 2024
ea9d45b
added Akka.NET messages
Aaronontheweb May 6, 2024
a70956c
added some DData replication for the index
Aaronontheweb May 6, 2024
d847b8e
added command and event processing for drawings
Aaronontheweb May 6, 2024
bf05f12
defining entity actors and other subscription commands
Aaronontheweb May 6, 2024
ae8d96a
add indicies subscriptions
Aaronontheweb May 6, 2024
6fdaa1b
added Akka.Hosting and Sharding config
Aaronontheweb May 6, 2024
aef7a51
working on defining local paint actors
Aaronontheweb May 6, 2024
fb23291
added local drawing actor
Aaronontheweb May 6, 2024
840242c
added Akka.Hosting support for local actors
Aaronontheweb May 6, 2024
e5e61bc
actor startup works correctly
Aaronontheweb May 6, 2024
2ed98df
disable DData persistence
Aaronontheweb May 6, 2024
8cfa2fb
added data loading to homepage
Aaronontheweb May 6, 2024
c74f759
fixed up new UI
Aaronontheweb May 6, 2024
f8b792b
fixed startup crash issues
Aaronontheweb May 6, 2024
d899ba9
got new paint session navigation working
Aaronontheweb May 6, 2024
93c4b0b
fixing issues with pruning dead sessions
Aaronontheweb May 6, 2024
726b635
fixing some UX issues
Aaronontheweb May 6, 2024
48a11b9
fixed SSR
Aaronontheweb May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@
<!-- Akka.NET Package Versions -->
<ItemGroup>
<PackageVersion Include="Akka" Version="1.5.20" />
<PackageVersion Include="Akka.Cluster.Hosting" Version="1.5.20" />
<PackageVersion Include="Akka.Hosting" Version="1.5.20" />
<PackageVersion Include="Akka.Hosting.TestKit" Version="1.5.20" />
<PackageVersion Include="Akka.Persistence.Sql.Hosting" Version="1.5.13" />
<PackageVersion Include="Akka.Streams" Version="1.5.20" />
<PackageVersion Include="Akka.Streams.TestKit" Version="1.5.20" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageVersion Include="MudBlazor" Version="6.19.1" />
</ItemGroup>
<!-- ASP.NET Package Versions -->
<ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.4" />
</ItemGroup>
<!-- FluentEmail Package Versions -->
<ItemGroup>
<PackageVersion Include="FluentEmail.Mailgun" Version="3.0.2" />
<PackageVersion Include="FluentEmail.Razor" Version="3.0.2" />
</ItemGroup>
<!-- OTEL Package Versions -->
<ItemGroup>
Expand Down
68 changes: 68 additions & 0 deletions DrawTogether.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrawTogether.UI.Server", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrawTogether.UI.Shared", "src\DrawTogether.UI\Shared\DrawTogether.UI.Shared.csproj", "{308A77AD-9D61-4D4A-B003-CF59B0BCE1A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{8CE7AE81-DC9A-439A-87CC-7E5CB8F894B1}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
global.json = global.json
nuget.config = nuget.config
README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawTogether.Email", "src\DrawTogether.Email\DrawTogether.Email.csproj", "{ED49A473-3E9F-4689-8297-13C9030565CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawTogether", "src\DrawTogether\DrawTogether.csproj", "{538A12B5-7CE5-4F72-931D-92F1F03495D7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "infrastructure", "infrastructure", "{DB40625F-3958-4D43-8430-C88AEC0FBB1C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawTogether.Entities", "src\DrawTogether.Entities\DrawTogether.Entities.csproj", "{7F01390E-AF15-442C-831C-C574D6AAFC1F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawTogether.Actors", "src\DrawTogether.Actors\DrawTogether.Actors.csproj", "{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,6 +61,54 @@ Global
{308A77AD-9D61-4D4A-B003-CF59B0BCE1A6}.Release|x64.Build.0 = Release|Any CPU
{308A77AD-9D61-4D4A-B003-CF59B0BCE1A6}.Release|x86.ActiveCfg = Release|Any CPU
{308A77AD-9D61-4D4A-B003-CF59B0BCE1A6}.Release|x86.Build.0 = Release|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Debug|x64.ActiveCfg = Debug|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Debug|x64.Build.0 = Debug|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Debug|x86.ActiveCfg = Debug|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Debug|x86.Build.0 = Debug|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Release|Any CPU.Build.0 = Release|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Release|x64.ActiveCfg = Release|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Release|x64.Build.0 = Release|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Release|x86.ActiveCfg = Release|Any CPU
{ED49A473-3E9F-4689-8297-13C9030565CC}.Release|x86.Build.0 = Release|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Debug|x64.ActiveCfg = Debug|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Debug|x64.Build.0 = Debug|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Debug|x86.ActiveCfg = Debug|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Debug|x86.Build.0 = Debug|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Release|Any CPU.Build.0 = Release|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Release|x64.ActiveCfg = Release|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Release|x64.Build.0 = Release|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Release|x86.ActiveCfg = Release|Any CPU
{538A12B5-7CE5-4F72-931D-92F1F03495D7}.Release|x86.Build.0 = Release|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Debug|x64.ActiveCfg = Debug|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Debug|x64.Build.0 = Debug|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Debug|x86.ActiveCfg = Debug|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Debug|x86.Build.0 = Debug|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Release|Any CPU.Build.0 = Release|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Release|x64.ActiveCfg = Release|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Release|x64.Build.0 = Release|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Release|x86.ActiveCfg = Release|Any CPU
{7F01390E-AF15-442C-831C-C574D6AAFC1F}.Release|x86.Build.0 = Release|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Debug|x64.ActiveCfg = Debug|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Debug|x64.Build.0 = Debug|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Debug|x86.ActiveCfg = Debug|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Debug|x86.Build.0 = Debug|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Release|Any CPU.Build.0 = Release|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Release|x64.ActiveCfg = Release|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Release|x64.Build.0 = Release|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Release|x86.ActiveCfg = Release|Any CPU
{5863DD74-00DE-4DE9-9F0A-FCBC32195E78}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,52 @@ A collaborative browser-based drawing program written in .NET.

Please see [REQUIREMENTS](docs/requirements.md) for more information.

## UI
![DrawTogether.NET UI](/docs/images/paintarea-ui.png)
## Running Locally

First things first, you will need to launch the dependencies for DrawTogether.NET - make sure you have `docker` installed locally:

**Windows**

```shell
start-dependencies.cmd
```

**Linux**

```shell
start-dependencies.sh
```

This will launch, among other things, a prebuilt SQL Server 2022 instance that has the correct default connection string and `DrawTogether` database required by DrawTogether.NET.

### Entity Framework Core Migrations

If you need to apply a change to the database model, by default this project uses a Sqlite instance locally. To apply migrations, change your directory to the `DrawTogether` project:

```shell
cd ./src/DrawTogether/
```

And then apply the migrations:

```shell
dotnet ef database update
```

To generate a migration script that you can apply manually (later):

```shell
dotnet ef migrations script
```

## MailGun Configuration

DrawTogether.NET can use [MailGun](https://mailgun.com/) to send outbound emails (via `FluentEmail.Mailgun`) - and the following two secrets need to be configured in order for that sending to work:

```shell
cd ./src/DrawTogether/
dotnet user-secrets set "EmailSettings:MailgunDomain" "<mailgun-domain>"
dotnet user-secrets set "EmailSettings:MailgunApiKey" "<mailgun-api-key>"
```

If these settings are not provided, DrawTogether.NET will simply fall back to not having email available to support ASP.NET Core Identity.
3 changes: 3 additions & 0 deletions infrastructure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DrawTogether.NET Infrastructure

This folder contains some "`git clone` and run" tooling for helping run all of DrawTogether.NET's infrastructure.
10 changes: 10 additions & 0 deletions infrastructure/build.all.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
REM @echo off
REM executes all `build.cmd` scripts recursively inside from this directory on down

pushd "%~dp0"
for /R %%f in ("build.cmd") do (
IF EXIST "%%f" (
call "%%f" %~1
)
)
popd
8 changes: 8 additions & 0 deletions infrastructure/build.all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# executes all `build.sh` scripts recursively inside from this directory on down
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"

for file in ./**/build.sh; do
./${file} $1
done
39 changes: 39 additions & 0 deletions infrastructure/mssql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# MSSQL Image

This is a prebuilt [SQL Server 2022 on Linux](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-whats-new-2019) Docker image that contains a blank `DrawTogether` database which will subsequently be used by Akka.Persistence.Sql for relevant samples.

## Build

To build this image, run the `build.sh` or `build.cmd` script found in root of this directory.

```shell
build.sh [-t {tag}]
````

```shell
build.cmd [-t {tag}]
```

This will produce an image named `drawtogether.sqlserver:{tag}`.

If you leave out the `{tag}` parameter the image name will default to `drawtogether.sqlserver:0.1.0`.

### Adding Additional Schema

If you need additional tables or any other DDLs added to this sample, modify the [`setup.sql`](setup.sql) script inside this repository. Those schema modifications will be applied when the container first starts up.

### Deployment

To run this image you will still need to provide the default environment variable arguments required by the [SQL Server 2022 public Docker image](https://hub.docker.com/_/microsoft-mssql-server):

```shell
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=yourStrong(!)Password" -p 1633:1433 -d drawtogether.sqlserver:0.1.0
```

This will produce a connection string that you can use to run Akka.Persistence (from the host machine):

```
Server=localhost; Database=DrawTogether; User Id=sa; Password=yourStrong(!)Password;
```

> **N.B.** It might take `drawtogether.sqlserver.sqlserver` up to 30 seconds to fully initialize the very first time it starts. Please be patient prior to running your sample and check the logs inside the Docker dashboard to see if the `DrawTogether` database has been created.
15 changes: 15 additions & 0 deletions infrastructure/mssql/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off
REM builds all docker images

set version="0.1.0"
set imageName="drawtogether.sqlserver"

if "%~1"=="" (
REM No version tag specified
echo No tag for [%imageName%] specified. Defaulting to [%version%]
) else (
set version="%~1"
echo Building [%imageName%] with tag [%~1]
)

docker build %~dp0/src/. -t "%imageName%:%version%"
16 changes: 16 additions & 0 deletions infrastructure/mssql/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Builds docker images
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"

version="0.1.0"
imageName="drawtogether.sqlserver"

if [ -z $1 ]; then
echo "No tag for [${imageName}] specified. Defaulting to [${version}]"
else
version="$1"
echo "Building [${imageName}] with tag [${version}]"
fi

docker build ./src/. -t "${imageName}:${version}"
14 changes: 14 additions & 0 deletions infrastructure/mssql/deploy.k8s.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
echo off
REM Deploys container instance into Kubernetes namespace

set namespace="drawtogether"

if "%~1"=="" (
REM No K8S namespace specified
echo No namespace specified. Defaulting to [%namespace%]
) else (
set namespace="%~1"
echo Deploying into K8s namespace [%namespace%]
)

kubectl apply -f "%~dp0/drawtogether.sql.yaml" -n "%namespace%"
15 changes: 15 additions & 0 deletions infrastructure/mssql/deploy.k8s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Deploys container instance into Kubernetes namespace
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )


namespace="drawtogether"

if [ -z $1 ]; then
echo "No namespace specified. Defaulting to [${namespace}]"
else
namespace="$1"
echo "Deploying into K8s namespace [${namespace}]"
fi

kubectl apply -f "drawtogether.sql.yaml" -n "%namespace%"
46 changes: 46 additions & 0 deletions infrastructure/mssql/drawtogether.sql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: Service
metadata:
name: sqlserver
spec:
ports:
- name: sqlserver
port: 1644
protocol: TCP
targetPort: 1433
selector:
app: sqlserver
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sqlserver
labels:
app: sqlserver
spec:
replicas: 1
selector:
matchLabels:
app: sqlserver
template:
metadata:
labels:
app: sqlserver
spec:
containers:
- name: sqlserver
image: drawtogether.sqlserver:0.1.0
env:
- name: ACCEPT_EULA
value: "Y"
- name: SA_PASSWORD
value: "yourStrong(!)Password"
ports:
- containerPort: 1433
name: sqlserver
readinessProbe:
exec:
command: ["/bin/sh", "-c", "ready-check.sh"]
initialDelaySeconds: 5
periodSeconds: 5
10 changes: 10 additions & 0 deletions infrastructure/mssql/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/mssql/server:2022-latest

COPY ./setup.sql .
COPY ./setup.sh .
COPY ./ready-check.sh .

# Grant permission on the setup script
#RUN chmod +x ./setup.sh

CMD /bin/bash -C './setup.sh';'bash'
5 changes: 5 additions & 0 deletions infrastructure/mssql/src/ready-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo "checking to see if [DrawTogether] database is available..."

/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -d master -q "select [dbo].[DatabaseExists]('DrawTogether')"
13 changes: 13 additions & 0 deletions infrastructure/mssql/src/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# start SQL Server
/opt/mssql/bin/sqlservr &

#wait for the SQL Server to come up
sleep 15s

# setup the tables
echo "Connecting to SQL and creating Akka database."
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -d master -i setup.sql

sleep infinity
Loading
Loading