fix: return login statuses on platform toolset/application GET #1928 - #1960
KirylKurnosenka wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
/deploy-review
|
This comment has been minimized.
This comment has been minimized.
| case APPLICATION -> handleSingleGetFromBlob(ResourceTypes.APPLICATION, | ||
| (key, application) -> { | ||
| Application entity = (Application) application; | ||
| new ExternalServiceStatusEnricher(context, context.getProxy().getResourceAuthSettingsService()) |
There was a problem hiding this comment.
better add ResourceAuthSettingsService via constructor as we do with other services.
There was a problem hiding this comment.
Done in 6f146d8 — ResourceAuthSettingsService is now taken via the constructor alongside the other services (the controller was reworked to derive all of them from Proxy there).
| * <p>Memoizes that lookup, so create one per response rather than per service. | ||
| */ | ||
| @Slf4j | ||
| public class ExternalServiceStatusEnricher { |
There was a problem hiding this comment.
Suggestion: re-name this to ResourceAuthStatusEnricher and move toolset status enrichment here as well.
public void enrichToolSet(String toolSetId, ToolSet toolSet) {
if (toolSet.getAuthSettings() == null) {
return;
}
resourceAuthSettingsService.setResourceAuthStatuses(CredentialsLocatorFactory.fromAnyUrl(
UrlUtil.encodePath(toolSetId), context, ResourceTypes.TOOL_SET),
toolSet.getAuthSettings(), context.getInitiatorId());
}
So we incapsulate this logic in enricher and use it for both branches in ConfigResourceController:
case APPLICATION -> ... authStatusEnricher.enrichApplication(path, entity.getExternalServices());
case TOOL_SET -> ... authStatusEnricher.enrichToolSet(path, entity);
It's also a good place to deal with encoded/decoded ids. Can we move this logic here from controller, where we do UrlUtil.encodePath(toolSetId)?
There was a problem hiding this comment.
Done in 6f146d8 — renamed to ResourceAuthStatusEnricher and moved toolset status enrichment here as enrichToolSet (also absorbing the UrlUtil.encodePath(toolSetId) handling from the controllers, which now pass decoded ids). ToolSetService.setResourceAuthStatuses is removed; all callers go through the enricher.
…Enricher #1928 Renames ExternalServiceStatusEnricher to ResourceAuthStatusEnricher and moves toolset status enrichment there (enrichToolSet), absorbing the id encode/decode handling from the controllers. ToolSetService.setResourceAuthStatuses is removed; ConfigResourceController, ResourceController and ToolSetController now go through the enricher. ConfigResourceController also injects ResourceAuthSettingsService via the constructor like its other services. Unit tests follow the moved logic (ResourceAuthStatusEnricherTest). Co-Authored-By: Claude Code <noreply@anthropic.com>
…nstructor #1928 The platform-route tests stubbed proxy.getAccessService() (and app/toolset services) that the constructor no longer reads, tripping Mockito strict stubs; only the config store is dereferenced at construction time. Co-Authored-By: Claude Code <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
GET v1/{toolsets|applications}/platform/{name}returned entities without the computed login statuses (global_auth_status,user_level_auth_status,app_level_auth_status), so the Admin UI showed the toolset/application as logged out even after a successful sign-in. The blobs never persist statuses (the write path strips computed fields), so the platform-bucket GET must compute them per caller — this adds that, reusing the same mechanisms the usage APIs already employ, and consolidates the status enrichment that was duplicated across controllers into one place.Applicable issues
Description of changes
ConfigResourceController.handleGetcase TOOL_SET: computes auth statuses viaResourceAuthStatusEnricher.enrichToolSetwith the short-name credential scope (platform deployments are short-name keyed in the merged config — the same form/v1/ops/toolset/signinnormalizes credentials under); per-call try/catch so a Redis hiccup degrades to omitted statuses instead of failing the GETcase APPLICATION: computes external-service statuses viaResourceAuthStatusEnricher.enrichApplication, using the short-name scope, before admin decrypt and secret redactionApplicationController,ResourceController,ConfigResourceController) into a singleResourceAuthStatusEnricher.enrichApplication, which resolves scopes through the newCredentialsLocatorFactory.fromExternalService(appId, serviceId, context)— decoded-only contract, symmetric encoding of both parts, with the one mixed-form input (ApplicationController's id) normalized at its own boundaryExternalServiceStatusEnricherand now also owns toolset status enrichment —enrichToolSetabsorbs the id encoding from the controllers, which pass decoded ids;ToolSetService.setResourceAuthStatusesis removed and all callers (ConfigResourceController,ResourceController,ToolSetController) go through the enricher;ConfigResourceControllertakesResourceAuthSettingsServicevia its constructor like its other servicesPlatformAppToolsetApiTest: API_KEY toolset statuses on GET (sign-in flips both levels), application external-service statuses (USER + APPLICATION sign-in), and OAUTH toolset withclient_secret_hintand status present togetherChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
🤖 Generated with Claude Code