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

User identity #2

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1aab947
Add Identity framework
urumo Oct 15, 2024
133d305
Add ASP.NET Core Identity packages
urumo Oct 15, 2024
cd51401
Add Identity models to ApplicationDbContext
urumo Oct 15, 2024
e1be7fe
Enable authentication, CORS, and add identity services.
urumo Oct 15, 2024
6713a03
Add connection strings to development settings
urumo Oct 15, 2024
0fd86ec
Refactor project formatting for consistency
urumo Oct 15, 2024
adf5456
Add Argon.Grains project to solution
urumo Oct 15, 2024
59d7201
Add Argon.Grains.Interfaces project
urumo Oct 15, 2024
9fa690d
Add Argon.Orleans.Client project to solution
urumo Oct 15, 2024
8f5431a
Add Argon.Wasm.Client project
urumo Oct 15, 2024
fa9665a
Add project reference to Argon.Grains.Interfaces
urumo Oct 15, 2024
51edeea
Update Dockerfile and project file to include new dependencies
urumo Oct 15, 2024
4f66712
Add new Argon.Api.Common project file
urumo Oct 15, 2024
2058b1d
Refactor namespace and file organization
urumo Oct 15, 2024
e1a8615
Reorganize Docker files and add Argon.Api.Common dependency
urumo Oct 15, 2024
da88176
Refactor Dockerfile for base image and add common project
urumo Oct 15, 2024
1ec66a9
Update DefaultConnection string in appsettings.json
urumo Oct 15, 2024
59625c6
Add Orleans configuration and enhance identity options
urumo Oct 15, 2024
9214e00
Add tests workflow and update API configurations
urumo Oct 15, 2024
dae68f2
Add build and test steps to CI workflow
urumo Oct 15, 2024
75b17f6
Simplify GitHub Actions workflow
urumo Oct 15, 2024
4f9ea15
Add .NET Aspire workload to CI pipeline
urumo Oct 15, 2024
f301692
Add Orleans package references to csproj
urumo Oct 15, 2024
be37813
Add Hello grain and interface with updated project references
urumo Oct 15, 2024
1dc34ea
Remove Argon.Wasm.Client and add Orleans client extensions
urumo Oct 15, 2024
5345d98
Add ConsoleApp1 project and update Orleans client extensions
urumo Oct 15, 2024
86dc39a
Remove unused Class1.cs files
urumo Oct 15, 2024
c97574d
Remove ConsoleApp1 project
urumo Oct 16, 2024
48035d9
Add submodule Contracts and refactor project structure
urumo Oct 16, 2024
59f5488
Enhance checkout steps in GitHub workflows
urumo Oct 16, 2024
f484393
Update token in workflows config
urumo Oct 16, 2024
c0f880c
Update token for `actions/checkout` in API workflow
urumo Oct 16, 2024
93e5cf4
Add ConsoleApp1 project and integrate with Orleans client
urumo Oct 16, 2024
6901470
updated Contracts
urumo Oct 16, 2024
00e7fb7
Refactor UseLocalhostClustering configuration
urumo Oct 16, 2024
9163564
Refactor code formatting and update Orleans configuration.
urumo Oct 18, 2024
fe53a51
Enhance client call and simplify endpoint configuration
urumo Oct 18, 2024
c7afcf3
Add Orleans Kubernetes clustering support
urumo Oct 18, 2024
9d86826
Normalize cluster and service IDs to lowercase
urumo Oct 18, 2024
a175ddf
Update Orleans Cluster and Service IDs in Program.cs
urumo Oct 18, 2024
877b3d1
Update lambda syntax in Program.cs for connection options
urumo Oct 18, 2024
84a6630
Remove EF Core migrations and identity setup
urumo Oct 18, 2024
fa2abbb
Disable Docker build and push in CI
urumo Oct 18, 2024
2fc6386
Revert "Disable Docker build and push in CI"
urumo Oct 18, 2024
b732883
Revert "Remove EF Core migrations and identity setup"
urumo Oct 18, 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
31 changes: 18 additions & 13 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
name: .NET
name: Api

on:
push:
branches: [ "master" ]
paths:
- 'src/Argon.Api/**'
- 'src/ServiceDefaults/**'
- 'src/Argon.Grains/**'
- 'src/Argon.Grains.Interfaces/**'
- 'src/Argon.Api.Common/**'
pull_request:
branches: [ "master" ]
paths:
- 'src/Argon.Api/**'
- 'src/ServiceDefaults/**'
- 'src/Argon.Grains/**'
- 'src/Argon.Grains.Interfaces/**'
- 'src/Argon.Api.Common/**'

jobs:
qa:
runs-on: ARM64
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
uses: ./.github/workflows/tests.yml
build:
# if: github.ref == 'refs/heads/master'
needs: [ qa ]
# if: github.ref == 'refs/heads/master'
runs-on: ARM64
needs: qa
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
Expand All @@ -36,6 +43,4 @@ jobs:
context: .
file: ./src/Argon.Api/Dockerfile
push: true
tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }}
# platforms: linux/arm64/v8

tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }}
23 changes: 23 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Tests
on: [ workflow_call ]
jobs:
qa:
runs-on: ARM64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install .NET Aspire workload
run: dotnet workload install aspire
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Contracts"]
path = Contracts
url = [email protected]:argon-chat/Contracts.git
35 changes: 35 additions & 0 deletions Argon.Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDefaults", "src\Serv
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Api", "src\Argon.Api\Argon.Api.csproj", "{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Api.Common", "src\Argon.Api.Common\Argon.Api.Common.csproj", "{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Grains", "Contracts\Argon.Grains\Argon.Grains.csproj", "{9D8512AA-367B-427C-8387-AE03F2374EE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Grains.Interfaces", "Contracts\Argon.Grains.Interfaces\Argon.Grains.Interfaces.csproj", "{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Orleans.Client", "Contracts\Argon.Orleans.Client\Argon.Orleans.Client.csproj", "{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "src\ConsoleApp1\ConsoleApp1.csproj", "{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,6 +27,11 @@ Global
{872FE764-2544-4E27-9193-BA625245F8D5} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{3AEA5748-B88E-45FF-B3DC-319A7A8D13B4} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{9D8512AA-367B-427C-8387-AE03F2374EE0} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{872FE764-2544-4E27-9193-BA625245F8D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -31,5 +46,25 @@ Global
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Release|Any CPU.Build.0 = Release|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Release|Any CPU.Build.0 = Release|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Release|Any CPU.Build.0 = Release|Any CPU
{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328}.Release|Any CPU.Build.0 = Release|Any CPU
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Release|Any CPU.Build.0 = Release|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions Contracts
Submodule Contracts added at e18aee
2 changes: 2 additions & 0 deletions src/AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
.WithReference(apiDb, "DefaultConnection")
.WithReference(cache)
.WithReference(rmq)
.WithEndpoint(11111, 11111, "tcp", "siloPort", isProxied: false)
.WithEndpoint(30000, 30000, "tcp", "grainPort", isProxied: false)
.WithExternalHttpEndpoints();

builder.Build().Run();
13 changes: 13 additions & 0 deletions src/Argon.Api.Common/Argon.Api.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.10"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.UI
Зачем?

</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/Argon.Api.Common/Models/ApplicationUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.AspNetCore.Identity;

namespace Argon.Api.Common.Models;

public class ApplicationUser : IdentityUser<Guid>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AspNetCore.Identity не научился в рекорды?

{
}
Comment on lines +5 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class ApplicationUser : IdentityUser<Guid>
{
}
public class ApplicationUser : IdentityUser<Guid>;

30 changes: 30 additions & 0 deletions src/Argon.Api.Common/Services/EmailSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Argon.Api.Common.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;

namespace Argon.Api.Common.Services;

public class EmailSender(ILogger<EmailSender> logger) : IEmailSender<ApplicationUser>
{
public Task SendConfirmationLinkAsync(ApplicationUser user, string email, string confirmationLink)
{
logger.LogInformation(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

реализация

"Sending confirmation link to {email} for user {user} with confirmation link {confirmationLink}", email,
user.UserName, confirmationLink);
return Task.CompletedTask;
}

public Task SendPasswordResetLinkAsync(ApplicationUser user, string email, string resetLink)
{
logger.LogInformation("Sending password reset link to {email} for user {user} with reset link {resetLink}",
email, user.UserName, resetLink);
return Task.CompletedTask;
}

public Task SendPasswordResetCodeAsync(ApplicationUser user, string email, string resetCode)
{
logger.LogInformation("Sending password reset code to {email} for user {user} with reset code {resetCode}",
email, user.UserName, resetCode);
return Task.CompletedTask;
}
}
10 changes: 7 additions & 3 deletions src/Argon.Api/Argon.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Orleans.Server" Version="8.2.0"/>
<PackageReference Include="Orleans.Clustering.Kubernetes" Version="8.2.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>

Expand All @@ -21,13 +23,15 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Contracts\Argon.Grains\Argon.Grains.csproj"/>
<ProjectReference Include="..\Argon.Api.Common\Argon.Api.Common.csproj"/>
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj"/>
</ItemGroup>

<ItemGroup>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Argon.Api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"]
COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"]
COPY ["Contracts/Argon.Grains/Argon.Grains.csproj", "Contracts/Argon.Grains/"]
COPY ["Contracts/Argon.Grains.Interfaces/Argon.Grains.Interfaces.csproj", "Contracts/Argon.Grains.Interfaces/"]
COPY ["src/Argon.Api.Common/Argon.Api.Common.csproj", "src/Argon.Api.Common/"]
RUN dotnet restore "src/Argon.Api/Argon.Api.csproj"
COPY . .
WORKDIR "/src/src/Argon.Api"
Expand Down
6 changes: 5 additions & 1 deletion src/Argon.Api/Entities/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Argon.Api.Common.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Argon.Api.Entities;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options);
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid>(options);
Loading
Loading