Skip to content

Fixed: ModelApiReader resolved omitted auth/publish attributes to false, opposite of rest-api.xsd's declared default - #2011

Open
mridulpathak wants to merge 2 commits into
apache:trunkfrom
mridulpathak:rest-api-secure-defaults
Open

mridulpathak wants to merge 2 commits into
apache:trunkfrom
mridulpathak:rest-api-secure-defaults

Conversation

@mridulpathak

@mridulpathak mridulpathak commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

ModelApiReader parsed an omitted auth or publish attribute via Boolean.parseBoolean(""), which resolves to false, while rest-api.xsd declares both attributes default="true". A .rest.xml resource or operation that omits auth therefore registered without the @secured binding OFBizApiConfig applies based on isAuth(), contrary to what the schema documents. ModelApiReader now defaults both attributes to true when omitted, matching the XSD.

…se, opposite of rest-api.xsd's declared default

ModelApiReader parsed an omitted auth or publish attribute via Boolean.parseBoolean(""), which resolves to false, while rest-api.xsd declares both attributes default="true". A .rest.xml resource or operation that omits auth therefore registered without the @secured binding OFBizApiConfig applies based on isAuth(), contrary to what the schema documents.

OpenApiResource (the OpenAPI schema endpoint) also had no @secured binding of its own, independent of any .rest.xml auth setting.

ModelApiReader now defaults both attributes to true when omitted, matching the XSD, and OpenApiResource is now bound with @secured like other protected resources.
mridulpathak added a commit to mridulpathak/ofbiz-plugins that referenced this pull request Sep 15, 2026
…se, opposite of rest-api.xsd's declared default

Backport of the trunk fix (apache/ofbiz-framework#2011) to the pre-move rest-api plugin here: ModelApiReader parsed an omitted auth or publish attribute via Boolean.parseBoolean(""), which resolves to false, while rest-api.xsd declares both attributes default="true", and OpenApiResource had no @secured binding of its own. Both are fixed the same way as on trunk, adapted to this branch's javax.ws.rs and org.apache.ofbiz.ws.rs.security.Secured layout.
Gating GET /rest/openapi.json behind auth conflicts with how Swagger UI's own Authorize flow works: it assumes the spec is viewable before a client has a token, since that's where a developer discovers how to obtain one in the first place. Leaving OpenApiResource unauthenticated, as it was before this fix, keeps that flow intact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant