The authorization rules that secure your application’s backend often have implications for the frontend user interface (UI) as well. For example, if a user does not have access to a specific page the UI should hide that link. Similarly, if a user can only read a resource, the UI may gray out an edit button. This guide covers the best practices for implementing frontend (UI) authorization with Oso Cloud.Documentation Index
Fetch the complete documentation index at: https://www.osohq.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Keep Enforcement in the Backend
The first rule of frontend authorization: keep the user interface in charge of presentation and the backend service in charge of enforcement. Because the end user has total control over code that runs in their browser, you can never trust requests from the UI. The user might represent as an administrator who should have unfettered access to your entire application. But thebackend service should request an authorization decision from Oso Cloud to confirm what they are permitted to do.Expose Permissions to the Frontend
UIs ask a single authorization question over and over: what actions can the current user perform on resources rendered on the current page? If the user can view an organization but does not have permission to edit or delete it, the user interface should not renderEdit or Delete buttons.
The general pattern for a backend service responding to an user interface request:
- Ask Oso Cloud via the Authorize API: is the user authorized to access the resource?
- If they have access, what actions can the user take on the resource?
- Return the permissions along with the response payload so that your UI can render the approriate experience based on what the user can and cannot do.
Create new repository button if the current user has the
"create_repositories" permission on the organization.