Skip to content

Commit

Permalink
ECER-485: Authentication SSO (BCeID) (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: ytqsl <[email protected]>
  • Loading branch information
pcatkins and ytqsl authored Dec 6, 2023
1 parent 31a88b3 commit 0baa710
Show file tree
Hide file tree
Showing 38 changed files with 22,285 additions and 2,322 deletions.
5 changes: 4 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,7 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml

# Ignore all JetBrains files
.idea/
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using ECER.Managers.Registry;
using ECER.Utilities.Hosting;

namespace ECER.Clients.RegistryPortal.Server;

/// <summary>
/// Registry API endpoint map
/// </summary>
public static class ApplicationsEndpoints
public class ApplicationsEndpoints : IRegisterEndpoints
{
internal static void Map(WebApplication app)
public void Register(IEndpointRouteBuilder endpointRouteBuilder)
{
app.MapPost("/api/applications", async (NewApplicationRequest request, HttpContext ctx) =>
endpointRouteBuilder.MapPost("/api/applications", async (NewApplicationRequest request, HttpContext ctx) =>
{
var handlers = ctx.RequestServices.GetRequiredService<ApplicationHandlers>();
var cmd = new SubmitNewApplicationCommand();
Expand All @@ -24,7 +22,7 @@ internal static void Map(WebApplication app)
return op;
});

app.MapGet("/api/applications", async (HttpContext ctx) =>
endpointRouteBuilder.MapGet("/api/applications", async (HttpContext ctx) =>
{
var handlers = ctx.RequestServices.GetRequiredService<ApplicationHandlers>();
var query = new ApplicationsQuery();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using ECER.Utilities.Hosting;

namespace ECER.Clients.RegistryPortal.Server;

public class ConfigurationEndpoints : IRegisterEndpoints
{
public void Register(IEndpointRouteBuilder endpointRouteBuilder)
{
endpointRouteBuilder.MapGet("/api/configuration", async (HttpContext ctx) =>
{
await Task.CompletedTask;
var configuration = ctx.RequestServices.GetRequiredService<IConfiguration>();
var appConfig = configuration.Get<ApplicationConfiguration>();
return TypedResults.Ok(appConfig);
}).WithOpenApi("Frontend Configuration", "Frontend Configuration endpoint", "configuration");
}
}

#pragma warning disable CA2227 // Collection properties should be read only

public class ApplicationConfiguration
{
public Dictionary<string, OidcAuthenticationSettings> AuthenticationMethods { get; set; } = [];
}

#pragma warning restore CA2227 // Collection properties should be read only

public record OidcAuthenticationSettings
{
public string Authority { get; set; } = null!;
public string ClientId { get; set; } = null!;
public string Scope { get; set; } = null!;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Reflection;
using ECER.Clients.RegistryPortal.Server;
using ECER.Utilities.Hosting;

var builder = WebApplication.CreateBuilder(args);

HostConfigurer.Configure(builder.Services, builder.Configuration);
HostConfigurer.ConfigureAll(builder.Services, builder.Configuration);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(opts =>
Expand All @@ -21,6 +20,6 @@
app.UseSwaggerUI();
}

ApplicationsEndpoints.Map(app);
EndpointsRegistrar.RegisterAll(app);

app.Run();
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Default": "Debug",
"Microsoft.AspNetCore": "Warning"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ module.exports = {
"prettier/prettier": ["error", { endOfLine: "auto" }],
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{ vars: "all", args: "after-used", argsIgnorePattern: "^_" },
],
"unused-imports/no-unused-vars": ["warn", { vars: "all", args: "after-used", argsIgnorePattern: "^_" }],
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"vue/multi-word-component-names": "off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ coverage
*.njsproj
*.sln
*.sw?

*.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
types
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "printWidth": 120 }
Loading

0 comments on commit 0baa710

Please sign in to comment.