Skip to content

OP-05: Inspect PostgreSQL connection info

This operation reads the secure PostgreSQL credential for an instance and user directly from the Environment API and returns the raw credential, the split user and password, and the composed connection string. It performs no probe, uses no cache and writes no audit log, and it discloses the plaintext password.

Field Value
Operation ID OP-05
Trigger HTTP request from an authorized caller
Entry endpoint POST /v1/Admin/GetPostgresConnectionInfo
Owning component AdminController.GetPostgresConnectionInfo, delegating to AdminController.GetConnectionInfo
Inputs Query values server, instance and userName (inferred query binding, no body); template postgresqlconnectiontemplate and a secure credential
Outputs Dictionary<string,string> with keys credentials, user, pw, connectionString and optionally Error
Failure response A failed credential split still returns 200 with an Error entry; a missing secure setting or template raises a failure whose status is not visible in source**

Steps

  1. Authorize the caller against resource DBConnAPIRetrieveResource (BR-DBC-025)
  2. Build the lower-cased secure-setting key postgres_<instance>_<user>; the server is not part of the credential key (BR-DBC-005, BR-DBC-006)
  3. Read the template postgresqlconnectiontemplate and replace {SERVER} and {INSTANCE} (BR-DBC-007)
  4. Read and decrypt the secure setting directly, with no existence check, no probe and no cache (BR-DBC-023)
  5. Split the credential at the first pipe inside a bare try/catch
  6. On failure: add an Error entry, leave user and pw empty, and continue with status 200 (BR-DBC-024)
  7. Substitute {USER} and {PW} (BR-DBC-008)
  8. Return the dictionary with status 200

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    A["Authorize DBConnAPIRetrieveResource"] -->|"Denied"| Z["Authorization denial, status not visible in source"]
    A --> B["Build secure key and read template"]
    B -->|"Template missing"| X["Unhandled/package error, status not visible in source"]
    B --> C["Read and decrypt secure setting"]
    C -->|"Secure setting missing or read fails"| X2["Unhandled/package error, status not visible in source"]
    C --> D{"Credential split at pipe succeeds?"}
    D -->|"Yes"| E["Set user and pw"]
    D -->|"No"| F["Add Error entry, user and pw empty"]
    E --> G["Substitute into template"]
    F --> G
    G --> H["Return dictionary, 200"]

Transaction and side effects

Aspect Finding
Unit of work None
Commit point None
Records written None
Downstream calls SAIF Environment API through IEnvironmentClient
Repeat-call behavior Every call re-reads the secure setting; nothing is cached

Logging

Surface Written content
None in this controller AdminController writes no log entry, so disclosures are not audit-logged locally

Error handling

  • Credential without a pipe: swallowed by the local try/catch and reported in the Error entry with status 200
  • Missing secure setting or missing template: unhandled; handled by package middleware with a status that is not visible in source**
  • Authorization failure: produced by the package authorization handler†; the status is not visible in source**

Note: Statements marked with † are derived from dependency library documentation via the Legends CLI. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • DBConnectionAPI/DBConnectionAPI/Controllers/AdminController.cs
  • DBConnectionAPI/DBConnectionAPI/Services/ConnectionManager.cs
  • DBConnectionAPI/DBConnectionAPI/Services/IConnectionManager.cs