Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f6a3aa9
Remove IdentityServer4 packages
juliangiebel Aug 10, 2025
555ded6
Comment out IdentityServer4 code
juliangiebel Aug 10, 2025
bc2cd24
Upgrade to .net9
juliangiebel Aug 10, 2025
1539281
Refactor SS14.Web startup to program.cs
juliangiebel Aug 10, 2025
e9eddaa
Work on adding OpenIddict to program.cs
juliangiebel Aug 10, 2025
0167585
Implement OpenIddict configuration
juliangiebel Aug 11, 2025
7b0520a
Implement custom application entity
juliangiebel Aug 11, 2025
20a01ad
Revert "migrate to nullable"
juliangiebel Aug 11, 2025
848c7df
Add list of ef core commands to readme
juliangiebel Aug 12, 2025
a046867
A
juliangiebel Aug 12, 2025
34f9134
Fix wrong get openiddict request method call
juliangiebel Aug 13, 2025
5886192
Finish implementing the oidc authorization/consent endpoint
juliangiebel Aug 13, 2025
ed44b1b
Clean up Consent.cshtml and codebehind
juliangiebel Aug 13, 2025
6960459
Remove IS4 code from ApplicationDbContext
juliangiebel Aug 13, 2025
20873e6
Remove UserOauthClient
juliangiebel Aug 13, 2025
88995d3
Change PersonalDataCollector to collecto from OpenIddict
juliangiebel Aug 13, 2025
ad63ba5
Implement generate token event handler for ensuring the right algorit…
juliangiebel Aug 14, 2025
50d2919
Add home page url property to SpaceApplication
juliangiebel Aug 14, 2025
6baccda
Work on oauth application manage page
juliangiebel Aug 14, 2025
2226e2d
Implement multiple client secret support
juliangiebel Aug 15, 2025
96ebfc9
Make a migration
juliangiebel Aug 15, 2025
952ec46
Implement methods for working with multiple secrets
juliangiebel Aug 17, 2025
49d3d26
Re-Implement developer and oauth manage page
juliangiebel Aug 17, 2025
df74a59
Re-Implement oauth application create page
juliangiebel Aug 17, 2025
7effe54
Re-Implement confirm delete page
juliangiebel Aug 17, 2025
435ea91
Implement identityserver4 legacy SHA256 client secret validation
juliangiebel Aug 17, 2025
fd67c7e
Re-Implement oauth client admin index and delete pages
juliangiebel Aug 18, 2025
8975aa9
Implement plain pkce option
juliangiebel Aug 29, 2025
4710fd5
Re-Implement oauth client admin edit page
juliangiebel Aug 30, 2025
cefe399
Add quartz for openiddict pruning
juliangiebel Aug 30, 2025
01309dd
Work on IdentityServer4Migration
juliangiebel Aug 30, 2025
2e7440d
Improve certificate configuration
juliangiebel Sep 1, 2025
9fd9eec
Remove test data seeder
juliangiebel Sep 1, 2025
191384c
Add data migration sql to tools
juliangiebel Sep 1, 2025
cb12e03
Address leftover todos and comments
juliangiebel Sep 1, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ riderModule.iml
/*.sln.DotSettings.user

*/appsettings.Secret.yml
*/tempkey.jwk
*/tempkey.jwk
cert
4 changes: 2 additions & 2 deletions OAuthTest/OAuthTest.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.8" />
</ItemGroup>
</Project>
16 changes: 8 additions & 8 deletions OAuthTest/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpLogging(logging =>
{
logging.LoggingFields = HttpLoggingFields.All;
//Write your code to configure the HttpLogging middleware here
//Write your code to configure the HttpLogging middleware here
});
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

services.AddControllersWithViews();

