Add secure administrator operations console

Provide TOTP-authenticated, role-controlled user and credit workflows with paginated audit data and SQL-backed statistics so operations can manage growth safely.
This commit is contained in:
Rocky
2026-08-17 15:20:34 +08:00
parent 676bfd2451
commit 1a9c518f96
76 changed files with 14602 additions and 3 deletions
@@ -34,6 +34,48 @@ class AppConfigTest : FunSpec({
config.database.migrationUsername shouldBe "test_migrator"
}
test("production accepts enabled admin bootstrap with Argon2 PHC hash") {
val config = validProductionConfig().apply {
put("app.admin.enabled", "true")
put("app.admin.bootstrapEnabled", "true")
put("app.admin.bootstrapOperatorId", "2c031def-4517-4fde-b592-5db3a3eefdf6")
put("app.admin.bootstrapUsername", "owner")
put(
"app.admin.bootstrapPasswordHash",
"\$argon2id\$v=19\$m=65536,t=3,p=1\$c2FsdHNhbHRzYWx0c2FsdA\$aGFzaGhhc2hoYXNoaGFzaGhhc2hoYXNoaGFzaA",
)
put("app.admin.bootstrapTotpSecretBase32", "JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP")
}
val admin = AppConfig.from(config).admin
admin.enabled shouldBe true
admin.bootstrapEnabled shouldBe true
}
test("production accepts established admin without bootstrap credentials") {
val config = validProductionConfig().apply {
put("app.admin.enabled", "true")
put("app.admin.bootstrapEnabled", "false")
}
val admin = AppConfig.from(config).admin
admin.enabled shouldBe true
admin.bootstrapEnabled shouldBe false
admin.bootstrapTotpSecretBase32 shouldBe null
}
test("admin bootstrap cannot be enabled while admin routes are disabled") {
val config = validProductionConfig().apply {
put("app.admin.enabled", "false")
put("app.admin.bootstrapEnabled", "true")
}
shouldThrow<IllegalArgumentException> {
AppConfig.from(config)
}.message.orEmpty() shouldContain "bootstrapEnabled requires"
}
test("production fails fast when Apple signing credentials are missing") {
val config = validProductionConfig().apply {
put("app.apple.keyId", "")