Skip to content

DC scope enforcement vocabulary doesn't match AS-issued ESPI FB scopes — customer tokens 403 on all resources #157

Closed

Description

@dfcoffin

Confirmed cross-service scope mismatch (AS issues one vocabulary, DC enforces another)

AS issues (seeded third_party client, AuthorizationServerConfig):

scope = "FB=4_5_15;IntervalDuration=3600;BlockDuration=monthly;HistoryLength=13"

DC uses the stock SpringOpaqueTokenIntrospector (no custom authority mapping), so Spring converts that scope to the authority:

SCOPE_FB=4_5_15;IntervalDuration=3600;BlockDuration=monthly;HistoryLength=13

DC enforces (openespi-datacustodian/.../config/SecurityConfiguration.java):

.requestMatchers(HttpMethod.GET, "/espi/1_1/resource/UsagePoint/**")
    .hasAnyAuthority("SCOPE_FB_15_READ_3rd_party", "SCOPE_FB_16_READ_3rd_party",
                     "SCOPE_FB_36_READ_3rd_party", "SCOPE_DataCustodian_Admin_Access")

The authority a customer token actually carries (SCOPE_FB=4_5_15;...) matches none of these matchers ⇒ every customer-token call to /UsagePoint, /MeterReading, /Subscription/*/UsagePoint, etc. returns 403.

Why it's gone unnoticed

Likely intended design

ESPI 4.0 scopes are FB=... function-block strings (the standard vocabulary the AS issues; see the FB-scope parser from PR A / [scope memory]). DC's FB_15_READ_3rd_party is a legacy/ad-hoc naming. The fix is almost certainly a custom DC authority mapping — an OpaqueTokenIntrospector (or Converter<OAuth2AuthenticatedPrincipal, ...>) that parses the ESPI FB scope into the function-block authorities DC enforces — reusing PR A's parser — rather than relying on stock raw SCOPE_<rawscope> mapping. Alternatively, align the two vocabularies.

Scope of fix

Surfaced during DC-plan seam analysis (folds into #150).

Activity

  1. added
    bugSomething isn't working
    NAESB ESPI StandardRequired to comply with the NAESB ESPI standard
    blockingBlocks other work or CI
    on Jun 4, 2026
  2. added a commit that references this issue on Jun 4, 2026
  3. added 2 commits that reference this issue on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    NAESB ESPI StandardRequired to comply with the NAESB ESPI standardblockingBlocks other work or CIbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions