feat: add license handshake and header injection#681
Merged
Conversation
- Add licenseType field to Client struct - Add FetchLicense() method to fetch license from management API - Add SetLicenseType() method to set license type - Inject x-descope-license header on management API requests - Perform handshake on client init when management key is present - Gracefully handle handshake failure (log warning, continue without header)
- Add 5 second timeout to license fetch to prevent indefinite blocking - Validate license response is not empty before setting - Gracefully handles timeout and empty response errors
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic license handshaking functionality to the SDK client initialization process. When a management key is configured, the client fetches the license type from a new endpoint and injects it as a header on all subsequent requests.
Changes:
- License handshake is automatically performed during client initialization with a 5-second timeout
- New
FetchLicense()andSetLicenseType()methods added to the API client - The
x-descope-licenseheader is injected on all requests when license type is set
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| descope/client/client.go | Adds license handshake logic during client initialization when management key is present |
| descope/api/client.go | Implements license fetching, storage, and header injection functionality |
| descope/api/client_test.go | Adds comprehensive test coverage for license handshake and header injection (8 test cases) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
orius123
added a commit
that referenced
this pull request
Feb 11, 2026
- Add sync.RWMutex to protect licenseType field from race conditions - Use RLock in addDescopeHeaders for concurrent reads - Use Lock in SetLicenseType for writes - Rename variable 'license' to 'licenseType' for clarity Addresses code review feedback from PR #681
- Rename variable 'license' to 'licenseType' for clarity Addresses code review feedback from PR #681
e029d65 to
80d62e8
Compare
- Fix linter warning about unused parameters in test mocks
aviadl
approved these changes
Feb 11, 2026
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
Sign up for free
to 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.
Fixes https://github.com/descope/etc/issues/13206
Description
Adds automatic license handshake during SDK client initialization. When a management key is configured, the SDK fetches the license type (free/pro/enterprise) from the
mgmt/licenseendpoint and injects it as anx-descope-licenseheader on all subsequent requests.Key Features:
Changes:
FetchLicense()andSetLicenseType()methods to API clientaddDescopeHeaders()to injectx-descope-licenseheader when setmgmt/licenseendpointNewWithConfig()when management key is presentBehavior:
Must