feat: import prepared Catalog bindings through authenticated services

This commit is contained in:
Codex
2026-10-06 18:04:07 +02:00
parent d720da721b
commit af4c7b5df9
29 changed files with 835 additions and 35 deletions
+4 -1
View File
@@ -66,6 +66,9 @@ overrides: [%s]
}
bootstrap := fmt.Sprintf(`# Bootstrap input only; PostgreSQL Metadata Catalog remains the runtime authority.
schemaVersion: 1
authentication:
username: admin
passwordFile: %s
databases:
- workspaceId: CHANGE_ME
engine: postgres
@@ -78,7 +81,7 @@ databases:
username: CHANGE_ME
secretFiles:
password: %s
`, root("secrets/database-password"))
`, root("secrets/admin-password"), root("secrets/database-password"))
documents := map[string]string{
".gitignore": "*\n",
"thothii-installation.yaml": installation, "operator.env": environment,
@@ -5,6 +5,7 @@ import (
"encoding/json"
"io"
"regexp"
"slices"
"strconv"
"strings"
@@ -32,6 +33,32 @@ type Report struct {
func NewReport() Report {
return Report{SchemaVersion: 1, Scope: "application-documents", Issues: []Issue{}, Warnings: []string{}, DeferredChecks: []string{"release-assets", "external-connectivity", "catalog-import", "runtime-readiness"}}
}
// Validate the prepared administrative login offline; execution still uses the normal login API.
func CheckBootstrapAuthentication(installation config.Installation, path string, report *Report) {
data, err := safeio.ReadCanonicalPrivateRegular(path, 1<<20)
var doc struct {
Authentication struct {
Username string `yaml:"username"`
PasswordFile string `yaml:"passwordFile"`
} `yaml:"authentication"`
}
valid := err == nil && yaml.Unmarshal(data, &doc) == nil && doc.Authentication.Username != ""
password, passwordErr := safeio.ReadCanonicalPrivateRegular(doc.Authentication.PasswordFile, 4096)
auth, users, authErr := authconfig.Load(installation.AuthenticationDirectory())
matched := false
if valid && passwordErr == nil && authErr == nil && auth.Mode == "local" {
for _, user := range users.Users {
if strings.EqualFold(user.Username, doc.Authentication.Username) && user.Enabled && slices.Contains(user.Roles, authconfig.RoleAdmin) {
matched = authconfig.VerifyPassword([]byte(strings.TrimSpace(string(password))), user.PasswordHash)
}
}
}
clear(password)
if !matched {
report.Add("database-bootstrap.yaml", "authentication", "bootstrap_authentication_invalid", "Prepare an enabled local administrator username and its protected passwordFile before setup; both must match the authentication documents.")
}
}
func (r *Report) Add(document, field, code, correction string) {
r.OK = false
r.Issues = append(r.Issues, Issue{document, field, code, correction})