Skip to content

Scopes, API tokens, OAuth, and MCP

See the scope reference for every permission, its description, supported restrictions, and token delegation.

Programmatic access should be easier to revoke and narrower than a human administrator session. The automation owner defines the required workflow, the resource owner approves its reach, and the security owner reviews credential lifetime and storage. Success means the integration can perform its intended action, is denied elsewhere, and can be rotated without interrupting unrelated systems.

Users manage API tokens under Profile > Authorizations > API Tokens. Secrets are shown once. Store them in a secret manager, assign the minimum scopes, and revoke unused tokens.

OAuth clients delegate user authority with explicit redirect URIs and consent. Remote MCP uses the same resource and scope model as REST and the Console; it is not a privileged back door.

Use separate credentials for CI, monitoring, and interactive tools. Avoid long-lived administrator tokens. Resource-scope automation to the exact nodes, Routes, workloads, databases, or Pages Projects it owns.

Regular opf_ API credentials and opfo_ OAuth credentials do not enter the Opfield Inference data plane. Inference uses dedicated opfi_ user tokens.

Audit token creation, use, and revocation. Rotate immediately after suspected disclosure and verify active sessions separately.

Credential Prefix Use
Session — Interactive Operations Console access
API token opf_ Direct automation owned by one Opfield user
OAuth client opfo_ access token, opfr_ refresh token Delegated user authorization and third-party applications
Remote MCP OAuth opfo_ Tool clients that act through Opfield’s MCP surface
Inference token opfi_ Requests to the separate Opfield Inference data plane
Logging ingest token opfl_ Write-only structured log ingestion
Pages deploy token opfp_ Deployments of one Pages Project

Tokens issued before 2.12.1 start with gw_, gwo_, gwr_, gwi_, gwl_, or gwp_ and keep working until they are revoked or expire.

Do not substitute one type for another merely because it is easier to copy. Credential type determines consent, revocation, scope evaluation, audit purpose, and the endpoint family it can access.

  1. Identify the exact operations and resources the automation owns.
  2. Create a dedicated user or service identity when attribution should be separate.
  3. Assign the minimum global and resource scopes.
  4. Create the token and capture the secret once.
  5. Store it in a secret manager and inject it at runtime.
  6. Test one allowed request and one denied request.
  7. Record the owner, purpose, expiry/rotation expectation, and dependent system.

Avoid embedding tokens in repository URLs, command history, screenshots, or logs. A masked UI value cannot be recovered later; create a replacement and revoke the old token when the secret is lost.

API tokens and OAuth grants for the Opfield API or MCP can hold every permission scope except a short user-only list: the AI Workspace and AI sandbox scopes (ai:workspace:use, feat:ai:configure, ai:skills:manage, and ai:sandbox:*), mcp:use, admin:users:impersonate, and integrations:gitlab:sandbox:clone. Programmatic access can therefore manage Nodes and their configuration, users and groups, Opfield settings, integration and hosting connectors, hosting VMs, Relay operations, updates, inference administration, the owner’s personal opfi_ inference keys, and access list service tokens. Every delegated scope stays bounded by the owner’s current permissions.

Some actions stay tied to an interactive browser session:

  • creating API tokens and OAuth authorizations, and OAuth consent itself;
  • AI Workspace chat and AI sandboxes;
  • starting impersonation;
  • signing in, and changing the owner’s own sign-in methods, MFA, passkeys, or sessions; a token that tries returns SELF_SIGN_IN_PROGRAMMATIC;
  • managing personal GitLab credentials.

Because tokens can now hold administrative scopes, treat an administrator-scoped token like an administrator account: give it an owner, an expiry, and a narrow resource scope where possible.

Opfield 2.11 renamed several scopes. Token creation, OAuth scope parameters, and OAuth authorization edits still accept the old names for two releases and store the new ones; existing tokens and grants were converted during the update. A new token or OAuth request for a scope such as integrations:github:manage also receives the scopes that the update added for it (here repo:read) when you hold them; the consent screen shows them and you can untick them. Scopes that need manual approval, such as repo:write or pki:ca:export, are never added this way. See Retired scope names.