services.AddAuthentication(options =>
Expand All @@ -39,15 +39,15 @@ public void ConfigureServices(IServiceCollection services)
.AddOpenIdConnect("oidc", options =>
{
options.SignInScheme = "Cookies";
options.Authority = "https://localhost:5003";
options.ClientId = "A";
options.ClientSecret = "A";

options.Authority = "https://localhost:5001";
options.ClientId = "test_client";
options.ClientSecret = "test_secret";

options.GetClaimsFromUserInfoEndpoint = true;
options.ResponseType = OpenIdConnectResponseType.Code;
//options.SaveTokens = true;

options.Scope.Add("profile");
options.Scope.Add("email");
options.ResponseType = "code";
Expand Down Expand Up @@ -85,4 +85,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ ConnectionStrings:
Mutex:
# Change this to something local on disk.
DbPath: 'C:\Users\Pieter-Jan Briers\Projects\ss14\web\mutex.db'
```
```

* Create the mutex DB mentioned above manually, and run `init_mutex.sql` on it. (I recommend https://sqlitebrowser.org/ for this task)
* If I didn't forget anything you should now be able to start both services and it should work:tm:.

### Handling migrations
The following ef core commands can be used:
- Creating a migration: `dotnet ef migrations add <migration name> -p SS14.Auth.Shared`
- Removing migrations: `dotnet ef migrations remove -p SS14.Auth.Shared --connection "<connection string>"`
- Updating the database: `dotnet ef database update -p SS14.Auth.Shared -s .\SS14.Web\ --connection "<connection string>"`
2 changes: 1 addition & 1 deletion SS14.Auth.Shared/Data/AccountLogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ public AccountLogActor NoActor()
}
}

public sealed record AccountLogActor(Guid? User, IPAddress? Address);
public sealed record AccountLogActor(Guid? User, IPAddress? Address);
63 changes: 1 addition & 62 deletions SS14.Auth.Shared/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
using System;
using System.Threading.Tasks;
using IdentityServer4.EntityFramework.Entities;
using IdentityServer4.EntityFramework.Extensions;
using IdentityServer4.EntityFramework.Interfaces;
using IdentityServer4.EntityFramework.Options;
using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace SS14.Auth.Shared.Data;

public class ApplicationDbContext : IdentityDbContext<SpaceUser, SpaceRole, Guid>,
IDataProtectionKeyContext,
IConfigurationDbContext,
IPersistedGrantDbContext
IDataProtectionKeyContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
Expand Down Expand Up @@ -61,49 +54,13 @@ protected override void OnModelCreating(ModelBuilder builder)
.HasIndex(p => p.SpaceUserId)
.IsUnique();

builder.Entity<UserOAuthClient>()
.HasIndex(p => new { p.ClientId })
.IsUnique();

builder.Entity<Hwid>()
.HasIndex(h => h.ClientData)
.IsUnique();

builder.Entity<HwidUser>()
.HasIndex(h => new { h.HwidId, h.SpaceUserId })
.IsUnique();

var cfgStoreOptions = new ConfigurationStoreOptions
{
IdentityResource = new TableConfiguration("IdentityResources", "IS4"),
IdentityResourceClaim = new TableConfiguration("IdentityResourceClaims", "IS4"),
IdentityResourceProperty = new TableConfiguration("IdentityResourceProperties", "IS4"),
ApiResource = new TableConfiguration("ApiResources", "IS4"),
ApiResourceSecret = new TableConfiguration("ApiResourceSecrets", "IS4"),
ApiResourceScope = new TableConfiguration("ApiResourceScopes", "IS4"),
ApiResourceClaim = new TableConfiguration("ApiResourceClaims", "IS4"),
ApiResourceProperty = new TableConfiguration("ApiResourceProperties", "IS4"),
Client = new TableConfiguration("Clients", "IS4"),
ClientGrantType = new TableConfiguration("ClientGrantTypes", "IS4"),
ClientRedirectUri = new TableConfiguration("ClientRedirectUris", "IS4"),
ClientPostLogoutRedirectUri = new TableConfiguration("ClientPostLogoutRedirectUris", "IS4"),
ClientScopes = new TableConfiguration("ClientScopes", "IS4"),
ClientSecret = new TableConfiguration("ClientSecrets", "IS4"),
ClientClaim = new TableConfiguration("ClientClaims", "IS4"),
ClientIdPRestriction = new TableConfiguration("ClientIdPRestrictions", "IS4"),
ClientCorsOrigin = new TableConfiguration("ClientCorsOrigins", "IS4"),
ClientProperty = new TableConfiguration("ClientProperties", "IS4"),
ApiScope = new TableConfiguration("ApiScopes", "IS4"),
ApiScopeClaim = new TableConfiguration("ApiScopeClaims", "IS4"),
ApiScopeProperty = new TableConfiguration("ApiScopeProperties", "IS4")
};
builder.ConfigureClientContext(cfgStoreOptions);
builder.ConfigureResourcesContext(cfgStoreOptions);
builder.ConfigurePersistedGrantContext(new OperationalStoreOptions
{
PersistedGrants = new TableConfiguration("PersistedGrants", "IS4"),
DeviceFlowCodes = new TableConfiguration("DeviceCodes", "IS4"),
});
}

public DbSet<LoginSession> ActiveSessions { get; set; }
Expand All @@ -113,26 +70,8 @@ protected override void OnModelCreating(ModelBuilder builder)
public DbSet<WhitelistEmail> WhitelistEmails { get; set; }
public DbSet<Patron> Patrons { get; set; }
public DbSet<PatreonWebhookLog> PatreonWebhookLogs { get; set; }
public DbSet<UserOAuthClient> UserOAuthClients { get; set; }
public DbSet<PastAccountName> PastAccountNames { get; set; }
public DbSet<AccountLog> AccountLogs { get; set; }
public DbSet<Hwid> Hwids { get; set; }
public DbSet<HwidUser> HwidUsers { get; set; }

// IS4 configuration.
public DbSet<Client> Clients { get; set; }
public DbSet<ClientSecret> ClientSecrets { get; set; }
public DbSet<ClientCorsOrigin> ClientCorsOrigins { get; set; }
public DbSet<IdentityResource> IdentityResources { get; set; }
public DbSet<ApiResource> ApiResources { get; set; }
public DbSet<ApiScope> ApiScopes { get; set; }

// IS4 operational.
public DbSet<PersistedGrant> PersistedGrants { get; set; }
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }

Task<int> IPersistedGrantDbContext.SaveChangesAsync()
{
return base.SaveChangesAsync();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using static SS14.Auth.Shared.Data.OpeniddictDefaultTypes;

namespace SS14.Auth.Shared.Data;

Expand All @@ -11,6 +12,7 @@ public ApplicationDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
optionsBuilder.UseNpgsql("Server=localhost");
optionsBuilder.UseOpenIddict<SpaceApplication, DefaultAuthorization, DefaultScope, DefaultToken, string>();
return new ApplicationDbContext(optionsBuilder.Options);
}
}
Loading
Loading