Skip to content

Commit 0ccb5c3

Browse files
authored
Merge pull request #2 from fdonnet/onboarding
Add endpoints for register and onboard Create a free subscription and a base tenant and attach the user to it Sveletkit simple example Various correction and upgrade Naming Other stuff
2 parents aa3e001 + b977c79 commit 0ccb5c3

File tree

67 files changed

+888
-117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+888
-117
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ SvelteKit Frontend added. (not working in Aspire with fnm), so:
1414

1515
`npm install, npm run dev in svelte-link-ui folder`
1616

17+
After all the Aspire things are mounted.
18+
19+
Simple onboarding endpoints + Svelle exmple. Now you can register new users and test. (Very simple and naive, but you have an example you can build on.)
20+
1721
## Goal
1822

1923
This project allows you to choose any OAuth provider and remain independent in terms of your security design. You can add any frontend (Blazor, Next.js, SvelteKit) or backend APIs in front or behind this security layer. For a full SPA, you can modify Yarp to be a full BFF (Backend for Frontend).
@@ -67,5 +71,5 @@ For your backend APIs, in the EF Core pooled DbContext factory, the user is inje
6771

6872
## How You Can Help
6973

70-
If you find this project useful, you can help by reviewing the implementation or contributing to make it more generic (user onboarding from oauth provider via webhook or other stuff). It's a side project on a boring and not "sexy" topic for me, but I hope it can be helpful to some of you. This project aims to avoid fully managed pricey solutions because, in the end, we only need simple OAuth authentication and to manage our authorization layer by ourselves. Help on that will be appreciated.
74+
If you find this project useful, you can help by reviewing the implementation or contributing to make it more generic ~~(user onboarding from oauth provider via webhook or other stuff)~~ => simple onboarding implmented. It's a side project on a boring and not "sexy" topic for me, but I hope it can be helpful to some of you. This project aims to avoid fully managed pricey solutions because, in the end, we only need simple OAuth authentication and to manage our authorization layer by ourselves. Help on that will be appreciated.
7175

UbikLink.AppHost/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
var transportType = builder.AddParameter("transport-type", secret: false);
1919
var authTokenStoreKey = builder.AddParameter("auth-token-store-key", secret: true);
2020
var authRegisterAuthorizationKey = builder.AddParameter("auth-register-authorization-key", secret: true);
21+
var emailActivationEnable = builder.AddParameter("email-activation-enable", secret: false);
2122

2223
//Postgres (local)
2324
var db = builder.AddPostgres("ubiklink-postgres", postgresUsername, postgresPassword)
@@ -55,6 +56,7 @@
5556
.WithEnvironment("Messaging__RabbitUser", rabbitUser)
5657
.WithEnvironment("Messaging__RabbitPassword", rabbitPassword)
5758
.WithEnvironment("AuthRegister__Key", authRegisterAuthorizationKey)
59+
.WithEnvironment("AuthRegister__EmailActivationActivated", emailActivationEnable)
5860
.WithReference(securityDB)
5961
.WaitFor(securityDB)
6062
.WithReference(rabbitmq)

UbikLink.AppHost/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
"ConnectionStrings:messaging": "xx",
3434
"Parameters:keycloak-password": "admin",
3535
"Parameters:auth-token-store-key": "Ye6Y36ocA4SaGqYzd0HgmqMhVaM2jlkE",
36-
"Parameters:auth-register-authorization-key": "Ye6Y36oddddcA4SaGqYzd0HgmqMhVaM2jlkE"
36+
"Parameters:auth-register-authorization-key": "Ye6Y36oddddcA4SaGqYzd0HgmqMhVaM2jlkE",
37+
"Parameters:email-activation-enable": "false"
3738
}

UbikLink.Common/Api/AuthRegisterAuthKey.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
namespace UbikLink.Common.Api
88
{
9+
//TODO: don't forget to activate the email activation
910
public class AuthRegisterAuthKey
1011
{
1112
public const string Position = "AuthRegister";
1213
public string Key { get; set; } = string.Empty;
14+
public bool EmailActivationActivated { get; set; } = false;
1315
}
1416
}

