What a key can and cannot protect here
An open-core project publishes a free core and sells extras: enterprise features, a hosted version, plugins, support. The question is how a buyer’s key turns the extras on.
If the extras are in the same public repository, behind an if (licensed) check, the paid tier is only as protected as the repository is closed, which is not at all. Anyone can read the check, patch it, build their own copy and share it. That is the nature of open source, and the license you chose says it is allowed.
So the check is not the moat. A key can still protect four things:
| What the key gates | How it works | Survives a fork? |
|---|---|---|
| A separate paid artifact | A binary, plugin or module delivered only to valid keys | Yes, the fork lacks the code |
| Updates and release notes | The release endpoint gives download links to valid keys | Yes |
| A hosted service or API | Your server checks the key before serving | Yes |
| Support and contracts | Who you answer | Yes |
| A feature flag in public code | An if around public code |
No |
Only the last row fails, and it is the quickest one to build, which is why it is tempting.
Ship the paid tier as its own artifact
The sturdiest design splits the code:
- The core is public and complete. It has an extension point, such as a plugin interface or a module loader.
- The paid module is a separate build, kept in a private repository, released as a file: a binary, a JAR, a wheel, a container image archive or a plugin ZIP.
- Clavem hosts the paid module’s release files. A valid key gets a signed download link, which lasts an hour, from
GET /v1/releases/:productId/latestwith the key in theX-License-Keyheader. A missing, expired or disabled key sees only that a version exists. Files can be up to 5 GiB each and carry platform labels such aslinux-amd64. - The core loads the module if it is present, and the module verifies a signed token at startup.
A fork of the core without the module gets the free tier. A user with the module and no valid key gets nothing new. The paid code never ships in the public repository, so nothing there can be patched to enable it.
The paid module may itself be closed source. If it links into a copyleft core, the combined work has legal consequences. Choose the core’s license and the way the module attaches with a lawyer, not on the basis of this page. See source-available and dual licensing for the vocabulary, and the open-core licensing article for the options.
Verify a signed token in open code
Putting the verification code in the public core is fine. A Clavem token is a payload signed with the product’s Ed25519 private key, which only Clavem holds, and verified with a public key that is not secret. Your open code can contain the public key, the checks of pid, valid, exp and refresh_by, and the module loader. A fork cannot create a valid token, though it can accept any token, which is why the paid module matters.
Keep the verification small and well tested. Open-source contributors will read it, and a clear implementation builds trust with buyers who audit what a license check does. The offline page lists the exact steps.
Design for buyers who read the source
- Transparency. Say what the key turns on and what the license check sends: the key, a device name and a fingerprint. Anyone can read the code, so the documentation should match it.
- No lock-in. Document how a customer exports their data and runs the core without the paid module.
- Sensible offline behavior. A server install will not always reach Clavem. Trust the token until
refresh_by, then warn, and never block access to data. See self-hosted software. - A free tier that is real. If the free core is crippled, contributors leave and buyers doubt the project.
Pricing models that fit
| Model | What you sell | Clavem setup |
|---|---|---|
| Per install, per year | The paid module for one server | Device limit counts installs |
| Per seat | The module for a team of users | Quantity at checkout; one key per seat |
| Support contract with a module | Response times plus the build | Subscription validity |
| Hosted version | The service itself | Your server checks the key |
A license can follow a Stripe subscription: it expires at the end of the paid period plus three days of grace, and returns when the renewal is paid.
Recommended setup
| Setting | Suggested value | Why |
|---|---|---|
| License type | Annual subscription for the module and support | Ongoing development has ongoing cost |
| Device limit | 2 or 3 installs | Production, staging and a spare |
| Trial | A trial key with a short fixed validity, or a free community tier | Lets buyers try the paid module |
| Updates | Releases endpoint, module delivered only to valid keys | The gate that survives a fork |
Doing this with Clavem
Create a product for the paid module, connect Stripe, map the price, and upload the module as a release. Buyers get a key by email and an order page that lists the download. Your module activates at startup and validates daily. Follow the guide for your language: Go, Java, Python or Node.js.
Guides to follow
Questions
Can a license key stop someone forking my open-source core and removing the check?
No. If the check is in code that anyone can read and rebuild, anyone can remove it. A key helps when the paid code is not in the public repository and is delivered only to valid keys, or when the value is a service you run.
Is it a problem to put the signature check and public key in open-source code?
No. The public key and the verification code are meant to be public. The signature can only be made with the private key that Clavem holds, so a copy of your code cannot forge a valid token.