CAP authorization: Why hiding a button does not protect the API
A factory request application needs a reviewer to act only within the assigned business responsibility, including the intended self-approval restriction.
START HERE · NO PRIOR TOPIC KNOWLEDGE NEEDED
What it is. Why it matters.
Authorization rules decide which users may call a service or act on records. CAP’s requires and restrict annotations express different permission conditions for those operations.
Completely new to SAP?
Manufacturers use SAP to connect work such as buying components, recording inventory, planning production, shipping equipment and accounting for costs. SAP S/4HANA is an enterprise resource planning system: it connects these activities through shared business data.
ABAP is SAP’s programming language for business applications. A program reads data, applies rules and produces a result. Start with the objects involved before investigating code.
A transaction code, or t-code, is a shortcut to a task in classic SAP GUI. Fiori apps provide another way to work. Names and screens depend on the product and release; you do not need a live system to learn the concepts in this guide.

Scope and source-review notes
Scope and evidence
Source review by FAST SAP SOLUTIONS® editorial. This badge describes our editorial review; it does not represent SAP certification or independent endorsement.
CAP Node.js declarative authorization and custom instance-bound operations; supported annotations and Java behavior require version-specific review.
Primary documentation reviewed on 14 November 2026 using readable full text and official indexed excerpts. Relevant full-text CAP authorization sections and indexed authentication guidance reviewed. Model and policy matrix were not compiled or penetration-tested; deployed claims, Java differences and custom handler behavior need runtime verification.
A MANUFACTURING EXAMPLE
Enforce manufacturing request approval responsibility
Separate reading and approving
Read the example values
- User role
- Order viewer
- READ operation
- Permitted by relevant rule
- Approve action
- Requires additional permission
- Review
- Service and entity rules
Words you’ll meet in this guide
- Program
- A set of instructions executed by a computer.
- Class
- A reusable unit that groups data with operations called methods.
- Database
- Organized information kept beyond one program execution.
- Internal table
- A list of rows held temporarily in an ABAP program’s memory.
- Key
- One or more fields used to identify or find a record.
- API
- A defined interface through which programs exchange data or request actions.
Preview the practical steps
SEE THE CONNECTION
See it in a simple example.
A small example to make the idea concrete.
Enforce manufacturing request approval responsibility
A factory request application needs a reviewer to act only within the assigned business responsibility, including the intended self-approval restriction.
Protect the service endpoint, then make the interface reflect that policy
A hidden or disabled button changes what one UI presents.
Scope and prerequisites
The worked model targets CAP Node.js instance-bound actions and generic service authorization.
Separate authentication, role access and instance policy
Authentication establishes a verified caller identity and claims.
Enforce manufacturing request approval responsibility
A factory request application needs a reviewer to act only within the assigned business responsibility, including the intended self-approval restriction.
Verify backend authorization with direct requests as well as the screen; hiding a button does not establish the API's access rule.
| Reader | Business question | Evidence to carry forward |
|---|---|---|
| SAP developers and application teams supporting manufacturers | Enforce manufacturing request approval responsibility | Verify backend authorization with direct requests as well as the screen; hiding a button does not establish the API's access rule. |
01 Protect the service endpoint, then make the interface reflect that policy
A hidden or disabled button changes what one UI presents. It does not prevent another client from calling the same CAP endpoint. Enforce role, operation and record-scope policy in the service, using @requires, @restrict and supported custom logic where needed. Then use presentation metadata to explain the allowed experience. [1]
Write the policy as concrete cases before writing annotations. “Reviewers can approve” is incomplete when they should approve only assigned requests and never their own submission. This tutorial builds that policy for a fictional request service and shows how an accidentally broad privilege can defeat an otherwise careful rule.
02 Scope and prerequisites
The worked model targets CAP Node.js instance-bound actions and generic service authorization. CAP Java and different runtime releases have distinct supported combinations and custom-event details. Record runtime/compiler versions, authentication strategy and identity claims. Use the installed authorization documentation rather than assuming every where expression is enforced on every resource kind.
You need controlled identities with known roles and attributes, plus a small dataset. Development mock users are useful fixtures but are not evidence of production token mapping. No authentication service, tenant or customer application was tested for this article. The sample needs the complete application's write controls, projections and handler paths reviewed before deployment.
03 Separate authentication, role access and instance policy
Authentication establishes a verified caller identity and claims. Authorization decides whether that caller may perform an operation or access a record. @requires is a coarse role restriction; @restrict can describe privileges including grant, role and supported instance conditions. Neither is the same as a frontend route guard. [1] [2]
The record predicate should use trusted request identity/attributes, not a body field supplied by the caller. A reviewer parameter reading alex cannot make an unauthenticated request become alex. In a multitenant service, tenant isolation is another boundary that must remain intact through the configured runtime and persistence context. Keep these layers explicit in the design worksheet.
04 Worked case: assigned review without self-approval
Requests 1001 and 1002 are assigned to alex. Request 1001 was submitted by dana; request 1002 by alex. Request 1003 is assigned to sam and submitted by dana. Alex has Viewer and Reviewer; pat has Viewer only. The intended policy allows alex to read assigned records, approve 1001, reject self-approval of 1002 and deny approval of 1003.
Pat should be able to read only pat's assigned records and cannot approve any request. An administrative role, if intentionally defined, needs its own explicit policy rather than an assumed bypass. These cases expose three independent dimensions: role, assignment and submitter. A single administrator happy-path test would exercise almost none of them.
| Caller / request | Assigned? | Self-submitted? | Expected approval |
|---|---|---|---|
| alex /1001 | Yes | No | Allowed if state valid |
| alex /1002 | Yes | Yes | Denied self-approval |
| alex /1003 | No | No | Denied scope |
| pat /own assigned | Yes | No | Denied without Reviewer |
| Anonymous /1001 | Unknown | Unknown | Authentication/authorization rejection |
05 Model narrow privileges and inspect runtime support
The sketch separates READ from the approve event. For supported Node.js instance-bound action restrictions, the where condition expresses assignment and non-self submission. Keep the action's own state transition validation in its handler; authorization answers who may attempt the operation, while state validation answers whether this record can currently transition.
Do not copy the same restriction object onto a service, entity and action without checking supported properties. The reviewed CAP table documents different combinations for those resources. Unsupported properties can be ignored, so an annotation that looks precise in source can provide less enforcement than a reviewer assumes. Compile, lint and test the actual endpoint. [1]
@requires: 'authenticated-user'
service ReviewService {
@restrict: [
{ grant: 'READ', to: 'Viewer',
where: (assignedTo = $user) },
{ grant: 'approve', to: 'Reviewer',
where: (assignedTo = $user and submittedBy != $user) }
]
entity Requests {
key ID : Integer;
assignedTo : String;
submittedBy : String;
status : String;
} actions {
action approve(reason : String(200)) returns Requests;
};
}06 Understand OR within privileges and checks across hierarchy
A request satisfies an entity restriction when an applicable privilege permits it under the documented combination rules. Matching privileges are alternatives. Adding a broad READ grant for Viewer alongside a scoped READ grant can therefore make the scoped grant ineffective for viewers. Do not read the array as a checklist where every row must pass. [1]
Service-level and entity-level restrictions also have hierarchy semantics; inspect those with the actual exposed projection and operation. A coarse authenticated-user service boundary does not supply the missing record predicate. Conversely, an entity rule cannot make an unauthenticated caller pass a required higher-level gate. Keep the policy small enough that reviewers can reason through its effective combinations.
07 The broad-grant mistake in concrete terms
Suppose someone adds {grant:'READ', to:'Viewer'} to fix a support complaint. Alex already has Viewer, so the new alternative permits READ without assignment filtering. The earlier assignedTo predicate remains visible in source but no longer limits those reads. A reviewer counting restrictive-looking annotations can miss this change.
Test the precise counterexample: alex reads request 1003 assigned to sam. If it becomes visible after the new grant, the policy widened. Decide whether that widening is intentional. If support needs a broader role, define and test that role explicitly instead of giving every viewer unrestricted access to resolve one user's issue.
| Privileges | alex reading 1003 | Reason |
|---|---|---|
| Scoped READ only | Denied/filtered | assignedTo does not match |
| Scoped READ plus broad Viewer READ | Permitted by broad alternative | Matching privileges are OR alternatives |
| Separate reviewed support role | Depends on explicit policy | Do not broaden Viewer implicitly |
08 Review custom handlers and alternate paths
Generic service authorization cannot repair arbitrary custom code that reads restricted persistence and returns it through another endpoint. Review custom actions, functions, remote calls, projections and low-level queries. Make sure the handler uses supported service context and explicitly checks policies that its chosen persistence path does not enforce.
For approve, derive the bound ID from the request context and compare the authenticated user to the assigned/submitted fields. Use a conditional update or appropriate concurrency design so a reassignment between read and write cannot invalidate the authorization assumption. Avoid returning another user's confidential fields in a rejection message. A denied operation should leave the protected business state unchanged.
09 Troubleshooting unexpected permits and denials
Capture the actual backend identity, roles, relevant attributes, operation and record key. Frontend role labels and a locally mocked test may differ from the deployed token context. Inspect effective service annotations and the handler path before changing policy.
| Observation | Question | Next evidence |
|---|---|---|
| Button hidden; direct call succeeds | Backend policy missing? | Endpoint test with same identity |
| Scope ignored despite where | Broad matching grant or unsupported resource property? | Effective privilege combinations |
| Works locally; denied deployed | Role/attribute mapping differs? | Verified runtime claims and binding |
| READ restricted; action unrestricted | Action-specific policy missing? | Bound event restrictions and handler |
| Other record leaks via custom function | Raw persistence bypass? | Custom query and response mapping |
| Authorized row rejected | Wrong identity/normalization/state? | Current user and authoritative record |
| Error exposes restricted details | Overinformative failure mapping? | Public message contract |
10 Test denials through the API, including direct-key access
Run the matrix through the public endpoint with each intended identity. Test collection reads and direct reads of 1003 as alex; a list filter alone is insufficient if direct-key access exposes the record. Test approve for 1001, self-submitted 1002 and sam-owned 1003. Verify the configured disclosure policy for denied versus nonexistent records.
Include requests with forged assignedTo/submittedBy fields, missing roles and changed assignment during processing. Verify protected fields cannot be changed through ordinary UPDATE unless explicitly permitted. After every denied action, read state with an authorized test identity to confirm no mutation occurred. These are proposed checks; a passing source annotation inspection alone is not a security test.
11 Keep UI availability and business state aligned
The interface should show available actions in a way users understand, but the service must still enforce them. A button can become unavailable because the user lacks permission, the record state changed or the data is stale. Present a meaningful response when a backend decision differs from the screen's earlier view.
Do not turn a state conflict into a permission change. If 1001 is already APPROVED, the Reviewer role does not authorize a second arbitrary transition. Keep concurrency and state rules in the operation and refresh the client from the authoritative result. This prevents frontend convenience from becoming the only line of defense against duplicate or invalid actions.
12 Frequently asked questions
Is @requires enough? It can express a coarse role gate. Record-specific policies and operation differences may need @restrict and supported custom checks.
Are multiple restrict entries all required? Matching privileges are alternatives under the documented rules. A broad grant can widen access despite a narrow neighbor.
Can I trust a UI role or supplied username? Use verified backend request identity and claims; client-supplied fields are input.
Does a successful admin test prove ordinary-user authorization? No. Use allowed and denied identities, direct keys, actions and alternate endpoints.
What belongs in the review record? Runtime/authentication versions, policy matrix, effective annotations, custom-query boundaries and actual positive/negative results. Keep permissions and business-state checks distinct so future changes do not accidentally weaken either.
Related services and next steps
Primary sources
Found this useful?
Share this guide with your network, or leave a like.
Your like is saved in this browser.