SAP

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

HANA Native, Add User Authentication to Your Application

Define security and enable user authentication and authorization.

Overview

🎓 beginner 15 min. SAP HANABeginnerExpress Edition

You will learn

  • How to create an instance of the User Authentication and Authorization service
  • How to incorporate security into the routing endpoint of your application
Thomas Jung T Thomas Jung November 1, 2022
Created on July 25, 2019
Contributors

More from Devtoberfest Planner

See all 227 tutorials by Devtoberfest Planner →

Prerequisites

Prerequisites

  • This tutorial is designed for SAP HANA on premise and SAP HANA, express edition. It is not designed for SAP HANA Cloud.
  • You have created a user interface.
  • You have administration access to the XS Advanced cockpit in SAP HANA (e.g., like user XSA_ADMIN in SAP HANA, express edition).

Steps

Intro

This tutorial can be completed in SAP HANA, express edition SPS04 or higher.


Step 1 Define the security model for your application

You will first define the different roles a user could have when using your application. As the developer of the application, you will define the roles. Then, an administrator would create the roles and assign them to the different users. In this tutorial, it is assumed you are the administrator of your instance so you will be performing this task, too.

Create a file called xs-security.json in the root folder of your application.

Add UAA
Add UAA

Paste the following content into the file and save it

JSON
{
	"xsappname": "myHanaApp",
  "tenant-mode": "dedicated",
	"scopes": [{
		"name": "$XSAPPNAME.Display",
		"description": "display"
	}, {
		"name": "$XSAPPNAME.Create",
		"description": "create"
	}, {
		"name": "$XSAPPNAME.Edit",
		"description": "edit"
	}, {
		"name": "$XSAPPNAME.Delete",
		"description": "delete"
	}, {
		"name": "xs_authorization.read",
		"description": "Read authorization information from UAA"
	}, {
		"name": "xs_authorization.write",
		"description": "Write authorization information to UAA"
	}],
	"attributes": [{
		"name": "country",
		"description": "country",
		"valueType": "s"
	}],
	"role-templates": [{
      "name": "Token_Exchange",
      "description": "UAA",
      "scope-references": [
        "uaa.user"
      ]
    },{
		"name": "Viewer",
		"description": "View all records",
		"scope-references": [
			"$XSAPPNAME.Display"
		],
		"attribute-references": [
			"country"
		]
	}, {
		"name": "Editor",
		"description": "Edit and Delete records",
		"scope-references": [
			"$XSAPPNAME.Create",
			"$XSAPPNAME.Edit",
			"$XSAPPNAME.Delete",
			"$XSAPPNAME.Display"
		]
	}]
}

Save the file.

Save xs-security file
Save xs-security file

Step 2 Create an instance of the UAA service
+
Step 3 Add UAA as a resource
+
Step 4 Modify routing
+
Step 5 Test the application
+

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. Define the security model for your application 2. Create an instance of the UAA service 3. Add UAA as a resource 4. Modify routing 5. Test the application