Skip to content

Add env override for Add/Manage License button#27779

Open
AlexGaillard wants to merge 24 commits into
mainfrom
alexg/cms-2721
Open

Add env override for Add/Manage License button#27779
AlexGaillard wants to merge 24 commits into
mainfrom
alexg/cms-2721

Conversation

@AlexGaillard

@AlexGaillard AlexGaillard commented Jun 24, 2026

Copy link
Copy Markdown
Member

Scope

What's changed:

  • A new env override LICENSE_KEY_MANAGEMENT_ENABLED has been added with default true
  • Setting this to false will disable the "Add/Manage License" button on the license page
  • This will also disable management of the license via the api
  • This change required an update of the @directus/license package, which has already been published with the change
  • Messaging for why management of license has been extended to account for both key in env and disallowed by env in both the "Manage License" button and the "Deactivate License" button

Potential Risks / Drawbacks

  • Changes to license manager cause some weird behavior

Tested Scenarios

  • Tested:

Manually tested across all these states and backed up by Claude

Before

  Post Patch Delete UI Disabled UI Message
source === null 204 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” false null
source === ‘env’ 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” true “Your license key is managed via an environment variable and can't be updated here.”
source === ‘settings’ 403 - "A license was already activated” 204 204 false null

After

  Post Patch Delete UI Disabled UI Message
source === null && LICENSE_KEY_MANAGEMENT_ENABLED === true 204 400 - "Invalid payload. A current license must be provided in order to update.” 400 - "Invalid payload. "key" has to be defined in order to deactivate.” false null
source === ‘env’ && LICENSE_KEY_MANAGEMENT_ENABLED === true 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” true “Your license key is managed via an environment variable and can't be updated here.”
source === ‘settings’ && LICENSE_KEY_MANAGEMENT_ENABLED === true 403 - "A license was already activated” 204 204 false null
source === null && LICENSE_KEY_MANAGEMENT_ENABLED === false 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” true “Management of your license key is disabled by your environment settings”
source === ‘env’ && LICENSE_KEY_MANAGEMENT_ENABLED === false 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” true “Your license key is managed via an environment variable and can't be updated here.”
source === ‘settings’ && LICENSE_KEY_MANAGEMENT_ENABLED === false 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” 403 - "You cannot manage license for the current license.” true “Management of your license key is disabled by your environment settings”

Review Notes / Questions

  • NA

Checklist

  • Added or updated tests
  • Documentation PR created here or not required
  • OpenAPI package PR created here or not required

Fixes cms-2721

@linear-code

linear-code Bot commented Jun 24, 2026

Copy link
Copy Markdown

CMS-2721

Comment thread api/src/services/server.ts Outdated
@AlexGaillard AlexGaillard marked this pull request as ready for review June 26, 2026 18:11

@ComfortablyCoding ComfortablyCoding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

First pass review

  • Are there any E2E tests I should update? New ones should be added to back this behavior.
  • Should we document this? Yes

Comment thread .changeset/six-pears-shave.md Outdated
Comment thread api/src/license/manager.ts
Comment thread api/src/license/manager.ts Outdated
Comment thread app/src/modules/settings/routes/license/license.vue Outdated
: getDirectusUrlWithUtm(DIRECTUS_PRICING_URL, serverStore.info.version, 'settings_license_upgrade_plan_link'),
);

const manageLicenseDisabledMessage = computed(() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any context for showing env managed if general management is off?

I would expect messaging should depend on whether management is enabled. If management is disabled, we should show that license management is not allowed. If management is enabled but the source is env, then we can show the env message.

As a side note, this also does not show the env manage message if license is enabled but source is env

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There wasn't originally, but now with how the editable is worked out on the backend it makes sense to show them this way otherwise when the edit is restricted purely by the env license, the frontend can't tell and will show “Management of your license key is disabled by your environment settings”

@ComfortablyCoding ComfortablyCoding Jun 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see no issue showing "Management of your license key is disabled by your environment settings” irrespective of license source or existing license?

const { info: license, addons, loading, boundary, isLicensed } = storeToRefs(licenseStore);

const isEnvManaged = computed(() => license.value?.source === 'env');
const isLicenseManageLinkEnabled = computed(() => licenseStore.info?.editable);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's rename this inline with any rename to the env var for clarity

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

renamed to isLicenseKeyManagementEnabled

@AlexGaillard AlexGaillard marked this pull request as draft June 30, 2026 19:28
@AlexGaillard AlexGaillard marked this pull request as ready for review June 30, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants