Repository navigation
feat(security): enforce credential ownership and retire legacy api_keys (#1050) - #1078
Merged
sbharatjoshi merged 2 commits intoOct 8, 2026
Merged
Conversation
… api_keys table (#1050) - Add Flyway migration V10__retire_api_keys_and_add_credential_key_hash.sql adding key_hash column and index to credentials, and dropping api_keys - Add CredentialCategory.AUTH for inbound API keys & authentication - Support key_hash in CredentialRecord, merge-credential.sql, and find-by-key-hash.sql - Implement findByKeyHash, findAll, and findAllByUserId in JdbcCredentialRepository - Add comprehensive repository unit and adversarial tests Co-authored-by: Bharat Joshi <bharatjoshi@spectrayan.com> Signed-off-by: Forge <forge@spectrayan.com>
…ys (#1050) - Enforce credential ownership and tenant isolation in CredentialController and DefaultCredentialService (IDOR remediation) - Support user-scoped listing for regular users and administrative oversight for admins - Authenticate inbound API keys via CredentialRepository.findByKeyHash in ApiKeyAuthenticationFilter - Completely remove legacy api_keys table, ApiKeyStore.java, and AuthController routes - Update OpenAPI specification to remove retired api-keys paths - Expand test suites covering IDOR protection, two-tier admin scope validation, and inbound auth Co-authored-by: Bharat Joshi <bharatjoshi@spectrayan.com> Signed-off-by: Forge <forge@spectrayan.com>
sbharatjoshi
approved these changes
Oct 8, 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.
Summary
Addresses #1050.
This PR migrates API keys to the universal credentials vault (
credentialstable /CredentialService//api/v1/credentials), remediates Insecure Direct Object References (IDOR) across credential endpoints, enables user-scoped credential listing and administrative oversight, rewires inbound API key authentication toCredentialRepository.findByKeyHash(...), and completely removes the deprecatedapi_keyssubsystem.Key Changes
V10__retire_api_keys_and_add_credential_key_hash.sql):key_hash VARCHAR(64)column tocredentialstable (idx_credentials_key_hash).api_keystable.CredentialController&DefaultCredentialService):@PreAuthorize("isAuthenticated()").X-Tenant-IDheader with authoritative tenant resolution fromSecurityUtils.getTenantId().super-admin) have fleet-wide access.[SPE-820-001 / SPE-SEC-001].spector:adminorsuper-adminroles.GET /api/v1/credentials):record.userId() == callerUserId).?userId=filter).?tenantId=and?userId=filters).ApiKeyAuthenticationFilter):CredentialRepository.findByKeyHash(sha256Hex(rawKey))for activeAUTHcredentials.last_used_atupdates via in-memory 60s coalesce throttle.api_keys:ApiKeyStore.java./api-keysendpoints fromAuthController.java./api/v1/auth/api-keysfromdocs/openapi.yaml.Verification
mvn license:check: 100% compliant across all 29 modules.mvn test -pl synapse/spector-synapse: 1718 tests run, 0 failures, 0 errors, 5 skipped.JdbcCredentialRepositoryAdversarialTest) covering hash collisions, case sensitivity, tenant isolation, and empty-string queries.ControllerSecurityMatrixTest) covering IDOR gating and two-tier admin differentiation.— Forge (Maintainer)