4D Blog

Home Product Permissions: Inspect Session Privileges for Easy Debugging

Permissions: Inspect Session Privileges for Easy Debugging

July 19, 2024

Product

Today, you can benefit from a powerful feature to filter access to data, which is essential for preventing malicious access to your application.

This feature uses privileges that allow certain actions on your data. These privileges are assigned to users through roles and stored in the Session during authentication.

In 4D 20 R6, we enhanced this functionality by allowing you to inspect the privileges in the Session, which is very helpful for debugging.

Keep reading to learn more.

HDI_GetPrivileges

a New getPrivileges() function on the Session object

Let’s look at an example.

In the roles.json file, we have the medium privilege containing the simple privilege. The Medium role contains the medium privilege.

{
 "privileges": [
  {
   "privilege": "simple",
   "includes": []
  },
  {
   "privilege": "medium",
   "includes": [
     "simple"
    ]
  }
 ],
 "roles": [
  {
   "role": "Medium",
   "privileges": [
    "medium"
   ]
  }
 ],
 "permissions": {
  "allowed": [] // Set up the allowed actions here
 }
}

In the Datastore class, there is an authentify() function that assigns all the privileges of the given role to the Session.

exposed Function authentify($role : Text) : Text
	
	Session.clearPrivileges()
	Session.setPrivileges({roles: $role})
	
	return "Authentication done with "+$role

In the Datastore class, a getPrivileges() function has also been implemented. It returns the privileges in the Session.

exposed Function getPrivileges() : Collection
	return Session.getPrivileges()

If the authentify() function is called with the Medium role, the getPrivileges() function returns:

[
"simple",
"medium"
]

New /$info/privileges RESt API

There is also a new REST API to get the privileges in the Session. Calling /$info/privileges in the example above also returns:

{
 "privileges": [
  {
  "privilege": "simple"
  },
  {
  "privilege": "medium"
  }
 ]
}

This makes debugging easier. Check the documentation to learn more.

Discuss

Tags 20 R6, 21, Programming, REST, REST server, Security, Session

Latest related posts

  • December 3, 2025

    Give AI to a 30 years old 4D application

  • November 28, 2025

    ORDA – Handle an event-driven logic during database operations

  • November 27, 2025

    ORDA – Permissions – Restrict / allow web access to the resources in one click

Avatar
Marie-Sophie Landrieu-Yvert
- Product Owner - Marie-Sophie Landrieu-Yvert joined the 4D Product team as a Product Owner in 2017. In this role, she is responsible for writing user stories and translating them into functional specifications. She also ensures that the delivered feature implementation meets the customer's needs. Marie-Sophie graduated from the engineering school ESIGELEC and began her career as an engineer at IBM in 1995. She took part in various projects (maintenance and development projects) and worked as a COBOL developer. She then moved on to work as a UML designer and Java developer. More recently, her main responsibilities included analyzing and writing functional requirements, and coordinating business and development teams.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy