App identity
Ghost checks that every app it installs or opens is the one it says it is. This page explains how, and what that means for your keys. The app SDK does the signing and answering for you, and Deployment has the steps to use your keys on a host.
Why Ghost checks
Anyone can put any App ID in a manifest, so the ID names an app without proving who made it. A domain can also change hands, or a copy of your manifest can turn up on someone else’s server. So Ghost doesn’t trust an app for its ID or its address. It trusts a key only you hold:
- When a site installs your app, Ghost remembers your app’s identity key, and accepts updates to the app only when they’re signed with it
- Each time someone opens the app, Ghost checks that the server at the app’s address holds your app’s backend key
The author’s name in the manifest is still unverified, so Ghost Admin shows it as from an unverified developer.
The two keys
Each key has a private half you keep secret and a public half your manifest names.
| Key | What it proves | Where it lives |
|---|---|---|
| Identity key | That a manifest comes from you. It signs your manifest. | Away from your app’s server: On your computer in .ghost-app/, with a backup in a password manager, or in a CI job’s secrets when CI builds your app |
| Backend key | That a server is yours. It answers Ghost’s challenge. | Your app’s server: the host’s secret settings, as GHOST_APP_BACKEND_KEY, or .dev.vars on your computer |
Keep both private keys out of your page, your app’s build output, and Git. The public halves belong in the signed manifest. The identity key never goes to your app’s server either, since only the signed manifest is served. The SDK keeps keys in .ghost-app/, and only creates them where Git ignores that folder.
The signed manifest
You write your manifest as ghost-app.json. Signing adds four fields and signs the result with your identity key:
manifest_url: The address the signed manifest is served fromidentity_keyandbackend_key: The public halves of your two keysdevelopment: Whether it’s signed with your development keys, which Ghost Admin labels
Ghost refuses a manifest whose manifest_url isn’t the address it was asked to fetch, so a copy served somewhere else can’t pass as your app. Each address needs its own signed manifest. The SDK’s Vite plugin signs for your app’s local address and tunnel in vite dev, and for GHOST_APP_URL in vite build (see Manifest).
The challenge
Before showing an install link’s app, and each time someone opens an installed app, Ghost posts a challenge to /.well-known/ghost-app/challenge at the app’s address. Your server signs it with the backend key, and Ghost checks the answer against the backend_key in the manifest. handleChallenge() from @tryghost/app-sdk/backend does this.
- The challenge names the address Ghost sent it to, and
handleChallenge()refuses one for any other address. Pass it the request as your server receives it. - Ghost doesn’t follow a redirect for the challenge, so answer it at the manifest’s own address
Ghost skips the challenge in two cases. The signature, the pinned identity key, and approvals still apply:
- Ghost running in development: For apps on the same computer, such as
http://hello-world.localhost:8787. An app needs a name of its own under.localhost: Ghost refuses one on its own host,localhost, on any port, since browsers send Ghost’s cookies to every port - A site you host yourself: For the addresses listed in
apps.trustedOriginsin Ghost’s config, such as"apps": { "trustedOrigins": ["https://your-app.example.com"] }. Ghost Admin then says the app is trusted by the site’s configuration, rather than verified.
Every other site needs your server to answer, so every deployed app has a backend, even one that only serves a page.
Development and production keys
Your app has two sets of keys. vite dev creates the development keys the first time it runs, in .ghost-app/development/. You create the production keys yourself, once, in .ghost-app/production/ (see Your app’s production keys).
A site pins the identity key it installed your app with, and has one installation per App ID. So the app on your computer and your deployed app are different apps to Ghost, even with the same App ID: Ghost refuses the deployed one while the one from your computer is installed. To go from your computer to a host, uninstall the app in Ghost Admin, then install it again from the deployed app’s link. The new installation starts with its own history, and Ghost keeps the old one as a record.
What changes need approval
Ghost reads your manifest each time someone opens your app, and compares it with the version the site approved:
- A new backend key applies right away: The identity key vouches for it, so replacing a leaked one doesn’t need each site’s approval
- A new address needs approval: Moving your app to a new
manifest_urlkeeps it the same app, with its history, once someone on the site approves the move - A new identity key is refused: It’s a different app, so the site uninstalls the old one and installs it again
The rest of the manifest follows the same rules as any change (see Changing it).
Replacing the backend key
When a site reads a manifest with a new backend key, Ghost retires the key it replaced, for good. A site keeps retired keys per App ID and identity key, across every installation of your app it has had, uninstalled ones included. It refuses any manifest signed with that identity key that names a retired backend key, even after an uninstall and a new install. Your development and production keys are separate pairs, so retiring one never affects the other. So:
- A leaked backend key stops working on each site the next time someone opens your app there
- Rolling back to an older deployment keeps working, unless it goes back past a new backend key
- People who share a development identity key must share its backend key too. Otherwise each one’s manifest retires the other’s key.
To replace it, follow Replacing or losing keys. Between storing the new key on your server and deploying the manifest that names it, Ghost can’t confirm your app, so deploy straight away.
Losing or leaking a key
- Backend key leaked or lost: Replace it, as above. Sites switch without anyone approving it.
- Identity key lost: Restore your backup of
.ghost-app/production/. Without a backup, there’s no way to sign an update sites accept, so it’s the same as a leak. - Identity key leaked: Whoever has it can sign manifests that sites accept as yours, such as a move to an address they control, which a publisher might approve. Create new production keys and deploy, then ask every site to uninstall your app and install it again from its link.
Ghost has no way to move an installation to a new identity key, so keep a backup of the production keys somewhere safe outside your app’s folder.
Error codes
When Ghost refuses an app over its identity, Ghost Admin says why. The code is in the response to the failed request in your browser’s developer tools, under Network. Troubleshooting has the fix for each one.
| Code | What it means |
|---|---|
APP_MANIFEST_UNSIGNED |
The app serves its manifest unsigned. |
APP_MANIFEST_URL_MISMATCH |
The manifest is signed for another address than the one Ghost fetched. |
APP_MANIFEST_SIGNATURE_INVALID |
The signature wasn’t made with the identity key the manifest names. |
APP_IDENTITY_MISMATCH |
The manifest is signed with another identity key than the one the site installed the app with. Only a site reports it. |
APP_BACKEND_KEY_RETIRED |
The manifest names a backend key a newer manifest replaced. Only a site reports it. |
APP_CHALLENGE_FAILED |
The app’s server answered the challenge, but not with the manifest’s backend key. |
APP_CHALLENGE_UNREACHABLE |
Ghost couldn’t reach the challenge address, or got an error from it. |