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

Add Security to the SAP SuccessFactors Extension

In this phase of the development you will add authentication and authorization to the extension.

Overview

🎓 beginner 10 min. SAP Cloud Application Programming ModelBeginnerSAP BTP Cloud Foundry Environment

You will learn

  • โœ”How to require user authentication in your CAP service
  • โœ”How to define authorization to access the service entities
  • โœ”How to setup the XSUAA service instance for future deployment
  • โœ”How to add required dependencies to the CAP project to handle application security
Unknown U Unknown November 1, 2022
Created by September 28, 2022
Contributors

Prerequisites

Steps

Step 1 Set service to require authentication
โ€”

So far, you have been working on a local project which only developers would have access to. Therefore, it’s OK to leave your service “unprotected” as it’s not yet publicly available. But, as soon as you deploy it to the cloud, it will be available to anyone who knows the service endpoint (which is not quite difficult).

In such scenario, anyone can access the service anonymously and freely make OData calls to it, which will probably cause a big mess in your application and related data. So, it’s imperative to “protect” your service against such risky situation by granting access only to authenticated users.

Then, to make the service available only to authenticated users, you just need to add the requires annotation to the service definition (in the projman-service.cds file), like demonstrated below:

Figure 1 โ€“ Annotation for requiring the user to be authenticated
Figure 1 โ€“ Annotation for requiring the user to be authenticated

Now, in the service home page, when you click on any entity link (i.e. SFSF_User) a pop-up in the browser will ask for the username and password.

Figure 2 โ€“ Login pop-up for mocked authentication
Figure 2 โ€“ Login pop-up for mocked authentication

As you are still in development you can provide whatever information you like and click sign in, because in this environment CAP is using what we call mocked authentication which does not utilize real users. So, after clicking sign in, you may see the data from the selected entity:

Figure 3 โ€“ Data retrieved after sign in
Figure 3 โ€“ Data retrieved after sign in

Step 2 Set authorization for service entities access
+
Step 3 Setup XSUAA
+
Step 4 Add required dependencies
+
Step 5 Check your knowledge
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 5
1. Set service to require authentication 2. Set authorization for service entities access 3. Setup XSUAA 4. Add required dependencies 5. Check your knowledge

Learn more →