一键导入
manage-security
Configure Mendix security via MDL: module roles, user roles, entity/microflow/page access, project security settings, and demo users
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Configure Mendix security via MDL: module roles, user roles, entity/microflow/page access, project security settings, and demo users
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Mendix MDL authoring, project navigation, and Docker app lifecycle — entities, microflows, pages, security, navigation, OQL, REST, testing, linting, and migration. Load when working in any Mendix codebase.
MDL Agent Documents — CREATE MODEL, CREATE KNOWLEDGE BASE, CREATE CONSUMED MCP SERVICE, CREATE AGENT syntax and calling agents from microflows
ALTER PAGE / ALTER SNIPPET — SET, INSERT, DROP, REPLACE widget operations on existing pages and snippets
Migration Assessment — structured investigation of non-Mendix projects for migration planning across technology stack, data model, business logic, UI, integrations, and security
Assess Mendix Project Quality — automated linting, catalog queries, naming conventions, security, maintainability, performance, and architecture review with scored report
Browse Integration Services and Contracts — SHOW/DESCRIBE OData, REST, business event, and database connection services; query MDL CATALOG integration tables; import external entities
| name | manage-security |
| description | Configure Mendix security via MDL: module roles, user roles, entity/microflow/page access, project security settings, and demo users |
| compatibility | opencode |
<security_concepts>
Shop.Admin, Shop.Viewer)Administrator includes Shop.Admin + System.Administrator)off, prototype, or production
</security_concepts><syntax_reference>
-- Project-wide security overview
show project security;
-- Module roles (all or filtered)
show module roles;
show module roles in MyModule;
-- User roles and demo users
show user roles;
show demo users;
-- Access on specific elements
show access on microflow MyModule.ProcessOrder;
show access on page MyModule.CustomerOverview;
show access on MyModule.Customer;
-- Full security matrix
show security matrix;
show security matrix in MyModule;
-- Describe individual roles and users (MDL output)
describe module role MyModule.Admin;
describe user role Administrator;
describe demo user 'demo_admin';
Security data is available in catalog tables for advanced querying. Use refresh catalog full to populate permissions and role mappings.
-- All permissions (entity, microflow, page, OData access)
select * from CATALOG.PERMISSIONS where ModuleRoleName = 'MyModule.Admin';
-- Filter by type
select ElementName, AccessType from CATALOG.PERMISSIONS
where ElementType = 'ENTITY' and ModuleName = 'MyModule';
select ElementName from CATALOG.PERMISSIONS
where ElementType = 'MICROFLOW' and AccessType = 'EXECUTE';
-- User role to module role mappings
select * from CATALOG.ROLE_MAPPINGS;
select ModuleRoleName from CATALOG.ROLE_MAPPINGS where UserRoleName = 'Administrator';
-- Which user roles have access to a module?
select distinct UserRoleName from CATALOG.ROLE_MAPPINGS where ModuleName = 'MyModule';
-- Describe catalog table schema
describe CATALOG.PERMISSIONS;
describe CATALOG.ROLE_MAPPINGS;
Catalog tables:
| Table | Contents | Build mode |
|---|---|---|
CATALOG.PERMISSIONS | Entity CRUD, microflow EXECUTE, page VIEW, OData ACCESS | refresh catalog full |
CATALOG.ROLE_MAPPINGS | User role → module role assignments | refresh catalog |
-- Create module roles
create module role MyModule.Admin description 'Full administrative access';
create module role MyModule.User;
create module role MyModule.Viewer description 'Read-only access';
-- Remove a module role
drop module role MyModule.Viewer;
-- Grant execute access (multiple roles supported)
grant execute on microflow MyModule.ACT_Customer_Create to MyModule.User, MyModule.Admin;
-- Revoke from specific roles
revoke execute on microflow MyModule.ACT_Customer_Create from MyModule.User;
-- Grant execute access (same syntax as microflows)
grant execute on nanoflow MyModule.NF_ValidateCart to MyModule.User, MyModule.Admin;
-- Revoke from specific roles
revoke execute on nanoflow MyModule.NF_ValidateCart from MyModule.User;
-- Show current access
show access on nanoflow MyModule.NF_ValidateCart;
Note: Security roles persist through DROP+CREATE of the same nanoflow name within a session (by design, for refactor-in-place workflows).
-- Grant view access
grant view on page MyModule.Customer_Overview to MyModule.User, MyModule.Admin;
-- Revoke from specific roles
revoke view on page MyModule.Customer_Overview from MyModule.User;
GRANT is additive — it merges with existing access, never removes permissions.
-- Full access (all CRUD + all members)
grant MyModule.Admin on MyModule.Customer (create, delete, read *, write *);
-- Read-only (all members)
grant MyModule.Viewer on MyModule.Customer (read *);
-- Selective member access
grant MyModule.User on MyModule.Customer (read (Name, Email), write (Email));
-- Additive: adds Phone to existing read access (Name, Email preserved)
grant MyModule.User on MyModule.Customer (read (Phone));
-- With XPath constraint
grant MyModule.User on MyModule.Order (read *, write *) where '[Status = ''Open'']';
-- Revoke entity access entirely
revoke MyModule.Viewer on MyModule.Customer;
-- Partial revoke: remove read on specific attribute
revoke MyModule.User on MyModule.Customer (read (Phone));
-- Partial revoke: downgrade write to read-only
revoke MyModule.User on MyModule.Customer (write (Email));
-- Partial revoke: remove structural permission
revoke MyModule.User on MyModule.Customer (delete);
-- Create with module roles
create user role RegularUser (MyModule.User, OtherModule.Reader);
-- Create with manage all roles permission
create user role SuperAdmin (MyModule.Admin) manage all roles;
-- Add/remove module roles
alter user role RegularUser add module roles (MyModule.Viewer);
alter user role RegularUser remove module roles (MyModule.Viewer);
-- Remove user role
drop user role RegularUser;
-- Set security level
alter project security level off;
alter project security level prototype;
alter project security level production;
-- Enable/disable demo users
alter project security demo users on;
alter project security demo users off;
-- Create demo user (auto-detects entity that generalizes System.User)
create demo user 'demo_admin' password 'Admin123!' (Administrator, SuperAdmin);
-- Create demo user with explicit entity
create demo user 'demo_admin' password 'Admin123!' entity Administration.Account (Administrator, SuperAdmin);
-- Remove demo user
drop demo user 'demo_admin';
The ENTITY clause specifies which entity (generalizing System.User) to use. If omitted, it auto-detects the unique System.User subtype in the project. If multiple subtypes exist, you must specify ENTITY explicitly.
</syntax_reference>
<starlark_lint_rule_apis>
Security data is available in Starlark lint rules (.star files):
| Function | Returns | Description |
|---|---|---|
permissions() | list of permission | All permissions across all element types |
permissions_for(qn) | list of permission | Permissions for a specific entity |
user_roles() | list of user_role | User roles with module role assignments |
module_roles() | list of module_role | Distinct module roles |
role_mappings() | list of role_mapping | User role → module role mappings |
project_security() | struct or None | Security level, guest access, password policy |
See write-lint-rules.md for object property details.
</starlark_lint_rule_apis>
<common_workflow> A typical security setup follows this order:
-- 1. Create module roles
create module role Shop.User description 'Regular user access';
create module role Shop.Admin description 'Administrative access';
create module role Shop.Viewer description 'Read-only access';
-- 2. Grant entity access
grant Shop.Admin on Shop.Customer (create, delete, read *, write *);
grant Shop.User on Shop.Customer (read (Name, Email), write (Email));
grant Shop.Viewer on Shop.Customer (read *);
-- 3. Grant microflow access
grant execute on microflow Shop.ACT_Customer_Create to Shop.User, Shop.Admin;
grant execute on microflow Shop.ACT_Customer_Delete to Shop.Admin;
-- 4. Grant page access
grant view on page Shop.Customer_Overview to Shop.User, Shop.Admin, Shop.Viewer;
grant view on page Shop.Customer_Edit to Shop.User, Shop.Admin;
-- 5. Create user roles (project-level)
create user role AppUser (Shop.User);
create user role AppAdmin (Shop.Admin) manage all roles;
-- 6. Verify
show security matrix in Shop;
describe user role AppAdmin;
</common_workflow>
<common_mistakes>
create module must come firstModule.Role format in GRANT/REVOKEread * for all members or read (Attr1, Attr2) for specific ones
</common_mistakes>~/.mxcli/mxbuild/*/modeler/mx check app.mpr
</validation>
<output_rules>Output MDL code only in code blocks. Keep explanations concise.</output_rules>