Security & Trusted Sources
Installing apps from unknown sources
Only install apps from sources you trust
Installing a Forge app grants it access to your project. Read this page before installing any app that was not built and distributed by a party you fully trust.
Think before approving permissions
When you install or update an app, you will be shown exactly what permissions it is requesting before you confirm. Only approve permissions you understand and trust the app to use responsibly.
An app can only do what you allow it to do — but within those permissions, it can act freely. An app with write or delete permissions can modify or remove data without asking for confirmation each time. An app with read permissions can access that data and, if malicious, send it elsewhere. Permissions granted to a trusted source are safe; the same permissions granted to an unknown source are a risk.
Who to trust
Official Protokol marketplace apps — apps published through the official marketplace are reviewed and the publisher's identity is verified before listing. These are safe to install.
Apps from known, trusted developers — if you know the author and can inspect or have reviewed the source, you can make an informed decision.
Apps from unknown sources — .tar.gz bundles, links shared externally, or apps from publishers you cannot verify. Only install these if you fully understand and trust the permissions they are requesting.
App runtime token
When a user launches a Forge app, the platform issues a short-lived JWT scoped to that specific app session. The permissions embedded in this token are computed as follows:
token_permissions =
(user_permissions ∩ runtime_permissions) -- what the user can do, limited to what the app declared
∪ (entitlements ∩ available_permissions) -- unconditional app-level permissions from the manifest
∪ (grants ∩ available_permissions) -- additional permissions approved by an administrator
runtime_permissions (manifest-declared, user-intersected)
The app declares which permissions it wants at runtime in ptkl.config.js. At launch time, the platform computes the intersection of those declared permissions with the launching user's actual permissions. The app can never receive a permission the current user does not hold.
entitlements (manifest-declared, unconditional)
Entitlements are also declared in ptkl.config.js. Unlike runtime_permissions, they are merged into the token unconditionally — the launching user does not need to hold them. Use entitlements for service-level capabilities the app always needs regardless of who is running it.
Use entitlements carefully
Any user who can launch the app will cause the app to receive its entitlements. Only declare permissions as entitlements if every user of the app should allow the app to hold them.
grants (administrator-managed, unconditional)
Grants are additional permissions that a platform administrator has explicitly approved for a specific installation of the app on a specific tenant. Like entitlements, grants bypass the user-intersection step. They are managed through the app's Edit page and are stored per-installation, not in the manifest.
All unconditional permissions are bounded
Both entitlements and grants are filtered against the set of permissions that actually exist on the platform. A permission that has not been registered by any deployed app cannot appear in a token, even if declared as an entitlement or grant.
Self-scoped permissions
Most permissions are project-wide: manage forge lets its holder read and write every Forge
app's configuration in the project, not just its own. That makes it the wrong thing to grant an app
that only needs to manage itself.
A few permissions are instead self-scoped, and manage_variables forge is one. It is only
honoured on routes that take no app ref — the platform resolves the target from the calling app's
own token, so there is no way to point the permission at a different app. Granting it to an app
gives that app control over its own variables and nothing else.
The distinction is worth checking when you review what an app is asking for:
| Permission | Reaches |
|---|---|
manage_variables forge |
the app's own variables only |
manage forge |
every app in the project |
Reading an app's own variables needs no permission at all.
Reading permissions at runtime
Because a Forge app runs under the scoped app runtime token above, there are two distinct questions the SDK can answer — and they often have different answers:
| Question | SDK method | Returns |
|---|---|---|
| What can this app do right now? | users.getPermissions() |
The token's scoped permissions — the intersection described above. |
| What can the user behind the app do? | users.getPrincipalPermissions() |
The full permission set of the user the token is acting on behalf of. |
getPermissions() reflects the token: it never contains a permission the app was not granted. getPrincipalPermissions() resolves the underlying user (the "principal") and returns everything that user is allowed to do on the project — including permissions the app itself was not granted.
Use getPrincipalPermissions() when the app needs to reason about the user rather than itself — for example, conditionally revealing UI a privileged user would expect, or deciding whether it is worth prompting for more access with $forge.requestPermissions.
import { Users } from '@ptkl/sdk'
const users = new Users()
// What the app's token is scoped to
const { data: appScope } = await users.getPermissions()
// What the acting user is actually allowed to do
const { data: principal } = await users.getPrincipalPermissions()
if (principal.permissions.includes('refund orders')) {
// The user can refund — reveal the control even if the app's own
// token was not granted this permission.
showRefundButton()
}
Both methods return the same shape:
{
"is_admin": false,
"roles": ["<role-uuid>", "..."],
"permissions": ["read orders", "edit orders", "..."]
}
Knowledge, not capability
getPrincipalPermissions() tells the app what the user can do; it does not widen the app's token. To actually perform an action beyond the app's scope, request it explicitly with $forge.requestPermissions, which mints a new token after the user consents.
Approval and the app's identity
Installing or updating a marketplace app is the approval. You approve exactly the revision you reviewed, and the permissions it declares become what the app and the code it creates may do.
What you approve
The install and update screen lists everything the revision declares:
Reviewing revision {version}. Installing or updating approves exactly what is listed here.
| List | What it is |
|---|---|
| Install permissions | Used by the app's install scripts. |
| Runtime permissions | What the app and the code it creates may do while running. |
| Permissions | Permissions the app declares for itself; they are added to the runtime set. |
| Entitlements | Always granted to the app, whatever the current user holds. |
| Service, View | Held by that service or view of the app. |
| Self-service grants | Implicit grants for the app's own services. |
dev env_access is implied for every app and shown, even when the manifest doesn't declare it.
You can approve only if you cover the whole set. Covering a permission means holding it:
- The Owner covers everything.
- A Maintainer covers everything except
admin,maintainer, a pattern that matches either, and Kortex permissions it doesn't hold itself. - Anyone else covers exactly what they hold. A pattern is covered only by the identical pattern.
If you lack some, the screen marks each one "you lack this" and says:
You can't approve this yet. Approving needs every permission below, and you don't hold them. Ask the Owner or a Maintainer who holds them to do it, or have them granted to you:
The API refuses with 403 and names what is missing:
The installed revision keeps running. The fix: ask someone who covers the set to install or update, or have the missing permissions granted to you. Only a person approves: the app itself, its views and its scripts can never approve or grant permissions.
Changed while you review
An approval is bound to the revision you reviewed. If the app changes first, the install or update is refused with 409 revision_changed and the screen says:
The app changed while you were reviewing. Review revision {version} again before you continue.
Marketplace installs and updates always take the app's live revision.
Installs waiting for approval
Some installs run without you present: a template that includes the app, or a purchase. They carry the approval of the person who started them. If that person doesn't cover the revision, or the revision changed since, the install is held. Nothing runs, no scripts, credentials, services or views, until someone who covers the set approves it. The previous revision keeps running.
These installs wait until someone who holds every permission the revision declares approves them. Nothing has run yet.
A held install shows "Requested {requested}, live is {live}. Approving installs {live}." If you lack permissions: "You can't approve this: you lack the permissions listed. Ask someone who holds them." A template install result names the held apps and the permissions missing.
A marketplace installation with no approved revision runs and serves nothing. Opening it gives 409 installation_not_approved:
Nothing is approved to run in this environment, so the app cannot open. An Owner or a Maintainer approves a revision first, then open it again.
What an app's code runs with
Code a Forge app creates, functions, components and workflows, runs as the app's identity, prn:forge:<app-uuid>. That identity holds the app's approved permissions and nothing else. Approval is per installation: dev and live share the app's code and its approval. A narrower dev revision doesn't take away what live's approved revision declares.
No person holds the app's identity, so nobody changes that code by hand. Update the app instead. The one other path is the app's own pages: when the Owner or a Maintainer uses one, it may create and change the app's code as the app. A member's view and a public view cannot. See Run identity.
Approving an upgrade takes effect before its install script runs, so the script can call code it just installed. A failed upgrade keeps the approval you gave.
Apps installed before run identities
Code these apps created has no run identity and runs as Maintainer. The first update after the release moves it to the app's own identity, which holds only what the app declares. Only the Owner, or a Maintainer who holds that identity, can approve this update, because the move changes who the code runs as. If you can't, the update screen says so and blocks approval. Ask the Owner or a Maintainer to update.
Code whose identity someone set after the release keeps it.
Your project's own Forge apps
A project's own Forge app has no approval flow. Anyone with manage forge uploads versions and picks the version each environment runs. That is editing the app's code. Changing what the app may do is checked: if the version you pick, or an upload over the version in use, declares permissions the current one doesn't, you must hold every added one. The screen says:
This version adds permissions. Switching to it needs you to hold every permission it adds.
or "This version adds no permissions." Otherwise the change is refused with 403 naming the added and missing permissions, and nothing changes. A version with the same or fewer permissions needs only manage forge.
Inputs are untrusted
An app's views, services and scripts receive input from users and other systems. Treat all of it as untrusted. Code that lets an input choose where data goes, or skip a check, is a bug in that code. The app's identity limits what the bug can reach. It doesn't make the bug safe.
Whoever can change an app's code acts as the app and reads its secrets. See the security model.