Skip to content

feat: add license handshake and header injection#681

Merged
orius123 merged 7 commits intomainfrom
feat/license-header
Feb 11, 2026
Merged

feat: add license handshake and header injection#681
orius123 merged 7 commits intomainfrom
feat/license-header

Conversation

@orius123
Copy link
Member

@orius123 orius123 commented Feb 11, 2026

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/license endpoint and injects it as an x-descope-license header on all subsequent requests.

Key Features:

  • Automatic handshake with 5-second timeout during client initialization
  • Graceful failure - logs error and continues without header if handshake fails
  • License type validation - rejects empty responses
  • Comprehensive test coverage (8 test cases)

Changes:

  • Added FetchLicense() and SetLicenseType() methods to API client
  • Modified addDescopeHeaders() to inject x-descope-license header when set
  • Added mgmt/license endpoint
  • Added license handshake in NewWithConfig() when management key is present

Behavior:

  • ✅ Fetches license on initialization when management key is present
  • ✅ Times out after 5 seconds to prevent blocking
  • ✅ Validates response is not empty
  • ✅ Falls back gracefully on error (logs and continues)
  • ✅ Header automatically added to all requests when license type is set

Must

  • Tests
  • Documentation (code comments and inline docs)

- 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
Copilot AI review requested due to automatic review settings February 11, 2026 11:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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() and SetLicenseType() methods added to the API client
  • The x-descope-license header 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
@orius123 orius123 force-pushed the feat/license-header branch from e029d65 to 80d62e8 Compare February 11, 2026 11:56
- Fix linter warning about unused parameters in test mocks
@orius123 orius123 requested a review from aviadl February 11, 2026 13:39
@orius123 orius123 enabled auto-merge (squash) February 11, 2026 13:39
@orius123 orius123 merged commit 1e5c653 into main Feb 11, 2026
13 checks passed
@orius123 orius123 deleted the feat/license-header branch February 11, 2026 14:51
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