-
Notifications
You must be signed in to change notification settings - Fork 4
feat(auth): add auth management key support for disabled auth methods #283
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 support for an Auth Management Key feature to enable authentication API calls when public access has been disabled. The implementation follows existing patterns in the codebase for handling management keys.
Changes:
- Added new environment variable constant and getter for
DESCOPE_AUTH_MANAGEMENT_KEY - Extended
ConfigandClientclasses to support the newauthManagementKeyfield - Modified authentication API proxy creation to include the auth management key in Authorization headers when provided
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/descope/literals/AppConstants.java | Added AUTH_MANAGEMENT_KEY_ENV_VAR constant |
| src/main/java/com/descope/utils/EnvironmentUtils.java | Added getAuthManagementKey() method to retrieve from environment |
| src/main/java/com/descope/client/Config.java | Added authManagementKey field with initialization method |
| src/main/java/com/descope/model/client/Client.java | Added authManagementKey field to client model |
| src/main/java/com/descope/client/DescopeClient.java | Initialize and pass authManagementKey during client creation |
| src/main/java/com/descope/sdk/auth/impl/AuthenticationsBase.java | Modified getApiProxy methods to include authManagementKey in Authorization header |
Comments suppressed due to low confidence (1)
src/main/java/com/descope/client/Config.java:24
- The comment label 'PublicKey' is incorrect for the managementKey field. It should be labeled 'ManagementKey' to match the field name. This appears to be a pre-existing issue that should be corrected for consistency.
// PublicKey (optional, "") - used to provide a management key that's required
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| String authManagementKey = client.getAuthManagementKey(); | ||
| if (StringUtils.isNotBlank(projectId)) { | ||
| if (StringUtils.isNotBlank(authManagementKey)) { | ||
| return ApiProxyBuilder.buildProxy(() -> String.format("Bearer %s:%s", projectId, authManagementKey), client); | ||
| } |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new logic that includes authManagementKey in the Authorization header lacks test coverage. Similar authentication tests exist in AuthenticationServiceImplTest.java and other test files. Consider adding tests to verify the Authorization header format when authManagementKey is present and absent.
| String authManagementKey = client.getAuthManagementKey(); | ||
| String token; | ||
| if (StringUtils.isNotBlank(authManagementKey)) { | ||
| token = String.format("Bearer %s:%s:%s", projectId, refreshToken, authManagementKey); | ||
| } else { | ||
| token = String.format("Bearer %s:%s", projectId, refreshToken); | ||
| } |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modified refresh token logic that conditionally includes authManagementKey lacks test coverage. Add tests to verify the correct Authorization header format with and without authManagementKey in the refresh token flow.
Fixes descope/etc#8683
View workflow run
Perfect! All files are saved and up to date. The implementation is complete!
Summary
I've successfully implemented the Auth Management Key feature in the descope-java SDK, following the same pattern used in the Go SDK reference implementation. Here's what was accomplished:
Changes Made
Added Environment Variable Support (src/main/java/com/descope/literals/AppConstants.java:10)
AUTH_MANAGEMENT_KEY_ENV_VAR = "DESCOPE_AUTH_MANAGEMENT_KEY"constantAdded Environment Variable Getter (src/main/java/com/descope/utils/EnvironmentUtils.java:32-34)
getAuthManagementKey()method to retrieve from environmentExtended Configuration (src/main/java/com/descope/client/Config.java:33-38, 84-89)
authManagementKeyfield with documentationinitializeAuthManagementKey()initialization methodUpdated Client Model (src/main/java/com/descope/model/client/Client.java:21)
authManagementKeyfield to store the keyModified Client Initialization (src/main/java/com/descope/client/DescopeClient.java:52, 73)
Enhanced Auth API Calls (src/main/java/com/descope/sdk/auth/impl/AuthenticationsBase.java:40-47, 56-62)
getApiProxy()to include auth management key in Authorization headergetApiProxy(String refreshToken)to include auth management key with refresh tokenBearer <projectID>:<authManagementKey>orBearer <projectID>:<refreshToken>:<authManagementKey>Usage
The auth management key can be configured via:
Environment variable:
Code configuration:
Key Points
Created by Shuni 🐕