Add WmsLite monorepo with JWT auth, tenant context, and project READMEs.
Implement API security baseline (sys_user, JWT, audit fields, transactions, unique constraints) and Web real login with 401 handling. Document setup and development workflows in root, WmsLite.Api, and WmsLite.Web README files. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
fa1b286463
241 files changed
+31188
No files matched your search
@@ -0,0 +1,37 @@
|
||||
namespace WmsLite.Api.Infrastructure;
|
||||
|
||||
public static class ConnectionStringConfiguration
|
||||
{
|
||||
public const string PostgreSqlName = "PostgreSql";
|
||||
|
||||
/// <summary>
|
||||
/// 读取 PostgreSQL 连接串:环境变量 ConnectionStrings__PostgreSql → Configuration → 校验占位符。
|
||||
/// </summary>
|
||||
public static string ResolvePostgreSql(IConfiguration configuration)
|
||||
{
|
||||
var fromEnv = Environment.GetEnvironmentVariable($"ConnectionStrings__{PostgreSqlName}");
|
||||
var connectionString = !string.IsNullOrWhiteSpace(fromEnv)
|
||||
? fromEnv
|
||||
: configuration.GetConnectionString(PostgreSqlName);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Connection string '{PostgreSqlName}' is not configured. " +
|
||||
"Use dotnet user-secrets set ConnectionStrings:PostgreSql \"Host=...\" or environment variable ConnectionStrings__PostgreSql.");
|
||||
}
|
||||
|
||||
if (connectionString.Contains("Password=***", StringComparison.OrdinalIgnoreCase)
|
||||
|| connectionString.Contains("YOUR_PASSWORD", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Connection string '{PostgreSqlName}' contains a placeholder password. " +
|
||||
"Configure a real password using one of: " +
|
||||
"dotnet user-secrets set ConnectionStrings:PostgreSql \"Host=...;Password=...\", " +
|
||||
"environment variable ConnectionStrings__PostgreSql, " +
|
||||
"or appsettings.Development.local.json (gitignored).");
|
||||
}
|
||||
|
||||
return connectionString;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user