Web API: the per-instance signing key (new installations)

From Web API 5.13.24.1, every Web API instance needs a token signing key of its own. This page explains what the key is and where it fits in a new installation with the install scripts (version 3.2.0 or later). The install scripts’ RUNBOOK.md, shipped in the MFSQLConnectWebAPI-Install folder, remains the full procedure.

One instance per vault

Each vault has its own Connector database, so each vault gets its own Web API instance: its own IIS application, folder, application pool, SQL login and signing key. Instances share the web server, its HTTPS site and its certificate, and nothing else.

What the signing key is

The Web API gives the vault application a login token and checks it on every call. Each instance signs its tokens with its own key, the JwtSigningKey setting in that instance’s web.config. Because the keys differ, a token issued by one instance is refused by every other instance.

  • The install scripts generate the key: 256 random bits, written to that instance’s web.config and nowhere else.

  • Nobody types the key, and it does not go into the password vault.

  • Never copy a key from one instance to another, or from one server to another.

  • Without a usable key, the Web API refuses every login with HTTP 503.

Where the key is written

The key is written by the web.config stage of .\Install.ps1 -Instance <Key>, together with the instance’s own connection string and the shared API username and password.

  1. The Deploy stage ([4/6]) puts the instance in place. Its application pool stays stopped, and does not start with IIS, because the package’s web.config still holds shipped default values.

  2. The web.config stage ([5/6]) applies three edits, which the plan listed before you confirmed:

    • the connection string, using the instance’s own SQL login;

    • the shared API username and password used by the vault;

    • the signing key (Edit 3), which is reported as added, replaced or kept, without ever showing it.

    .\Install.ps1 -Instance <Key>
    

    The stage tests the connection before it writes anything, backs web.config up, and then starts this instance’s pool. It reports JwtSigningKey present, 256 bits or more.

  3. The Endpoint test stage ([6/6]) tests the endpoint. Check 6/8 confirms a login token is issued. Check 8/8 confirms that a token from this instance is refused by every other instance on the server (Refused (HTTP 401)). After adding a second or later instance, run .\Run-Step.ps1 8 -Instance <Key> for each existing instance as well, so isolation is checked in both directions.

Running the install again

A usable key already in web.config is kept, so running .\Install.ps1 -Instance <Key> again (for example to change a password) does not log the vault out. To replace the key on purpose, run .\Run-Step.ps1 7 -Instance <Key> -Apply -RotateSigningKey; the vault application then logs in again on its next call.

A reinstall with .\Run-Step.ps1 6 -Instance <Key> -Apply -PreserveWebConfig keeps web.config and its key. A reinstall that takes the package’s web.config writes a new key when the web.config stage runs again.

Checking an installation

.\Run-Step.ps1 validate reports a missing or short key as a failure and points to the web.config stage.