manage-webapps
暂无简介
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-10
- Stars
- ★ 178
- Forks
- 222
02 资源文件 5
- 参考文档references/language-patterns.md5.2 KB
- 参考文档references/report-format.md6.6 KB
- 参考文档references/secret-patterns.md3.4 KB
- 参考文档references/vuln-categories.md7.7 KB
- 参考文档references/vulnerable-packages.md3.9 KB
03 SKILL.md 正文
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
name: manage-webapps description: Configure and manage OFBiz web applications, defining component webapp properties, servlet environments, and request routing through controller.xml.
Manage Webapps Skill
Manage the registration, bootstrapping, and request routing of OFBiz web applications. This skill covers how webapps link to components, how the servlet environment is initialized, and how requests flow through the framework.
Triggers
- Creating a new module or UI plugin.
- Exposing a set of screens or services to the web.
- Modifying servlet filters, listeners, or security settings.
- Debugging request routing or dispatcher lookup issues.
Component Webapp Definition (ofbiz-component.xml)
Webapps are registered in the ofbiz-component.xml file. A single component can contain multiple web applications (e.g., ordermgr, facility, catalog).
Key Attributes
- name: Unique identifier for the webapp.
- title: Display name; also used in headers when no UI Label is found.
- mount-point: The context path (e.g.,
/mywebapp). - app-bar-display:
true/false. Controls if the app appears in the top navigation bar. - base-permission: Defines the minimum security permission(s) required to access the webapp. The user must have ALL listed permissions to enter.
- access-permission: (Preferred) Modern replacement for
base-permission. Takes precedence if both are defined. - server: Usually
default-server. - location: Path to the webapp directory relative to the component root.
- menu-name: Determines which application menu it belongs to (e.g.,
main,secondary). - client-proxy-server: Optional proxy server name for the webapp.
- description: Internal documentation of the webapp's purpose.
- position: Order of the app in the application bar or menu.
- use-autologin-cookie:
true/false. Enables the "remember me" feature. - session-cookie-max-age: Duration in seconds for the session cookie.
The Request Pipeline
Understanding the flow is critical for debugging and routing.
1. Request Routing vs. Bootstrapping
web.xml: Bootstraps the servlet environment (Filters, Servlets, Listeners).controller.xml: Handles the actual Request Routing logic.
2. Standard Flow
- Browser sends request (e.g.,
/ordermgr/control/viewOrder). - ControlServlet (defined in
web.xml) processes all controller requests. - ControlServlet delegates to
controller.xmlby matching the request URI to a<request-map>. controller.xmlMapping:- Request-Map: Checks security and invokes events.
- Event: Logic-level execution (Service, Java, Groovy).
- View-Map: Determines the response type (view, redirect, request).
- Screen: If response type is
view, a screen definition is called (e.g.,widget/OrderScreens.xml). - Widget: The screen renders UI components (Form, Menu, Tree).
Web Application Configuration (web.xml)
Located in webapp/<webapp-name>/WEB-INF/web.xml.
The Filter Chain
OFBiz uses a specific sequence of filters for security and context management. Order is critical.
- ContextFilter: Initializes the delegator and local dispatcher.
- ControlFilter: Handles URL redirections and allowed paths.
- SameSiteFilter: Manages session cookie flags.
- SecurityFilter: Handles request-level authentication/authorization.
- ResponseFilter: Manages response headers (caching, security headers).
Servlet Configuration
- servlet-name: Usually
ControlServlet. - servlet-class:
org.apache.ofbiz.webapp.control.ControlServlet. - servlet-mapping: Maps a URL pattern (standardly
/control/*) to theControlServlet.
Context Parameters (context-param)
- delegatorName: The name of the entity delegator to use (e.g.,
default). - localDispatcherName: Connects the webapp to a unique service engine instance.
- Guardrail: It MUST match the webapp name (e.g.,
ordermgr) to ensure reliable service execution and logging.
- Guardrail: It MUST match the webapp name (e.g.,
- mainDecoratorLocation: Path to the main decorator screen used by the webapp (e.g.,
component://order/widget/CommonScreens.xml).
Three-Layer Security Model
Access control happens at three distinct levels:
- Component Level:
base-permissioninofbiz-component.xml(The gatekeeper). - Controller Level:
<security auth="true"/>inrequest-map(Path protection). - Service Level:
auth="true"inservices.xml(Logic protection).
Static Resource Handling
Static assets (images, CSS, JS) reside in webapp/<app>/.
- Rule: These are served directly by the servlet container. Do not route static assets through the controller via a request-map.
Procedure
- Define the webapp in
ofbiz-component.xmlwith proper permissions andapp-bar-display. - Create the folder structure:
webapp/<app>/WEB-INF/andwebapp/<app>/widget/. - Configure
web.xmlfor bootstrapping (Filters,ControlServlet,localDispatcherName). - Define routing in
controller.xml(request-map,view-map). - Verify global framework settings in
url.properties(affects all webapps).
Best Practices
- Unique Mount Points: Ensure mount points do not overlap across the framework.
- Permission Consistency: Align
base-permissioninofbiz-component.xmlwith request-level security checks incontroller.xml. - Dispatcher Naming Symmetry: Always match
localDispatcherNameinweb.xmlto the webapp name defined inofbiz-component.xml. - Context Path Safety: Avoid hardcoding context roots (e.g.,
/ordermgr) in URLs; use dynamic path lookups (e.g.,request.getContextPath()).
Guardrails
- Filter Order: Never reorder filters in
web.xmlwithout deep framework knowledge. - Dispatcher Symmetry: Always match
localDispatcherNameto the webapp name. - Servlet Mappings: Do not modify
ControlServletmappings (/control/*) unless extending the core engine. - Context Safety: Never expose sensitive logic or files outside of the
ControlServletrouting. - Mount Point Uniqueness: Ensure mount points do not overlap across the framework.
Anti-Patterns
- ❌ Shared Dispatchers: Multiple apps sharing one dispatcher name, leading to context collisions.
- ❌ Controller-Routed Assets: Creating request-maps for simple
.jsor.cssfiles. - ❌ Hardcoded Context Paths: Using
/ordermgrin HTML instead of dynamic context lookup.
Examples
1. Minimal Webapp Setup Structure
my-component/
ofbiz-component.xml
webapp/
example/ <-- Webapp Location
images/ <-- Static Assets
WEB-INF/
web.xml <-- Bootstrapping
controller.xml <-- Request Routing
widget/
ExampleScreens.xml <-- UI Definitions
2. Webapp Registration (ofbiz-component.xml)
<webapp name="example"
title="Example App"
server="default-server"
location="webapp/example"
mount-point="/example"
app-bar-display="true"
base-permission="OFBTOOLS,EXAMPLE_VIEW"/>
3. Request Routing (controller.xml)
<request-map uri="viewOrder">
<security auth="true" https="true"/>
<event type="service" invoke="getOrderDetails"/>
<response name="success" type="view" value="OrderView"/>
</request-map>
<view-map name="OrderView" type="screen" page="component://order/widget/OrderScreens.xml#OrderView"/>
4. Global URL Settings (url.properties)
[!IMPORTANT] Settings in
framework/webapp/config/url.propertiesapply globally to all webapps in the instance.
no.http=Y: Force HTTPS instance-wide.port.https=8443: Global secure port.content.url.prefix: Global prefix for media/content like images, JS, CSS, and URL (e.g., CDN or static server).