96
Views
7
Comments
Best practice for authorization in accessing a screen

Hi!

I have a screen where I need to check a role (ex.: Manager) and a department (ex.: Logistics).
The Role is created in the roles logic. The department is in a custom aggregate that was created.

What is developed now:

I am using a data action to know if the user has the right department, and the rest of the aggregates are fetching only after this validation.
Is this the best practice? Is there a better solution? I am worried about performance issues.
With traditional this validation was made in the preparation, in reactive I don't know where should I do this.

Thank you in advance,
Best Regards,
Diogo

2022-05-05 14-37-30
Mika Grootenboer

Hi @Diogo Luciano,

I think this is fine performance wise.

I would also use a data action with a server action that checks for the right department (to keep the check the same over the entire application). 

If you are worried about performance you can always change it around a little.

1. fetch the aggregates on start.

2. have the containers containing the data of the aggregates not visible until the data action is fetched.

3. if the data is fetched set the visibility of the container to true or if the user does not have the rights redirect the user to another page (invalid permissions page).


Hope this helps


UserImage.jpg
Diogo Luciano

Hi Mika!

Thanks for your advice!
The containers are a good advice, I will test it out!

Best Regards,
Diogo

2024-10-12 12-11-20
Kerollos Adel
Champion

hallo @Diogo Luciano ,

To improve data security and user experience, a good approach would be to fetch all the necessary data in a server-side action or service and then return both the data and the user's permission levels. Initially, you can hide the page details and only change the visibility of elements after the data is fetched, based on the user's permissions. This method helps keep sensitive data secure, as it prevents unauthorized users from accessing or manipulating it.

If you're concerned about users attempting to manipulate the HTML to reveal unauthorized sections, it's worth noting that OutSystems doesn't render invisible containers on the client side, which adds an extra layer of security. Even if a user tries to inject scripts or modify the page, they won't be able to access or see content that they're not authorized for.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Kerollos Adel ,

First a quick check : are you aware that several of your replies today are to old posts ?

Now about the content of your reply, if data is sensitive, you shouldn't even retrieve it.  Just not showing it in the DOM doesn't wipe it from the network tab.

Most secure is to add validation on the user's role on server side and not return data unless user has rights.

2024-10-12 12-11-20
Kerollos Adel
Champion

Totally agree 

what if is not about data ,  it about buttons with actions or links user not authorized to view it ?  

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Same thing, just hiding them is not enough, the server side should still check user role before executing a protected action.

2024-10-12 12-11-20
Kerollos Adel
Champion

It's essential to implement server-side validation for every action to prevent any security issues. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.