[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACQ1ACNJQBTAYZC6S6GWQV":3,"skill-same:01M6ACQ1ACNJQBTAYZC6S6GWQV":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":34,"frontMatter":35,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":41,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":7,"updatedAt":44,"install":45,"resources":58},"01M6ACQ1ACNJQBTAYZC6S6GWQV","manage-security-advanced","OFBiz 高级安全配置管理",null,"","apache\u002Fofbiz-plugins","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACMJJ1Q4WYATY4GXZ2FAVD",178,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-security-advanced\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BR4MYFKGCC4WCWVJ50KJ2C","安全工程师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BXREJNJE7HY785DVVKG7CW","Web应用安全防护","SCENARIO","使用场景",[30,31],"security","manage security advanced","2026-11-10 10:12:30",false,"\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\n---\nname: manage-security-advanced\ndescription: |\n  Manage OFBiz access control using permissions, security groups, service-level authorization, and business data scoping. OFBiz security is granular and permission-driven, but secure implementations must also protect services, requests, APIs, and record-level access. Use when:\n  - Implementing access controls for controllers, services, and screens.\n  - Differentiating between module-level and record-level (data scoped\u002Fmulti-tenant) permissions.\n  - Designing security groups, permissions, roles, and enforcing separation of duties.\n---\n\n## Goal\nImplement a defense-in-depth security model in OFBiz by prioritizing Service-Level validation and strict data scoping, ensuring UI-level checks are treated merely as UX conveniences.\n\n## Triggers\n**ALWAYS** read this skill when:\n- **New Access Control**: Creating applications requiring authentication or authorization.\n- **Roles & Groups**: Defining user roles, security groups, or permissions in seed data.\n- **Data Isolation**: Implementing logic that requires multi-tenant or record-level data scoping.\n- **Exposing Endpoints**: Adding controller request-maps, APIs, or background jobs.\n\n> [!TIP]\n> If you are configuring password strengths, host headers, or moving a server to production, see the [manage-security-deployment](..\u002Fmanage-security-deployment\u002FSKILL.md) skill instead.\n\n## Core Concepts\n\n### 1. The OFBiz Trust Model\n- **Administrative Trust Boundary**: OFBiz does **not** sandbox administrators from the host OS JVM. Any user with administrative rights is considered fully trusted.\n- **Plugin & Extension Trust**: All custom extensions and plugins (including `ecommerce`) execute with the same privileges as the core framework.\n- **OS Privilege Boundary**: The application must be run by a dedicated, restricted OS user account, as OFBiz lacks internal privilege separation.\n\n### 2. Authentication vs Authorization\n- **Authentication**: Verifying *who* the user is (`userLogin`). Controllers must require authentication.\n- **Authorization**: Verifying *what* the user can do (`hasEntityPermission`).\n\n### 3. The Two Levels of OFBiz Authorization\n1. **Functionality\u002FModule-Level Security**: Broad permissions tied purely to the `SecurityGroup` (e.g., `ORDERMGR_VIEW`). It dictates if a user can access a module feature generally.\n2. **Record-Level Access (Data Scoping)**: Row-level security combining a module check with a business data query. For example, verifying a user has `ORDERMGR_ROLE_VIEW` *AND* ensuring they are actively associated with a specific Order via `OrderRole`. `hasEntityPermission` does **not** grant safe access to *every* record across the system.\n\n### 4. Auditability\nAlways preserve the `userLogin` object in the service context so the framework correctly tracks `createdByUserLogin` and `lastModifiedByUserLogin`.\n\n## Procedure\n\n### 1. The Security Hierarchy Checklist\nWhen evaluating access control, **always think in this exact order**:\n1. **Who is the user?** Identity validation (`auth=\"true\"`).\n2. **What module permission do they have?** Functionality authorization.\n3. **Should they access this specific record?** Business Data Scoping (ownership boundary).\n4. **Is the service protected?** The absolute core layer of defense.\n5. **Is every entry point protected?** Controller endpoints, APIs, and events.\n\n### 2. Service-Level Security (Primary Defense)\nThe service layer is the absolute core. Even if UI buttons are hidden, if a request event invokes logic, the underlying service MUST enforce the permission. \n- Protect EVERY mutating service and EVERY sensitive read service.\n- Centralize permission checks into reusable `\u003Cpermission-service>` helpers.\n\n### 3. Controller\u002FRequest Protection\nPrevent anonymous access to internal logic at the HTTP boundary. URLs and direct events should never bypass login (`auth=\"true\"` and `https=\"true\"`).\n\n### 4. Defining Groups & Seed Data\n- **Scope Groups**: Create granular groups like `ORDER_ENTRY_CLERK` instead of generic admin buckets.\n- **Separate Duties**: Approvals must not be handled by the same broad group that creates the transactions.\n- **Seed vs Demo Data**: Foundational security permissions must reside in `seed` data. Never assume demo users (`admin`) exist in production environments.\n\n## Guardrails\n\n- **Service-first security**: Enforce access at the service layer; never rely only on screens or menus.\n- **Least privilege**: Grant only the minimum modular permissions required for the job.\n- **Scope matters**: Permission to view\u002Fupdate a module does not automatically grant access to all records in that module (Data Scoping).\n- **No hardcoded admins**: Never hardcode user IDs, group IDs, or bypasses in business logic.\n- **Use reusable checks**: Prefer centralized `\u003Cpermission-service>` implementations for complex checks.\n- **Protect entry points**: Secure controller request-maps, events, services, and APIs consistently.\n- **Audit sensitive actions**: Ensure important security-sensitive actions remain attributable to an authenticated `userLogin`.\n- **Separate Infrastructure**: Do not configure `security.properties` or Tomcat headers here. Refer to the [manage-security-deployment](..\u002Fmanage-security-deployment\u002FSKILL.md) skill.\n\n## Examples\n\n### 1. Centralized Service Protection (XML)\nModularize permission logic into reusable helper services to protect business logic.\n\n```xml\n\u003C!-- Reusable permission service -->\n\u003Cservice name=\"orderManagerPermissionCheck\" engine=\"java\" ...> ... \u003C\u002Fservice>\n\n\u003C!-- Protecting a mutating service -->\n\u003Cservice name=\"createOrder\" engine=\"java\" ...>\n    \u003Cpermission-service service-name=\"orderManagerPermissionCheck\" main-action=\"CREATE\"\u002F>\n\u003C\u002Fservice>\n```\n\n### 2. Programmatic Module Check (Groovy\u002FJava)\nFor ad-hoc logic or when checking permissions manually inside a service implementation.\n\n```java\n\u002F\u002F Check basic module functionality permission\nif (!security.hasEntityPermission(\"ORDERMGR\", \"_CREATE\", userLogin)) {\n    return ServiceUtil.returnError(\"You do not have permission to create orders.\");\n}\n```\n\n### 3. Data Scoping \u002F Record-Level Security (Java)\nCombine a broad module-level check with a strict business data query to enforce multi-tenant or ownership boundaries.\n\n```java\npublic Map\u003CString, Object> viewVendorOrder(DispatchContext dctx, Map\u003CString, ?> context) {\n    GenericValue userLogin = (GenericValue) context.get(\"userLogin\");\n    String orderId = (String) context.get(\"orderId\");\n\n    \u002F\u002F 1. Module-Level Check\n    if (!security.hasEntityPermission(\"ORDERMGR\", \"_VIEW\", userLogin)) {\n        return ServiceUtil.returnError(\"Permission denied.\");\n    }\n\n    \u002F\u002F 2. Data Scoping Check (Business Ownership Boundary)\n    long relatedOrderCount = EntityQuery.use(delegator).from(\"OrderRole\")\n        .where(\"orderId\", orderId, \"partyId\", userLogin.getString(\"partyId\"), \"roleTypeId\", \"VENDOR\")\n        .queryCount();\n\n    if (relatedOrderCount == 0) {\n        return ServiceUtil.returnError(\"Security Violation: You do not have organization access to this order.\");\n    }\n    \u002F\u002F Proceed...\n}\n```\n\n### 4. Controller Protection (XML)\nEnsure public\u002Funauthenticated requests cannot trigger internal logic.\n\n```xml\n\u003C!-- Enforces login and SSL -->\n\u003Crequest-map uri=\"createOrderEndpoint\">\n    \u003Csecurity https=\"true\" auth=\"true\"\u002F>\n    \u003Cevent type=\"service\" invoke=\"createOrder\"\u002F>\n    \u003Cresponse name=\"success\" type=\"view\" value=\"OrderSummary\"\u002F>\n\u003C\u002Frequest-map>\n```\n\n### 5. UI Visibility as UX Convenience (XML)\nUse `\u003Cif-has-permission>` strictly to prevent showing dead links. **This is not a security boundary.**\n\n```xml\n\u003Cscreen name=\"ViewOrder\">\n    \u003Csection>\n        \u003Ccondition>\n            \u003C!-- Check permission before rendering the link -->\n            \u003Cif-has-permission permission=\"ORDERMGR\" action=\"_VIEW\"\u002F>\n        \u003C\u002Fcondition>\n        \u003Cwidgets>\n            \u003C!-- Render the link -->\n        \u003C\u002Fwidgets>\n    \u003C\u002Fsection>\n\u003C\u002Fscreen>\n```\n\n## Anti-Patterns\n\n- **❌ Hardcoding User IDs or Roles**: Never grant bypasses based on specific user IDs. Permissions must come from the defined security model.\n  ```java\n  \u002F\u002F BAD: Hardcoding bypassing security logic\n  if (\"admin\".equals(userLogin.getString(\"userLoginId\"))) { ... }\n\n  \u002F\u002F GOOD: Using the OFBiz Security engine\n  if (security.hasEntityPermission(\"SYSTEM\", \"_ADMIN\", userLogin)) { ... }\n  ```\n\n- **❌ Unprotected Mutating Services**: Exposing `java`\u002F`groovy` services without a `\u003Cpermission-service>` mapping or an internal `security` check.\n  ```xml\n  \u003C!-- BAD: Mutating service without permission boundary -->\n  \u003Cservice name=\"deleteDangerousData\" engine=\"java\" default-entity-name=\"SystemData\" ...\u002F>\n  ```\n\n- **❌ Relying solely on UI Hiding**: Assuming an action is secure just because the screen `\u003Clink>` requires a permission. A malicious user can directly POST to the `auth=\"false\"` controller endpoint mapped to the underlying service.\n\n- **❌ Accidental System Context Execution**: Wrapping untrusted input in a block where `userLogin` is specifically swapped to the `system` account. Elevated actions must never be casually triggered by normal user requests.\n  ```java\n  \u002F\u002F BAD: Executing logic with an elevated 'system' user context without extreme care\n  GenericValue systemUser = EntityQuery.use(delegator).from(\"UserLogin\").where(\"userLoginId\", \"system\").queryOne();\n  dispatcher.runSync(\"someSensitiveService\", UtilMisc.toMap(\"userLogin\", systemUser));\n  ```\n\n- **❌ Overuse of FULLADMIN**: Assigning standard users to `FULLADMIN` (except for true system administrators) causes uncontrolled security sprawl. Always prefer job-scoped groups (e.g., `ORDER_ENTRY_CLERK`).\n",{},"trunk","6c6c27710443de03e9247605d33a2e2f5bc3d1e2","ai-agent-skills\u002Fmanage-security-advanced",222,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins","https:\u002F\u002Fofbiz.apache.org\u002F","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-12 22:04:06",{"source":9,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add apache\u002Fofbiz-plugins --skill manage-security-advanced",{"tool":51,"command":52},"bunx","bunx skills add apache\u002Fofbiz-plugins --skill manage-security-advanced",{"tool":54,"command":55},"pnpm","pnpm dlx skills add apache\u002Fofbiz-plugins --skill manage-security-advanced","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-security-advanced\u002FSKILL.md",true,[59],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"scripts\u002Finstall.sh","SCRIPT","脚本",5593,"https:\u002F\u002Fgithub.com\u002Fgithub\u002Fawesome-copilot\u002Fblob\u002Fmain\u002Fskills\u002Fsandbox-npm-install\u002Fscripts\u002Finstall.sh",[66,80,92,106,120,134],{"skillNo":67,"name":68,"nameZh":69,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":70,"categories":71,"keywords":78,"publishedAt":32},"01M6ACQSN90YKJZ92MQ52D9R8H","prepush-readiness","推送前就绪检查","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fprepush-readiness\u002FSKILL.md",[72,75],{"categoryNo":73,"categoryName":74,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师",{"categoryNo":76,"categoryName":77,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[79],"prepush readiness",{"skillNo":81,"name":82,"nameZh":83,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":84,"categories":85,"keywords":90,"publishedAt":32},"01M6ACQPR1WRA751V4DXVC3AHF","manage-webapps","Web 应用管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-webapps\u002FSKILL.md",[86,87],{"categoryNo":73,"categoryName":74,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":88,"categoryName":89,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BWKS60NTYJHFE9FQSXGDKS","低代码应用开发",[91],"manage webapps",{"skillNo":93,"name":94,"nameZh":95,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":96,"categories":97,"keywords":104,"publishedAt":32},"01M6ACQMCX8Z7NY2CE08NCV6ND","manage-themes","主题管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-themes\u002FSKILL.md",[98,101],{"categoryNo":99,"categoryName":100,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQMKHSMFVQHR2KYAEVN","界面设计师",{"categoryNo":102,"categoryName":103,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[105],"manage themes",{"skillNo":107,"name":108,"nameZh":109,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":110,"categories":111,"keywords":118,"publishedAt":32},"01M6ACQHYN20AFWF6TKK4RGQ8A","manage-tests","测试管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-tests\u002FSKILL.md",[112,115],{"categoryNo":113,"categoryName":114,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":116,"categoryName":117,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[119],"manage tests",{"skillNo":121,"name":122,"nameZh":123,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":124,"categories":125,"keywords":132,"publishedAt":32},"01M6ACQFRMW7R45YD3HRAXPGWF","manage-templates","模板管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-templates\u002FSKILL.md",[126,129],{"categoryNo":127,"categoryName":128,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TK1MPB82068236GSXDE","文档处理",{"categoryNo":130,"categoryName":131,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TPH3VQWKQZXV7EPF8VZ","办公行政人员",[133],"manage templates",{"skillNo":135,"name":136,"nameZh":137,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":138,"categories":139,"keywords":146,"publishedAt":32},"01M6ACQCSSDZQMD8VX2K3WRR93","manage-strategies","策略管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-strategies\u002FSKILL.md",[140,143],{"categoryNo":141,"categoryName":142,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BTXF8K9DFQC4T4TXVH0NMZ","策略与托管设置管理",{"categoryNo":144,"categoryName":145,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8C6RQ852C9AEJFCBGG1YA7S","IT 管理员",[147],"manage strategies"]