UbikLink.Common/UbikLink.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
2222
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
2323
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.6.0" />
24-
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />
24+
<PackageReference Include="Yarp.ReverseProxy" Version="2.3.0" />
2525
</ItemGroup>
2626

2727
<ItemGroup>

UbikLink.Proxy/Authorizations/UserTenantRolesOrAuthorizationsRequirement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext
4646
}
4747

4848
//TODO: check that
49-
if (requirement.IsSubscriptionOwnerAllowed && userInfo.IsSubOwnerOfTheSelectetdTenant)
49+
if (requirement.IsSubscriptionOwnerAllowed && userInfo.IsSubOwnerOfTheSelectedTenant)
5050
{
5151
context.Succeed(requirement);
5252
return;

UbikLink.Proxy/UbikLink.Proxy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
1515
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.2.0-preview.1.25105.6" />
1616
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Yarp" Version="9.1.0" />
17-
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />
17+
<PackageReference Include="Yarp.ReverseProxy" Version="2.3.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

UbikLink.Security.Api/Data/Config/UserConfiguration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public void Configure(EntityTypeBuilder<UserModel> builder)
2121
.IsRequired()
2222
.HasMaxLength(200);
2323

24+
builder.Property(a => a.ActivationCode)
25+
.HasMaxLength(50);
26+
2427
builder.Property(a => a.Version)
2528
.IsConcurrencyToken();
2629

UbikLink.Security.Api/Data/Init/MandatoryData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ internal static async Task LoadAsync(SecurityDbContext ctx)
2323
Lastname = "9000",
2424
IsMegaAdmin = false,
2525
Version = SystemUserId,
26+
IsEmailVerified = false,
27+
ActivationCode = "000000",
2628
AuditInfo = new(audit.CreatedAt, audit.CreatedBy, audit.ModifiedAt, audit.ModifiedBy)
2729
};
2830

UbikLink.Security.Api/Data/Init/TestData.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ internal static async Task LoadAsync(SecurityDbContext ctx)
280280
Lastname = "Admin",
281281
IsMegaAdmin = true,
282282
Version = AdminUserId,
283+
IsEmailVerified = true,
283284
AuditInfo = new(audit.CreatedAt, audit.CreatedBy, audit.ModifiedAt, audit.ModifiedBy)
284285
},
285286
new()
@@ -292,6 +293,7 @@ internal static async Task LoadAsync(SecurityDbContext ctx)
292293
IsMegaAdmin = false,
293294
SelectedTenantId = null,
294295
Version = UserId2,
296+
IsEmailVerified = true,
295297
AuditInfo = new(audit.CreatedAt, audit.CreatedBy, audit.ModifiedAt, audit.ModifiedBy)
296298
},
297299
new()
@@ -304,6 +306,7 @@ internal static async Task LoadAsync(SecurityDbContext ctx)
304306
IsMegaAdmin = false,
305307
SelectedTenantId = null,
306308
Version = UserId1,
309+
IsEmailVerified = true,
307310
AuditInfo = new(audit.CreatedAt, audit.CreatedBy, audit.ModifiedAt, audit.ModifiedBy)
308311
},
309312
new()
@@ -316,6 +319,7 @@ internal static async Task LoadAsync(SecurityDbContext ctx)
316319
IsMegaAdmin = false,
317320
SelectedTenantId = null,
318321
Version = UserId3,
322+
IsEmailVerified = true,
319323
AuditInfo = new(audit.CreatedAt, audit.CreatedBy, audit.ModifiedAt, audit.ModifiedBy)
320324
},
321325
new() //Not really used anymore because the user is not active at the top lvl (managed by you oauth provider, but inactivity is managed at subscription lvl)
@@ -328,6 +332,7 @@ internal static async Task LoadAsync(SecurityDbContext ctx)
328332
IsMegaAdmin = false,
329333
SelectedTenantId = null,
330334
Version = UserIdInactivated,
335+
IsEmailVerified = true,
331336
AuditInfo = new(audit.CreatedAt, audit.CreatedBy, audit.ModifiedAt, audit.ModifiedBy)
332337
},
333338
};

0 commit comments

Comments
 (0)