Skip to content

feat: initial licensing enforcment impl#4348

Merged
markphelps merged 12 commits into
v2from
licensing
Jun 13, 2025
Merged

feat: initial licensing enforcment impl#4348
markphelps merged 12 commits into
v2from
licensing

Conversation

@markphelps

@markphelps markphelps commented Jun 11, 2025

Copy link
Copy Markdown
Collaborator

This pr adds initial license validation for Flipt v2 Enterprise Pro

It uses https://keygen.sh/ for the license validation

Ive got a server that im working on that integrates with stripe to manage license lifecycle and provision / deprovision licenses based on subscription payment from stripe

It does the following:

  1. checks for flipt.license.key from config on startup
  2. validates this license key using our accountID and productID (will be embedded at buildtime) with keygen
  3. creates a machine fingerprint to activate the license for the machine (only required for trial license/period where we limit to 5 machines)
  4. revalidates the license every 12 hours
  5. shows the product version in the ui at the footer (Open Source or Pro)
  6. hides any commercial features in UI if oss, but still does validation server side
  7. fallsback to OSS if license is invalid or missing

For development mode we just force enterprise version to make it simpler for us to develop commercial features.

TODO:

  • implement offline license validation (need to read up on how this is done with keygen) as not all flipt instances will have internet connectivitiy all the time. this will be done in a followup PR
  • Add to goreleaser build config
  • Set repo secrets for release

Notes:

  • The keygen accountID and productID are embedded as strings in this binary, however in order to actually make license changes via the API you'll need a product API key, which is what the backend license server uses and will not be exposed here

Base automatically changed from v2-scm-gitlab to v2 June 12, 2025 14:28
@markphelps
markphelps marked this pull request as ready for review June 12, 2025 18:39
@markphelps
markphelps requested a review from a team as a code owner June 12, 2025 18:39
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 12, 2025
@markphelps
markphelps requested review from Copilot and erka June 12, 2025 18:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds initial enterprise license enforcement for Flipt v2 by integrating Keygen-based license validation, embedding machine fingerprints, and propagating an enterprise/OSS “product” flag throughout the backend and UI.

  • Introduces EnterpriseConfig.LicenseKey, license manager (internal/enterprise/license), and CLI/build-time flags for license settings.
  • Extends the Flipt info API with a product field and custom JSON marshaling to differentiate OSS vs Enterprise.
  • Exposes the edition badge in the UI (Footer.tsx), restricts enterprise-only UI actions (e.g. branch merge), and updates tests for onboarding.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/config/config.go Adds EnterpriseConfig and LicenseKey to main config
internal/enterprise/license/license.go Implements Manager for license validation and periodic recheck
internal/info/flipt.go Adds Product enum, licenseManager, IsEnterprise(), and JSON marshaling
internal/info/flipt_test.go Tests JSON marshaling of product field based on license manager
cmd/flipt/main.go Wires up license manager on startup and injects into GRPC server
ui/src/types/Meta.ts Defines Product enum and adds product to IInfo
ui/src/app/meta/metaSlice.ts Loads product in Redux meta slice and selector isEnterprise
ui/src/components/Footer.tsx Renders edition badge dynamically based on info.product
ui/src/components/environments/...tsx Hides merge actions unless enterprise license is active
ui/tests/support.spec.ts Updates onboarding test expectations for new headings
Comments suppressed due to low confidence (1)

ui/src/components/Footer.tsx:58

  • Consider adding a UI test for the edition badge rendering in the Footer, verifying it shows 'Enterprise' or 'Open Source' based on info.product.
info?.product && (

Comment thread ui/tests/support.spec.ts
Comment thread ui/src/components/Footer.tsx Outdated

@erka erka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what has changed but now I can stop Flipt only with kill -9...

Comment thread ui/src/components/Footer.tsx Outdated
@markphelps

Copy link
Copy Markdown
Collaborator Author

I don't know what has changed but now I can stop Flipt only with kill -9...

Ugh it's probably due to the shutdown context change. I'll investigate. I was able to ctrl c kill it tho

Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
@markphelps

Copy link
Copy Markdown
Collaborator Author

I don't know what has changed but now I can stop Flipt only with kill -9...

Ugh it's probably due to the shutdown context change. I'll investigate. I was able to ctrl c kill it tho

Ok turns out there were two places where we were getting stuck on shutdown. They should both be fixed now

Signed-off-by: Mark Phelps <[email protected]>

@erka erka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that I think over and over if this should be called business. Enterprises usually have the closed system and usually without direct access to the Internet

@markphelps

markphelps commented Jun 13, 2025

Copy link
Copy Markdown
Collaborator Author

One thing that I think over and over if this should be called business. Enterprises usually have the closed system and usually without direct access to the Internet

what about 'Pro'? I do plan to add support for offline license validation. But Pro might be more fitting than Enterprise, until we add more enterprisey features

Signed-off-by: Mark Phelps <[email protected]>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 13, 2025
@markphelps
markphelps merged commit 692e566 into v2 Jun 13, 2025
17 of 18 checks passed
@markphelps
markphelps deleted the licensing branch June 13, 2025 16:20
@erka

erka commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

what about 'Pro'? I do plan to add support for offline license validation. But Pro might be more fitting than Enterprise, until we add more enterprises features

I suppose you're aiming for something in between. It's possible that some companies may prefer to sign a direct agreement, which could fall under an enterprise plan with custom features per that agreement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants