Skip to content

Reference

Constants

Set in wp-config.php. Secrets never go anywhere else.

Constant Purpose
OG_KEYSTONE_RUN_AS standalone, server or connector.
OG_KEYSTONE_ENC_KEY Recovery encryption key for licence keys and stored secrets.
OG_KEYSTONE_HASH_SECRET Keyed hash for licence key lookup.
OG_KEYSTONE_SIGNING_SECRET, OG_KEYSTONE_SIGNING_PUBLIC Ed25519 key pair for signed answers.
OG_KEYSTONE_DOWNLOAD_SECRET Secret for signed download links.
OG_KEYSTONE_RELEASES_DIR Release files folder, outside the web root.
OG_KEYSTONE_S3_KEY, OG_KEYSTONE_S3_SECRET S3-compatible storage credentials.
OG_KEYSTONE_S3_ALLOW_HTTP Allow a plain-http storage endpoint (testing only).
OG_KEYSTONE_SERVER_URL, OG_KEYSTONE_CONNECTOR_KEY, OG_KEYSTONE_CONNECTOR_SECRET Connector-mode credentials.
OG_KEYSTONE_CONNECTOR_ALLOW_HTTP Allow an http licence server (testing only).
OG_KEYSTONE_RATE_LIMIT_ALLOW Addresses exempt from public rate limits (your own servers).

The OG plugin licence bridge also reads OG_KEYSTONE_BRIDGE_PRODUCT, OG_KEYSTONE_BRIDGE_FILTER and OG_KEYSTONE_BRIDGE_DEFAULT; these belong to plugin authors.

Filters

Filter Purpose
ogk_docs_url URL shown as "Documentation" in the key email.
ogk_user_can_access Override the answer to an access check.
ogk_restricted_message Text shown in place of restricted content.
ogk_download_url Change a download link.
ogk_contact_url Contact link in the "Licence not accepted" pop-up.
og_keystone_tier Adjust a tier read by the plugin.
og_keystone_max_upload_bytes Largest upload from the Downloads screen.
og_keystone_subscription_grace_hours Hours before a late renewal counts as past due.
ogk_subscription_cancel_at_period_end Cancel at period end instead of at once.
og_keystone_remove_data_on_uninstall Return true to delete all data on uninstall.

Functions and shortcodes

  • ogk_user_can_access( $target_type, $target ) returns true when the current user may have the target.
  • [ogk_account] renders the portal. [ogk_restricted target_type="page" target="..."]...[/ogk_restricted] gates content.

REST API

Base URL: /wp-json/og-keystone/v1 on a WordPress site (the licence server serves the same routes under its own host). Answers use one envelope with data or an error carrying a code, a message and, for refusals, an OGK- reference.

Authentication. Public routes need no login. Admin routes need a signed-in administrator or the X-OGK-Api-Key header with an allowed address. Customer routes (/my/...) need the signed-in, email-confirmed customer and a REST nonce.

Public routes (licence checks)

Route Use
verify, status, details Check a key for a product and site.
activate, deactivate Use or free a site's place.
product-meta Public product information.
update-check Newest release and a signed link for a licensed, activated site.
download Fetch the file with a signed token.

Parameters include the licence key, product, site, the current version and a client nonce. Answers can be signed; verify the signature with the public key. Public routes are rate limited per address (10 to 30 a minute), and 10 unknown keys in 10 minutes lock an address out.

Admin and customer routes

Products, tiers, key generator rules, licences, releases, memberships and plans, restriction rules, credits, subscriptions, webhooks, settings, API keys, events and the dashboard each have list, create, update and delete routes with page and per_page paging. The /my routes read account, memberships, subscriptions, credits, access, licences, sites and downloads, and change the customer's own subscription and sites. The full contract is contract/openapi.yaml in the plugin folder.

Webhooks

Delivery. Each endpoint gets signed POST requests with these headers: Content-Type: application/json, User-Agent: OG-Keystone-Webhook/1, X-OGK-Event, X-OGK-Delivery, X-OGK-Timestamp and X-OGK-Signature (v1= plus the hex HMAC-SHA256). Targets must be https and public.

Checking a signature. The secret starts with whsec_ and is shown once.

X-OGK-Signature = "v1=" + hex( HMAC-SHA256( secret, X-OGK-Timestamp + "." + raw_body ) )
  1. Read the raw body bytes before any JSON parsing.
  2. Reject the delivery if X-OGK-Timestamp is more than 5 minutes from your clock.
  3. Compute the HMAC over timestamp + "." + raw_body with your secret.
  4. Compare with the header using a constant-time comparison (hash_equals in PHP).
  5. Answer 2xx quickly and do slow work afterwards.

Events.

Object Events
product product.created, product.updated, product.deleted
tier tier.created, tier.updated, tier.deleted
generator_rule generator_rule.created, .updated, .deleted
licence licence.created, licence.updated, licence.status_changed, licence.deleted, licence.activated, licence.deactivated, licence.imported, licence.exported
release release.created, release.updated, release.deleted, release.downloaded
api_key api_key.created, api_key.revoked
settings settings.updated

Update server

  1. Put the release zip in the releases folder (or upload it on the Downloads screen).
  2. Register a version: number, changelog, file, minimum PHP and WordPress, Published.
  3. A site calls update-check with its key, product, site and current version.
  4. If the licence is usable and activated for that site and a newer published release exists, the answer carries a signed link valid for 5 minutes.
  5. The site fetches the file from download.

"Newest" is the published version with the highest number by PHP's version_compare (for example 1.2.3 or 1.2.3-beta.1).

Tiers and prices (OG Nexus store)

See Licences and tiers.