Page MenuHomePhabricator

Inject global `securitySchemes` and operation requirements into OpenAPI spec generator
Closed, ResolvedPublic5 Estimated Story Points

Description

Wire the SessionManager, which T427481: Extend MediaWiki Session framework to support OpenAPI metadata modified to communicate necessary OpenAPI information, into ModuleSpecHandler. Update the specification generator to build the global components.securitySchemes object and dynamically compute route-level security requirements based on whether an endpoint needs read/write access.

Conditions of Acceptance

References

A resulting get example in an OpenAPI spec could be:

security:
  - {}
  - MediaWiki-Session-CookieSessionProvider-Session: []
    MediaWiki-Session-CookieSessionProvider-UserID: []
    MediaWiki-Session-CookieSessionProvider-Token: []
  - MediaWiki-Extension-OAuth-SessionProvider: []

A resulting put example in an OpenAPI spec could be:

security:
  - MediaWiki-Session-CookieSessionProvider-Session: []
    MediaWiki-Session-CookieSessionProvider-UserID: []
    MediaWiki-Session-CookieSessionProvider-Token: []
  - MediaWiki-Extension-OAuth-SessionProvider: []

View of This Task in Context of Related Tasks

implementation_tasks_result_T423552_spike_security_scheme_information_MediaWiki_REST_API_description.png (4,372×8,192 px, 1 MB)

Event Timeline

Async estimation results:

3 points: 3 votes (@BPirkle, @Moriel (she/her), @aghirelli)
5 points: 2 votes (@mgoncalves, @Hua Szu Yang)
8 points: 1 vote (@aschulz)

BPirkle set the point value for this task to 5.Jun 4 2026, 2:09 PM

Decided on a 5 after sync discussion

Per discussion in code review on https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1302980, please also consider where/how to apply localization. Here's my comment on review of that patch, so you don't have to dig it out:

Can/should these descriptions be localizable?

If so, message keys related to session provider tend to begin with "sessionprovider-" and are in files under languages/i18n, not the Rest i18n folder where we've been putting REST-specific message keys.

I'm a little uncertain on the best path here. We use "x-i18n-description" in similar situations with MW REST, but that's specific to that part of the code. Currently only JsonLocalizer knows to do anything with "x-i18n-description". SessionProvider is a completely separate area of the code, and using "x-i18n-description" here feels out of place.

Alternatively, these could be MessageValue objects, similar to what we do in getParamSettings(), but that's inconsistent with everything else in the return value being a flat string.

Sorry, I should have thought about this when Hua Szu wrote her google doc. I just missed it.

aaron changed the task status from Open to In Progress.Tue, Jun 30, 3:41 PM

Change #1306786 had a related patch set uploaded (by Aghirelli; author: Aghirelli):

[mediawiki/core@master] rest: Add security schemes and per-operation security to OpenAPI spec

https://gerrit.wikimedia.org/r/1306786

Change #1306786 merged by jenkins-bot:

[mediawiki/core@master] rest: Add security schemes and per-operation security to OpenAPI spec

https://gerrit.wikimedia.org/r/1306786