Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Xiao-fei_Song
Advisor
Advisor
In this blog post, we'll demonstrate how to add authorization and access control to CAP model using the CDS Graphical Modeler via the CAP annotation "@readonly" and "@insertonly".

Authorization and Access Control for CAP Model through the CAP Annotations


In Authorization and Access Control CAP authorization and access control through the CAP annotations have been introduced and there are some samples in detail about how to add authorization and access control to CAP entities and services. In this blog post, we will demonstrate how to add the CAP annotations using the annotation editor in CDS Graphical Modeler very conveniently so that the CAP developers don't need to remember the complex syntax of the CAP annotations terms. And in this blog post, we'll show you how to add access control to CAP entities via CAP annotation "@readonly" and "@insertonly" using the CDS Graphical Modeler.

For example, we have a CDS service model:


Open the service model using the CDS Graphical Modeler:


Select the "Suppliers" entity and click "Manage Annotation" context menu:



The annotation editor shows up:



As you can see, the entity and its properties can been seen in the annotation editor.

Now click "+" button for the entity "Suppliers" and in the drop down list you will see all the annotation terms that can be applied to this entity:


Select "readonly" from the list:


Press "Enter" key to confirm your selection:


Now click the "Update" button to close the dialog, and then check the CDS file you will see the "readonly" CAP annotation has been created for entity "Suppliers":


and you can do the same for entity "Territories" by using "insertonly" CAP annotation:





Conclusion


In this blog post, we have demonstrated how to add access control information to CAP entities via "@readonly" and "@insertonly" CAP annotations using the CDS Graphical Modeler.

References


Authorization and Access Control

https://marketplace.visualstudio.com/items?itemName=SAPSE.vscode-wing-cds-editor-vsc

https://blogs.sap.com/2022/04/29/an-introduction-to-cds-graphical-modeler-for-visual-studio-code/