SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Use mocking to embrace auth in your domain model from the outset

With the mocked authentication strategy, we can embrace and work on the important aspect of securing our app or service right from the very start. CAP makes it easy to do the right things here.

Overview

🎓 beginner 15 min. SAP Cloud Application Programming ModelSAP Business Technology PlatformCloudBeginner

You will learn

  • What the mocked authentication strategy is and how to use it
DJ Adams D DJ Adams August 3, 2026
Created by July 30, 2026
Contributors

Prerequisites

Prerequisites

You will need a development environment for CAP Node.js. See the tutorial Set up a self-contained development environment for CAP Node.js The assumptions in this tutorial are based on option 1 or option 2 in that tutorial, in that you have a VS Code (or GitHub Codespace) environment based on the foundation repository used in the setup described there, which also means that your starting directory will be /workspaces/cap-nodejs-dev-env. If you have your own CAP Node.js development environment setup, then please make the appropriate adjustments where necessary.

Steps

Intro

The CAP framework offers various auth strategies, including ones that support JWT, XSUAA and IAS based solutions. It also offers the mock strategy where Basic Authentication is used in combination with a simple list of pre-defined users and roles, which you can add to to suit your domain and authentication & authorization modeling.


Step 1 Set up a simple Northwind-based service

The OData Deep Dive mission is based around a cut-down version of the classic Northwind service called “Northbreeze”. That service is available in the repository https://github.com/SAP-samples/odata-dd-server and is a good basis for our exploration of the mocked authentication strategy in this tutorial.

👉 Clone the repository:

Shell
git clone https://github.com/SAP-samples/odata-dd-server

👉 Now open the northbreeze/ directory within the cloned repository in a new VS Code / Codespace window:

Shell
code odata-dd-server/northbreeze/

This should present just the Northbreeze project in the Explorer, at the root. Use the CAP Project Explorer feature to get a feel for the project’s service and entity definitions (you may need to use the Refresh button, in the form of a circular arrow, to get the explorer to re-read the project configuration):

using the CAP Project Explorer
using the CAP Project Explorer

Step 2 Examine the service context
+
Step 3 Explore the service as-is
+
Step 4 Introduce an authentication requirement
+
Step 5 Retry the requests with authentication
+
Step 6 Apply more granular authorization restrictions
+
Step 7 Retry the DELETE request
+
Step 8 Retry the GET request
+
Step 9 Include an explicit privilege block for read operations
+
Step 10 Add the required role to the user
+
Step 11 Retry the DELETE request once again
+
Step 12 Wrap-up and further info
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 12
1. Set up a simple Northwind-based service 2. Examine the service context 3. Explore the service as-is 4. Introduce an authentication requirement 5. Retry the requests with authentication 6. Apply more granular authorization restrictions 7. Retry the DELETE request 8. Retry the GET request 9. Include an explicit privilege block for read operations 10. Add the required role to the user 11. Retry the DELETE request once again 12. Wrap-up and further info

Learn more →