- Notifications
You must be signed in to change notification settings - Fork1.1k
feat(enterprise): add license auto-import from file on server startup#20939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
ausbru87 wants to merge11 commits intomainChoose a base branch fromfeature/license-auto-import
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Implements automatic license import from a file during server startup,addressing the need for automated license deployment in Helm/Kubernetesenvironments without requiring admin API tokens.**Backend Changes:**- Add `LicenseFile` configuration option to deployment settings- Implement `ImportLicenseFromFile()` function in enterprise/coderd/licenses.go- Integrate license import into server startup flow in enterprise/cli/server.go- Use system context with wildcard RBAC permissions for startup operations**Helm Chart Changes:**- Add license secret configuration to values.yaml- Mount license secret as volume in pod- Set CODER_LICENSE_FILE environment variable when secret is configured**Key Features:**- Idempotent: only imports when no licenses exist- Validates license JWT signature and deployment ID restrictions- Proper error handling and logging- Works with CLI flag, environment variable, or Helm secrets- No authentication required (runs during server startup)Resolves:#20259🤖 Generated with [Claude Code](https://claude.com/claude-code)Co-Authored-By: Claude <noreply@anthropic.com>
…se importReplace wildcard permissions with least-privilege approach:- Only grant ActionCreate and ActionRead on ResourceLicense- Removes unnecessary access to all other resources- Follows principle of least privilege- Reduces attack surface if code is refactoredThe license import operation only needs to:1. Read existing licenses (ActionRead)2. Create new license (ActionCreate)No other permissions are required, so wildcard was unnecessarily broad.
…or license import"This reverts commit53a659f.
…se importReplace wildcard permissions with least-privilege approach:- Only grant ActionCreate and ActionRead on ResourceLicense- Removes unnecessary access to all other resources- Follows principle of least privilegeThe license import operation only needs to:1. Read existing licenses (ActionRead on License)2. Create new license (ActionCreate on License)
Add 12 test cases covering:- Successful license import on first startup- Idempotency (skips re-import when licenses exist)- Empty file path handling- Missing file handling (file doesn't exist)- Empty file content- Whitespace-only file content- Invalid license JWT format- Deployment ID restrictions (both mismatch and match)- Expired license handling- License UUID preservation- Skipping import when licenses already exist in databaseTests validate proper error handling, file I/O, license validation,and idempotent behavior. All tests use proper parallel executionand follow existing codebase patterns.
- Fix gocritic lint error by renaming license_uuid to license_uuid_id- Fix helm template nil pointer by adding existence check for coder.license values
Expired licenses are properly rejected by the license parser as they failvalidation. Updated the test to expect an error and verify no license isimported, which is the correct behavior.
Changed from 'and' conditionals to 'with' statements to safely handleoptional nested values. This prevents nil pointer errors when thecoder.license object doesn't exist in values, while still properlyhandling the license configuration when it is provided.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements automatic license import from a file during server startup, addressing the need for automated license deployment in Helm/Kubernetes environments without requiring admin API tokens.
Backend Changes:
LicenseFileconfiguration option to deployment settingsImportLicenseFromFile()function in enterprise/coderd/licenses.goHelm Chart Changes:
Key Features:
Resolves:#20259