A token or OAuth grant can be limited to folders, Nodes, app environments, or individual resources in the same way as a user’s permissions. A folder restriction covers the folder, its subfolders, and resources created in or moved into it later. See Restrict access to a folder.

  • API tokens: the token dialog in Profile > Authorizations > API Tokens shows the token’s access as a list. Add Access adds a line. On Resources, choose a Role, Where it applies (Everywhere, In a project folder, In an app environment, or Specific resources), and what it Covers; on Git repositories, choose a connector, the repositories, and the access level. The dialog offers only what you can grant yourself.
  • Scope picker: Review N scopes at the bottom of the token dialog and of the OAuth and MCP consent screen opens the scopes themselves. Each section header shows where the section’s scopes reach: Everywhere, one place, or N places. Click it to pick from the folders, apps, and environments that hold that kind of resource. The scopes of a section follow it; Only this scope… gives one scope its own restriction. A scope you hold only for some resources shows No resources selected until you choose them.
  • OAuth and MCP consent: the consent screen shows what the client asks for as access lines. High-risk scopes stay out of the grant until you approve them under Review N scopes. To change the scopes and restrictions of an existing authorization later, open it under Profile > Authorizations > OAuth Applications, edit Scopes, and click Save Scopes.
  • Git integrations: the scope picker restricts Git scopes to a connector, a GitLab group or project, or a GitHub owner or repository, with Add groups or projects… or Add owners or repositories… under each connector. Such a token is checked against its own restriction and against your current Git access on every repository operation, so it stops reaching a repository as soon as you lose access to it. See Git integration restrictions.

Opfield expands a token’s own folder and Node restrictions first and then limits the result by your current access, so a token never sees more than you do. A creation grant never counts as a view grant when you delegate it. If a client requests a broad scope that you hold only for some resources, Opfield narrows the grant to those resources.

API tokens, inference tokens, and OAuth grants take an optional expiry and a list of allowed addresses, checked on every request:

  • Expires offers presets from 15 minutes to 1 year, Never, or a custom date. An expired token is refused like a revoked one, and the Expired Tokens housekeeping category removes it after a configurable period, 7 days by default.
  • Allowed Addresses takes up to 20 IP addresses or CIDR ranges. Opfield compares them with the client address it resolves through its trusted proxies; see Client address.

An API token also carries its own internal registry access: none, pull, or pull and push, each for every repository or for listed repository names. Every repository needs the owner’s broad workload or image scope; a listed repository needs view (pull) or edit or manage (push) on a workload that builds into or runs from it. Every docker login checks this again against the owner’s current permissions.

Register exact redirect URIs and reject wildcard redirect behavior. Review requested scopes during consent and separate development clients from production clients. Consent leaves high-risk scopes unchecked by default so that they must be selected explicitly—for example admin:system, admin:users, admin:groups, settings:opfield:edit, nodes:manage, proxy:raw:write, proxy:unrestricted, proxy:templates:manage, pki:ca:export, connector system credentials (integrations:*:use), integrations:ssh:use, paid or destructive hosting actions, storage:credentials:reveal, storage:iam, databases:backups:restore, and feat:ai:use. Remote MCP tools use the same authorization checks and resource visibility as REST and the Console; tool discovery does not grant permission to execute a tool.

Handle authorization failures distinctly:

  • 401: missing, expired, or invalid authentication;
  • 403: authenticated identity lacks the required scope or entitlement;
  • 409: current resource state or quota conflicts with the operation;
  • 422: request validation failed.

Expired OAuth authorization codes and tokens, and OAuth clients that have had no grant for 90 days, are removed by the Expired OAuth Grants housekeeping category; a refresh token is kept until it expires so that its reuse is still detected. See Housekeeping and retention.

Create the replacement, update the dependent system, verify successful use, and then revoke the old credential. After suspected disclosure, revoke first when operationally safe, inspect audit activity, invalidate related sessions separately, and rotate any downstream secret that may have been exposed.

Start from the operation, not from a role name. List the exact read and mutation calls the integration needs, then bind resource scopes to the smallest stable ownership boundary: a Folder, Node, Route, workload, database, or Pages Project. Add a global scope only when the workflow genuinely crosses all resources of that type. Separate view, reveal, export, console, mount, secret, and lifecycle permissions; ordinary read access must not imply access to credentials or host-sensitive operations.

Every credential needs a human owner, a machine consumer, a purpose, an environment, and a removal condition. A token used by CI should not also be used for an operator’s terminal session. Production and non-production OAuth clients should have different client IDs, redirect URIs, secrets, and consent records. When ownership changes, transfer or replace the credential rather than leaving it attached to a departed user’s account.

Before enabling automation in production:

  1. call a harmless read endpoint with the new credential;
  2. perform one intended mutation against a disposable resource;
  3. prove an out-of-scope resource is hidden or denied;
  4. confirm audit attribution identifies the expected user or OAuth client;
  5. verify token values, authorization headers, and callback parameters are redacted from logs;
  6. revoke the credential and prove the consumer fails closed;
  7. install the replacement and document the tested rotation order.

Revoking an API token does not automatically terminate browser sessions, OAuth grants, inference tokens, or credentials stored in external providers. During an incident, inventory each credential family separately.