Skip to content

AuthorizationController stub bodies need implementation + per-TP filtering #141

Description

@dfcoffin

Summary

web/api/AuthorizationController currently has two endpoints whose bodies return null (stubs marked //todo - complete implementation). PR C2a fixed the long-disabled AuthorizationControllerTest as a security-boundary-only check (verifies authentication + scope-based authorization), but the functional behavior still needs to be built.

Endpoints

Method Path Status
GET /espi/1_1/resource/Authorization Stub returns null — should return a paginated list of authorizations
GET /espi/1_1/resource/Authorization/{authorizationId} Stub returns null — should return a single authorization or 404

Required behavior

Both endpoints accept either of two scopes (post-PR C2a):

  • SCOPE_DataCustodian_Admin_Access — DC admin (client_credentials)
  • SCOPE_ThirdParty_Admin_Access — TP admin (client_credentials)

A customer-bearer (FB-scoped) token is rejected at the chain level (verified in PR C2a tests).

Per-TP filtering when called with SCOPE_ThirdParty_Admin_Access

A TP authenticating with its own client_credentials token MUST see only its own authorizations, not the full set. The current stub's commented-out logic calls authorizationRepository.findAll(...) unconditionally, which would expose every TP's authorizations to every other TP. This is the production-critical part of the implementation.

Implementation approach (suggested, not prescriptive):

String clientId = extractClientIdFromAuthentication(authentication);
boolean isDcAdmin = hasAuthority(authentication, "SCOPE_DataCustodian_Admin_Access");
Page<AuthorizationEntity> page = isDcAdmin
    ? authorizationRepository.findAll(pageable)
    : authorizationRepository.findAllByThirdParty(clientId, pageable);

For the single-id endpoint: findById(authorizationId) then verify ownership matches clientId (404 if not — don't leak existence).

Acceptance criteria

  • GET /Authorization with SCOPE_DataCustodian_Admin_Access returns paginated list of ALL authorizations.
  • GET /Authorization with SCOPE_ThirdParty_Admin_Access returns ONLY authorizations whose third_party matches the authenticating client.
  • GET /Authorization/{id} with admin scope returns the authorization or 404.
  • GET /Authorization/{id} with TP_Admin scope returns the authorization IFF it belongs to the authenticating client, else 404 (never 403 — no existence leak).
  • Existing PR C2a security-boundary tests still pass.
  • New functional MockMvc tests covering: admin sees all; TP sees only own; TP cannot see another TP's authorization (404).

Refs

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions