Add project files.

This commit is contained in:
Khwezi Mngoma
2026-06-05 22:07:25 +02:00
parent 59ea7de742
commit 437e8c5c08
978 changed files with 151911 additions and 0 deletions
@@ -0,0 +1,22 @@
using System;
using System.Reflection;
using Skoruba.Duende.IdentityServer.Admin.EntityFramework.Configuration.Configuration;
using SqlMigrationAssembly = LiteCharmsSecurity.Admin.EntityFramework.SqlServer.Helpers.MigrationAssembly;
using PostgreSQLMigrationAssembly = LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL.Helpers.MigrationAssembly;
namespace LiteCharmsSecurity.Admin.Api.Configuration;
public static class MigrationAssemblyConfiguration
{
public static string GetMigrationAssemblyByProvider(DatabaseProviderConfiguration databaseProvider)
{
return databaseProvider.ProviderType switch
{
DatabaseProviderType.SqlServer => typeof(SqlMigrationAssembly).GetTypeInfo().Assembly.GetName().Name,
DatabaseProviderType.PostgreSQL => typeof(PostgreSQLMigrationAssembly).GetTypeInfo()
.Assembly.GetName()
.Name,
_ => throw new ArgumentOutOfRangeException()
};
}
}
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using NSwag;
using NSwag.Generation.Processors.Security;
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Configuration;
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Configuration.Authorization;
namespace LiteCharmsSecurity.Admin.Api.Configuration;
public static class StartupHelpers
{
public static void AddSwaggerServices(this IServiceCollection services, AdminApiConfiguration adminApiConfiguration)
{
services.AddEndpointsApiExplorer();
services.AddOpenApiDocument(configure =>
{
configure.Title = adminApiConfiguration.ApiName;
configure.Version = adminApiConfiguration.ApiVersion;
configure.AddSecurity("OAuth2", new OpenApiSecurityScheme
{
Type = OpenApiSecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows
{
AuthorizationCode = new OpenApiOAuthFlow
{
AuthorizationUrl = $"{adminApiConfiguration.IdentityServerBaseUrl}/connect/authorize",
TokenUrl = $"{adminApiConfiguration.IdentityServerBaseUrl}/connect/token",
Scopes = new Dictionary<string, string>
{
{ adminApiConfiguration.OidcApiName, adminApiConfiguration.ApiName }
}
}
}
});
configure.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("OAuth2"));
configure.OperationProcessors.Add(new AuthorizeCheckOperationProcessor(adminApiConfiguration));
});
}
}
@@ -0,0 +1,64 @@
// Copyright (c) Jan Škoruba. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Skoruba.Duende.IdentityServer.Admin.EntityFramework.Configuration.Configuration;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.DbContexts;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.Entities.Identity;
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Helpers;
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Middlewares;
using Skoruba.Duende.IdentityServer.Shared.Configuration.Constants;
namespace LiteCharmsSecurity.Admin.Api.Configuration.Test
{
public class StartupTest : Startup
{
public StartupTest(IWebHostEnvironment env, IConfiguration configuration) : base(env, configuration)
{
}
public override void RegisterDbContexts(IServiceCollection services,
DatabaseMigrationsConfiguration databaseMigration)
{
services.RegisterDbContextsStaging<AdminIdentityDbContext, IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, AdminLogDbContext, AdminAuditLogDbContext, IdentityServerDataProtectionDbContext>();
}
public override void RegisterAuthentication(IServiceCollection services)
{
services
.AddIdentity<UserIdentity, UserIdentityRole>(options =>
{
Configuration.GetSection(nameof(IdentityOptions)).Bind(options);
options.Stores.SchemaVersion = IdentityStoreDefaults.SchemaVersion;
options.Stores.MaxLengthForKeys = IdentityStoreDefaults.MaxLengthForKeys;
})
.AddEntityFrameworkStores<AdminIdentityDbContext>()
.AddDefaultTokenProviders();
services.AddAuthentication(options =>
{
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultForbidScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddCookie(JwtBearerDefaults.AuthenticationScheme);
}
public override void RegisterAuthorization(IServiceCollection services)
{
services.AddAuthorizationPolicies();
}
public override void UseAuthentication(IApplicationBuilder app)
{
app.UseAuthentication();
app.UseMiddleware<AuthenticatedTestRequestMiddleware>();
}
}
}
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG TARGETARCH
WORKDIR /src
COPY ["src/LiteCharmsSecurity.Admin.Api/LiteCharmsSecurity.Admin.Api.csproj", "src/LiteCharmsSecurity.Admin.Api/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.Shared/LiteCharmsSecurity.Admin.EntityFramework.Shared.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.Shared/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.SqlServer/LiteCharmsSecurity.Admin.EntityFramework.SqlServer.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.SqlServer/"]
COPY ["src/LiteCharmsSecurity.Shared/LiteCharmsSecurity.Shared.csproj", "src/LiteCharmsSecurity.Shared/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL/"]
RUN dotnet restore -a $TARGETARCH "src/LiteCharmsSecurity.Admin.Api/LiteCharmsSecurity.Admin.Api.csproj"
COPY . .
WORKDIR "/src/src/LiteCharmsSecurity.Admin.Api"
RUN dotnet build -a $TARGETARCH "LiteCharmsSecurity.Admin.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish -a $TARGETARCH "LiteCharmsSecurity.Admin.Api.csproj" -c Release --no-restore -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENTRYPOINT ["dotnet", "LiteCharmsSecurity.Admin.Api.dll"]
@@ -0,0 +1,65 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>1cc472a2-4e4b-48ce-846b-5219f71fc643</UserSecretsId>
<DockerComposeProjectPath>..\..\docker-compose.dcproj</DockerComposeProjectPath>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL\LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL.csproj" />
<ProjectReference Include="..\LiteCharmsSecurity.Admin.EntityFramework.SqlServer\LiteCharmsSecurity.Admin.EntityFramework.SqlServer.csproj" />
<ProjectReference Include="..\LiteCharmsSecurity.Shared\LiteCharmsSecurity.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NSwag.CodeGeneration" Version="14.7.1" />
<PackageReference Include="NSwag.CodeGeneration.TypeScript" Version="14.7.1" />
<PackageReference Include="NSwag.Generation" Version="14.7.1" />
<PackageReference Include="NSwag.Generation.AspNetCore" Version="14.7.1" />
<PackageReference Include="NSwag.Generation.WebApi" Version="14.7.1" />
<PackageReference Include="NSwag.AspNetCore" Version="14.7.1" />
<PackageReference Include="NSwag.MSBuild" Version="14.7.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Skoruba.Duende.IdentityServer.Admin.UI.Api" Version="3.0.0-rc4" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>
<Target Name="NSwag" BeforeTargets="AfterBuild" Condition="'$(Configuration)'=='Debug'">
<Exec ContinueOnError="true" Command="$(NSwagExe_Net100) run nswag.json /variables:Configuration=$(Configuration)">
<Output TaskParameter="ExitCode" PropertyName="NSwagExitCode" />
<Output TaskParameter="ConsoleOutput" PropertyName="NSwagOutput" />
</Exec>
<Message Text="$(NSwagOutput)" Condition="'$(NSwagExitCode)' == '0'" Importance="low" />
<Error Text="$(NSwagOutput)" Condition="'$(NSwagExitCode)' != '0'" />
</Target>
</Project>
+153
View File
@@ -0,0 +1,153 @@
// Copyright (c) Jan Škoruba. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Skoruba.Duende.IdentityServer.Admin.EntityFramework.Configuration.Configuration;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.DbContexts;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.Entities.Identity;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.Helpers;
using Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers;
namespace LiteCharmsSecurity.Admin.Api
{
public class Program
{
private const string SeedArgs = "/seed";
private const string MigrateOnlyArgs = "/migrateonly";
public static async Task Main(string[] args)
{
var configuration = GetConfiguration(args);
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
try
{
DockerHelpers.ApplyDockerConfiguration(configuration);
var host = CreateHostBuilder(args).Build();
var migrationComplete = await ApplyDbMigrationsWithDataSeedAsync(args, configuration, host);
if (await MigrateOnlyOperationAsync(args, host, migrationComplete)) return;
await host.RunAsync();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
await Log.CloseAndFlushAsync();
}
}
private static async Task<bool> MigrateOnlyOperationAsync(string[] args, IHost host, bool migrationComplete)
{
if (args.All(x => x != MigrateOnlyArgs)) return false;
await host.StopAsync();
if (!migrationComplete)
{
Environment.ExitCode = -1;
}
return true;
}
private static async Task<bool> ApplyDbMigrationsWithDataSeedAsync(string[] args, IConfiguration configuration,
IHost host)
{
var applyDbMigrationWithDataSeedFromProgramArguments = args.Any(x => x == SeedArgs);
if (applyDbMigrationWithDataSeedFromProgramArguments) args = args.Except(new[] { SeedArgs }).ToArray();
var seedConfiguration = configuration.GetSection(nameof(SeedConfiguration)).Get<SeedConfiguration>();
var databaseMigrationsConfiguration = configuration.GetSection(nameof(DatabaseMigrationsConfiguration))
.Get<DatabaseMigrationsConfiguration>();
return await DbMigrationHelpers
.ApplyDbMigrationsWithDataSeedAsync<IdentityServerConfigurationDbContext, AdminIdentityDbContext,
IdentityServerPersistedGrantDbContext, AdminLogDbContext, AdminAuditLogDbContext,
IdentityServerDataProtectionDbContext, AdminConfigurationDbContext, UserIdentity, UserIdentityRole>(host,
applyDbMigrationWithDataSeedFromProgramArguments, seedConfiguration,
databaseMigrationsConfiguration);
}
private static IConfiguration GetConfiguration(string[] args)
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var isDevelopment = environment == Environments.Development;
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddJsonFile("serilog.json", optional: true, reloadOnChange: true)
.AddJsonFile($"serilog.{environment}.json", optional: true, reloadOnChange: true);
if (isDevelopment)
{
configurationBuilder.AddUserSecrets<Startup>(true);
}
var configuration = configurationBuilder.Build();
configuration.AddAzureKeyVaultConfiguration(configurationBuilder);
configurationBuilder.AddCommandLine(args);
configurationBuilder.AddEnvironmentVariables();
return configurationBuilder.Build();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostContext, configApp) =>
{
var configurationRoot = configApp.Build();
configApp.AddJsonFile("serilog.json", optional: true, reloadOnChange: true);
configApp.AddJsonFile("identitydata.json", optional: true, reloadOnChange: true);
configApp.AddJsonFile("identityserverdata.json", optional: true, reloadOnChange: true);
var env = hostContext.HostingEnvironment;
configApp.AddJsonFile($"serilog.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
configApp.AddJsonFile($"identitydata.{env.EnvironmentName}.json", optional: true,
reloadOnChange: true);
configApp.AddJsonFile($"identityserverdata.{env.EnvironmentName}.json", optional: true,
reloadOnChange: true);
if (env.IsDevelopment())
{
configApp.AddUserSecrets<Startup>(true);
}
configurationRoot.AddAzureKeyVaultConfiguration(configApp);
configApp.AddEnvironmentVariables();
configApp.AddCommandLine(args);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(options => options.AddServerHeader = false);
webBuilder.UseStartup<Startup>();
})
.UseSerilog((hostContext, loggerConfig) =>
{
loggerConfig
.ReadFrom.Configuration(hostContext.Configuration)
.Enrich.WithProperty("ApplicationName", hostContext.HostingEnvironment.ApplicationName);
});
}
}
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44302",
"sslPort": 44302
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"LiteCharmsSecurity.Admin.Api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:44302"
}
}
}
+129
View File
@@ -0,0 +1,129 @@
// Copyright (c) Jan Škoruba. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
using System.IdentityModel.Tokens.Jwt;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NSwag.AspNetCore;
using Skoruba.AuditLogging.EntityFramework.Entities;
using LiteCharmsSecurity.Admin.Api.Configuration;
using Skoruba.Duende.IdentityServer.Admin.EntityFramework.Configuration.Configuration;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.DbContexts;
using LiteCharmsSecurity.Admin.EntityFramework.Shared.Entities.Identity;
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Configuration;
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Helpers;
using Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers;
using LiteCharmsSecurity.Shared.Dtos;
using LiteCharmsSecurity.Shared.Dtos.Identity;
using StartupHelpers = Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers.StartupHelpers;
namespace LiteCharmsSecurity.Admin.Api
{
public class Startup
{
public Startup(IWebHostEnvironment env, IConfiguration configuration)
{
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
HostingEnvironment = env;
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public IWebHostEnvironment HostingEnvironment { get; }
public void ConfigureServices(IServiceCollection services)
{
var adminApiConfiguration = Configuration.GetSection(nameof(AdminApiConfiguration)).Get<AdminApiConfiguration>();
services.AddSingleton(adminApiConfiguration);
var databaseProviderConfiguration = Configuration.GetSection(nameof(DatabaseProviderConfiguration)).Get<DatabaseProviderConfiguration>();
var databaseMigration = StartupHelpers.GetDatabaseMigrationsConfiguration(Configuration, MigrationAssemblyConfiguration.GetMigrationAssemblyByProvider(databaseProviderConfiguration));
// Add DbContexts
RegisterDbContexts(services, databaseMigration);
// Add email senders which is currently setup for SendGrid and SMTP
services.AddEmailSenders(Configuration);
// Add authentication services
RegisterAuthentication(services);
// Add authorization services
RegisterAuthorization(services);
services.AddIdentityServerAdminApi<AdminIdentityDbContext, IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, IdentityServerDataProtectionDbContext, AdminLogDbContext, AdminAuditLogDbContext, AdminConfigurationDbContext, AuditLog,
IdentityUserDto, IdentityRoleDto, UserIdentity, UserIdentityRole, string, UserIdentityUserClaim, UserIdentityUserRole,
UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken, UserIdentityPasskey,
IdentityUsersDto, IdentityRolesDto, IdentityUserRolesDto,
IdentityUserClaimsDto, IdentityUserProviderDto, IdentityUserProvidersDto, IdentityUserChangePasswordDto,
IdentityRoleClaimsDto, IdentityUserClaimDto, IdentityRoleClaimDto>(Configuration, adminApiConfiguration);
services.AddSwaggerServices(adminApiConfiguration);
services.AddIdSHealthChecks<IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, AdminIdentityDbContext, AdminLogDbContext, AdminAuditLogDbContext, IdentityServerDataProtectionDbContext>(Configuration, adminApiConfiguration);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AdminApiConfiguration adminApiConfiguration)
{
app.AddForwardHeaders(Configuration);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseOpenApi();
app.UseSwaggerUi(settings =>
{
settings.OAuth2Client = new OAuth2ClientSettings
{
ClientId = adminApiConfiguration.OidcSwaggerUIClientId,
AppName = adminApiConfiguration.ApiName,
UsePkceWithAuthorizationCodeGrant = true,
ClientSecret = null
};
});
app.UseRouting();
UseAuthentication(app);
app.UseCors();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHealthChecks("/health", new HealthCheckOptions
{
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
});
}
public virtual void RegisterDbContexts(IServiceCollection services,
DatabaseMigrationsConfiguration databaseMigration)
{
services.AddDbContexts<AdminIdentityDbContext, IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, AdminLogDbContext, AdminAuditLogDbContext, IdentityServerDataProtectionDbContext, AdminConfigurationDbContext, AuditLog>(Configuration, databaseMigration);
}
public virtual void RegisterAuthentication(IServiceCollection services)
{
services.AddApiAuthentication<AdminIdentityDbContext, UserIdentity, UserIdentityRole>(Configuration);
}
public virtual void RegisterAuthorization(IServiceCollection services)
{
services.AddAuthorizationPolicies();
}
public virtual void UseAuthentication(IApplicationBuilder app)
{
app.UseAuthentication();
}
}
}
@@ -0,0 +1,23 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebApiClientBase = void 0;
class WebApiClientBase {
transformOptions(options) {
return __awaiter(this, void 0, void 0, function* () {
const headers = new Headers(options.headers);
headers.set("X-ANTI-CSRF", "1");
return Object.assign(Object.assign({}, options), { headers });
});
}
}
exports.WebApiClientBase = WebApiClientBase;
//# sourceMappingURL=base-client.js.map
@@ -0,0 +1 @@
{"version":3,"file":"base-client.js","sourceRoot":"","sources":["../../src/base-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAa,gBAAgB;IACT,gBAAgB,CAAC,OAAoB;;YACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YAEhC,uCACO,OAAO,KACV,OAAO,IACT;QACN,CAAC;KAAA;CACJ;AAVD,4CAUC"}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,29 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.client = void 0;
const client = __importStar(require("./client"));
exports.client = client;
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAG/B,wBAAM"}
@@ -0,0 +1,19 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
export class WebApiClientBase {
transformOptions(options) {
return __awaiter(this, void 0, void 0, function* () {
const headers = new Headers(options.headers);
headers.set("X-ANTI-CSRF", "1");
return Object.assign(Object.assign({}, options), { headers });
});
}
}
//# sourceMappingURL=base-client.js.map
@@ -0,0 +1 @@
{"version":3,"file":"base-client.js","sourceRoot":"","sources":["../../src/base-client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,OAAO,gBAAgB;IACT,gBAAgB,CAAC,OAAoB;;YACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YAEhC,uCACO,OAAO,KACV,OAAO,IACT;QACN,CAAC;KAAA;CACJ"}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=dayjs.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dayjs.js","sourceRoot":"","sources":["../../dayjs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
import * as client from './client';
export { client };
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EACH,MAAM,EACT,CAAA"}
@@ -0,0 +1,3 @@
export declare class WebApiClientBase {
protected transformOptions(options: RequestInit): Promise<RequestInit>;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,2 @@
import * as client from './client';
export { client };
@@ -0,0 +1,50 @@
{
"name": "@skoruba/duende.identityserver.admin.api.client",
"version": "2.7.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@skoruba/duende.identityserver.admin.api.client",
"version": "2.7.0",
"license": "Apache-2.0",
"dependencies": {
"dayjs": "1.11.11",
"typescript": "5.1.6"
},
"devDependencies": {
"@tsconfig/recommended": "1.0.2",
"@types/node": "20.4.4"
}
},
"node_modules/@tsconfig/recommended": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.2.tgz",
"integrity": "sha512-dbHBtbWBOjq0/otpopAE02NT2Cm05Qe2JsEKeCf/wjSYbI2hz8nCqnpnOJWHATgjDz4fd3dchs3Wy1gQGjfN6w==",
"dev": true
},
"node_modules/@types/node": {
"version": "20.4.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.4.tgz",
"integrity": "sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew==",
"dev": true
},
"node_modules/dayjs": {
"version": "1.11.11",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz",
"integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg=="
},
"node_modules/typescript": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz",
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
}
}
}
@@ -0,0 +1,26 @@
{
"name": "@skoruba/duende.identityserver.admin.api.client",
"version": "3.0.0-rc4",
"description": "Lite Charms Security Api Client",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"files": [
"dist"
],
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:esm": "tsc",
"build:cjs": "tsc --module CommonJS --outDir dist/cjs"
},
"author": "Skoruba",
"license": "Apache-2.0",
"devDependencies": {
"@tsconfig/recommended": "1.0.2",
"@types/node": "20.4.4"
},
"dependencies": {
"dayjs": "1.11.11",
"typescript": "5.1.6"
},
"types": "dist/types/index.d.ts"
}
@@ -0,0 +1,11 @@
export class WebApiClientBase {
protected async transformOptions(options: RequestInit): Promise<RequestInit> {
const headers = new Headers(options.headers);
headers.set("X-ANTI-CSRF", "1");
return {
...options,
headers,
};
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
import * as client from './client';
export {
client
}
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowJs": true,
"declaration": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"lib": ["es5", "es2015", "es2016", "dom", "esnext"],
"types": ["node"],
"module": "es2015",
"moduleResolution": "node",
"noImplicitAny": true,
"noUnusedLocals": true,
"outDir": "./dist/esm", // Output directory for compiled files
"sourceMap": true,
"strict": true,
"target": "es6",
"declarationDir": "./dist/types", // Output directory for declaration files
"skipLibCheck": true
},
"include": ["src/**/*.ts"], // Include all TypeScript files in src directory
"exclude": ["node_modules", "dist", "src/dayjs.ts"] // Exclude dist, node_modules, and specific file
}
@@ -0,0 +1,88 @@
{
"DatabaseProviderConfiguration": {
"ProviderType": "PostgreSQL"
},
"ForwardedHeadersConfiguration": {
"Enabled": true,
"AllowAll": true,
"KnownProxies": [],
"KnownNetworks": [],
"ForwardLimit": 1
},
"ConnectionStrings": {
"ConfigurationDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;",
"PersistedGrantDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;",
"IdentityDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;",
"AdminLogDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;",
"AdminAuditLogDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;",
"DataProtectionDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;",
"AdminConfigurationDbConnection": "Server=192.168.1.170;Port=5432;Database=skoruba;User Id=skoruba;Password=wsb7sebwm$BoZ9;application_name=litecharms_security;"
},
"AdminApiConfiguration": {
"ApplicationName": "Lite Charms Security UI",
"ApiName": "Lite Charms Security Api",
"ApiVersion": "v1",
"ApiBaseUrl": "https://localhost:44302",
"IdentityServerBaseUrl": "https://localhost:44310",
"OidcSwaggerUIClientId": "skoruba_identity_admin_api_swaggerui",
"OidcApiName": "skoruba_identity_admin_api",
"AdministrationRole": "Admin",
"RequireHttpsMetadata": false,
"CorsAllowAnyOrigin": true,
"CorsAllowOrigins": []
},
"SmtpConfiguration": {
"Host": "",
"Login": "",
"Password": ""
},
"SendGridConfiguration": {
"ApiKey": "",
"SourceEmail": "",
"SourceName": ""
},
"AuditLoggingConfiguration": {
"Source": "IdentityServer.Admin.Api",
"SubjectIdentifierClaim": "sub",
"SubjectNameClaim": "name",
"ClientIdClaim": "client_id"
},
"IdentityOptions": {
"Password": {
"RequiredLength": 8
},
"User": {
"RequireUniqueEmail": true
},
"SignIn": {
"RequireConfirmedAccount": false
}
},
"IdentityTableConfiguration": {
"IdentityRoles": "Roles",
"IdentityRoleClaims": "RoleClaims",
"IdentityUserRoles": "UserRoles",
"IdentityUsers": "Users",
"IdentityUserLogins": "UserLogins",
"IdentityUserClaims": "UserClaims",
"IdentityUserTokens": "UserTokens"
},
"DataProtectionConfiguration": {
"ProtectKeysWithAzureKeyVault": false
},
"AzureKeyVaultConfiguration": {
"AzureKeyVaultEndpoint": "",
"ClientId": "",
"ClientSecret": "",
"TenantId": "",
"UseClientCredentials": true,
"DataProtectionKeyIdentifier": "",
"ReadConfigurationFromKeyVault": false
},
"SeedConfiguration": {
"ApplySeed": true
},
"DatabaseMigrationsConfiguration": {
"ApplyDatabaseMigrations": true
}
}
@@ -0,0 +1,25 @@
{
"IdentityData": {
"Roles": [
{
"Name": "Admin"
}
],
"Users": [
{
"Username": "admin",
"Password": "4w%HPXmwhHjq5A",
"Email": "khwezi@litecharms.co.za",
"Roles": [
"Admin"
],
"Claims": [
{
"Type": "name",
"Value": "admin"
}
]
}
]
}
}
@@ -0,0 +1,112 @@
{
"IdentityServerData": {
"IdentityResources": [
{
"Name": "roles",
"Enabled": true,
"DisplayName": "Roles",
"UserClaims": ["role"]
},
{
"Name": "openid",
"Enabled": true,
"Required": true,
"DisplayName": "Your user identifier",
"UserClaims": ["sub"]
},
{
"Name": "profile",
"Enabled": true,
"DisplayName": "User profile",
"Description": "Your user profile information (first name, last name, etc.)",
"Emphasize": true,
"UserClaims": [
"name",
"family_name",
"given_name",
"middle_name",
"nickname",
"preferred_username",
"profile",
"picture",
"website",
"gender",
"birthdate",
"zoneinfo",
"locale",
"updated_at"
]
},
{
"Name": "email",
"Enabled": true,
"DisplayName": "Your email address",
"Emphasize": true,
"UserClaims": ["email", "email_verified"]
},
{
"Name": "address",
"Enabled": true,
"DisplayName": "Your address",
"Emphasize": true,
"UserClaims": ["address"]
}
],
"ApiScopes": [
{
"Name": "skoruba_identity_admin_api",
"DisplayName": "skoruba_identity_admin_api",
"Required": true,
"UserClaims": ["role", "name"]
}
],
"ApiResources": [
{
"Name": "skoruba_identity_admin_api",
"Scopes": ["skoruba_identity_admin_api"]
}
],
"Clients": [
{
"ClientId": "litecharms-admin-client",
"ClientName": "litecharms-admin-client",
"ClientUri": "https://localhost:7127",
"AllowedGrantTypes": ["authorization_code"],
"RequireConsent": false,
"RequirePkce": true,
"ClientSecrets": [
{
"Value": "13c0e7ada2a123cfe31e99e5c63e252c"
}
],
"RedirectUris": ["https://localhost:7127/signin-oidc"],
"FrontChannelLogoutUri": "https://localhost:7127/signout-oidc",
"PostLogoutRedirectUris": [
"https://localhost:7127/signout-callback-oidc"
],
"AllowedCorsOrigins": ["https://localhost:7127"],
"AllowOfflineAccess": true,
"AllowedScopes": [
"openid",
"email",
"profile",
"roles",
"skoruba_identity_admin_api"
],
"RequirePushedAuthorization": true
},
{
"ClientId": "skoruba_identity_admin_api_swaggerui",
"ClientName": "skoruba_identity_admin_api_swaggerui",
"AllowedGrantTypes": ["authorization_code"],
"RequireClientSecret": false,
"RequirePkce": true,
"RedirectUris": [
"https://localhost:44302/swagger/oauth2-redirect.html"
],
"AllowedScopes": ["skoruba_identity_admin_api"],
"AllowedCorsOrigins": ["https://localhost:44302"]
}
]
}
}
+117
View File
@@ -0,0 +1,117 @@
{
"runtime": "Net100",
"defaultVariables": null,
"documentGenerator": {
"aspNetCoreToOpenApi": {
"project": "LiteCharmsSecurity.Admin.Api.csproj",
"msBuildProjectExtensionsPath": null,
"configuration": null,
"runtime": "",
"targetFramework": "",
"noBuild": true,
"verbose": true,
"workingDirectory": null,
"requireParametersWithoutDefault": true,
"apiGroupNames": null,
"defaultPropertyNameHandling": "CamelCase",
"defaultReferenceTypeNullHandling": "Null",
"defaultDictionaryValueReferenceTypeNullHandling": "NotNull",
"defaultResponseReferenceTypeNullHandling": "NotNull",
"defaultEnumHandling": "Integer",
"flattenInheritanceHierarchy": false,
"generateKnownTypes": true,
"generateEnumMappingDescription": false,
"generateXmlObjects": false,
"generateAbstractProperties": true,
"generateAbstractSchemas": true,
"ignoreObsoleteProperties": false,
"allowReferencesWithProperties": false,
"excludedTypeNames": [],
"serviceHost": null,
"serviceBasePath": null,
"serviceSchemes": [],
"infoTitle": "Skoruba",
"infoDescription": null,
"infoVersion": "1.0.0",
"documentTemplate": null,
"documentProcessorTypes": [],
"operationProcessorTypes": [],
"typeNameGeneratorType": null,
"schemaNameGeneratorType": null,
"contractResolverType": null,
"serializerSettingsType": null,
"useDocumentProvider": false,
"documentName": "v1",
"aspNetCoreEnvironment": null,
"createWebHostBuilderMethod": null,
"startupType": null,
"allowNullableBodyParameters": true,
"output": null,
"outputType": "OpenApi3",
"newLineBehavior": "Auto",
"assemblyPaths": [],
"assemblyConfig": null,
"referencePaths": [],
"useNuGetCache": false
}
},
"codeGenerators": {
"openApiToTypeScriptClient": {
"className": "{controller}Client",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 4.2,
"template": "Fetch",
"promiseType": "Promise",
"httpClass": "HttpClient",
"withCredentials": false,
"useSingletonProvider": true,
"injectionTokenType": "InjectionToken",
"rxJsVersion": 6.0,
"dateTimeType": "Date",
"nullValue": "Undefined",
"generateClientClasses": true,
"generateClientInterfaces": true,
"generateOptionalParameters": false,
"exportTypes": true,
"wrapDtoExceptions": false,
"exceptionClass": "SwaggerException",
"clientBaseClass": "WebApiClientBase",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"protectedMethods": [],
"configurationClass": null,
"useTransformOptionsMethod": true,
"useTransformResultMethod": false,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromOperationId",
"markOptionalProperties": false,
"generateCloneMethod": false,
"typeStyle": "Class",
"classTypes": [],
"extendedClasses": [],
"extensionCode": "TypescriptClient/src/base-client.ts",
"generateDefaultValues": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateConstructorInterface": true,
"convertConstructorInterfaceData": false,
"importRequiredTypes": false,
"useGetBaseUrlMethod": false,
"baseUrlTokenName": "API_BASE_URL",
"queryNullValue": "",
"inlineNamedDictionaries": false,
"inlineNamedAny": false,
"templateDirectory": null,
"typeNameGeneratorType": null,
"propertyNameGeneratorType": null,
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "TypescriptClient/src/client.ts"
}
}
}
@@ -0,0 +1,33 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Error",
"Override": {
"Skoruba": "Information"
}
},
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"path": "Log/skoruba_admin.txt",
"rollingInterval": "Day"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "Server=(localdb)\\mssqllocaldb;Database=IdentityServerAdmin;Trusted_Connection=True;MultipleActiveResultSets=true",
"tableName": "Log",
"columnOptionsSection": {
"addStandardColumns": [ "LogEvent" ],
"removeStandardColumns": [ "Properties" ]
}
}
}
]
}
}