
Role-Based Access Control – Launch Week #3

Overview of Morph's RBAC
One of the infrastructures provided by Morph for AI applications is user authentication along with role-based access restrictions. You can assign both team-level and project-level permissions to your invited team members.
In the following demo, the Python process is switched according to the roles set in the dashboard.
Team-Level Roles
Team-level roles determine what actions each user can perform on projects. The team-level permissions can be selected from a set of predefined roles:
- Admin: Has full permission for the team’s resources. Can edit other members’ access to projects.
- Developer: Can create, edit, and deploy projects.
- Contributor: Can deploy invited projects.
- Viewer: Can view invited projects.
Project-Level Roles
In addition to team-level roles, you can set project-level roles. These roles can be defined using any free-form string.
You can access to the user’s project role within a Python function as follows:
import pandas as pd
import morph
from morph import MorphGlobalContext
from morph_lib.types import HtmlResponse
import pygwalker as pyg
@morph.func
@morph.load_data("example_data")
def create_pygwalker_dashboard(context: MorphGlobalContext):
data = context.data["example_data"]
if "Admin" not in context.user_info["roles"]:
return HtmlResponse("You are not authorized to access this dashboard.")
return pyg.to_html(data)
By using the roles set in the dashboard, you can achieve granular access management. With Python, you can build detailed logic that enables complex conditional access controls—capabilities that traditional data tools or BI solutions simply do not have.
Furthermore, since this is implemented using built-in user authentication, Morph’s strength lies in the fact that you don’t have to develop a complex user authentication flow within your application just for internal apps!
Related Articles



