Introducing a new way to review your PRs.

Read the announcement

frappe / insights

Open Source Business Intelligence Tool

View on GitHub

25 documents · Updated Nov 23, 2026

docs / authorization-and-users

Authorization and user administration

Insights combines Frappe identity with Insights roles, team access, visibility, and sharing rules to decide who can use the app and which analytical resources they can reach. The backend is the final authority. The client uses session state to present the right settings and user actions, while user APIs support sharing, profile updates, and invitations. For the wider access model, see Access and collaboration.

Authorization model

The authorization model has two layers. An Insights role grants entry to the Builder and its protected API methods. Resource rules then limit access to data and analytical assets for non-admin users. The main roles are Insights User and Insights Admin; Administrator and users with the System Manager role have admin-level access. A user may still read a shared or visible analytical asset without an Insights role, but editing requires both document write access and an Insights role. insights/permissions.py• L37-38 insights/permissions.py• L1597-1609 insights/…/insights_team.py• L196-199

The insights_whitelist decorator is the normal boundary for callable backend methods. It exposes a method through Frappe and checks the required role before the method runs. Admin users can pass the default user check, while methods that manage teams or send invitations require Insights Admin. The separate check_permission decorator delegates a document permission check to Frappe. insights/decorators.py• L13-46 insights/decorators.py• L142-167

The client uses related checks for authoring actions. Write access requires document permission, an Insights role, and a workbook that is not read-only. Standard content can be copied instead of edited. Sharing is a separate capability even though workbook-member sharing currently follows write access. insights/permissions.py• L1553-1595

Session authorization

The session is the client’s shared view of the current identity. It starts with cookie values, then asks insights.api.get_user_info for role and site information. isLoggedIn means that the session has a non-guest email. isAuthorized means that the user is an Insights user or admin. These values guide access-aware client behavior, but they do not replace backend checks. frontend/…/session.ts• L35-70 insights/…/__init__.py• L29-61

The session also carries product-wide limits that affect the user experience. For example, admins can download data regardless of the site download setting, while other users receive the site setting as can_download. Login and logout reset the local session and reload the app so that the new server state becomes active. insights/…/__init__.py• L47-60 frontend/…/session.ts• L72-88

References: frontend/…/session.ts• L35-88 insights/…/__init__.py• L29-61 insights/permissions.py• L1510-1541 insights/permissions.py• L1553-1609

Resource permissions

Resource permissions govern the data sources, tables, teams, workbooks, queries, charts, dashboards, and alerts that a user may read or change. With team permissions off, the team-based data resources are available to Insights users. With team permissions on, a non-admin user reaches data through team membership and the resources assigned to those teams. A user who belongs to no team receives no team-based resource grant. Admin users bypass these resource limits. insights/permissions.py• L65-85 insights/permissions.py• L284-393 insights/permissions.py• L850-871

Ownership and sharing form the second access path for analytical assets. A user can access an owned workbook or an asset shared with the user or everyone. Related assets can inherit access through their workbook or dashboard. Queries can also be reached through permitted charts, including queries used at deeper levels of a query pipeline. Alerts depend on access to their query. This lets a shared analytical view work without exposing every underlying record in the site. insights/permissions.py• L184-228 insights/permissions.py• L609-764 insights/permissions.py• L772-848

Visibility is a read-only audience rule for charts and dashboards. Private limits access to other grants, Roles names selected roles, Everyone permits signed-in users, and Public permits guests. A role audience cannot name All, Guest, or Administrator; those audiences use the wider visibility levels instead. Widening visibility requires share permission because it gives access to people who have no other grant. insights/permissions.py• L99-165 insights/permissions.py• L451-496 insights/permissions.py• L944-996

Links between analytical assets can grant access, so the backend checks them at the point where they are added or used. A chart cannot be pointed to a query that its author cannot read. A dashboard cannot include a chart that the caller cannot read or that belongs to another workbook. A referenced query is also checked for the identity that runs the content, including unattended runs. These checks stop a permitted workbook, chart, or dashboard from widening access to a hidden query or chart. insights/permissions.py• L874-942 insights/permissions.py• L1263-1293

The backend applies these rules both to lists and to individual document actions. A list query removes records outside the user’s allowed set. A document check then confirms the requested action, with write access used for actions that are not read or share operations. New analytical assets linked to a workbook use the workbook’s access as their starting point. insights/permissions.py• L308-393 insights/permissions.py• L403-449

Data access checks

Data access checks protect direct use of a source or table. A table may also carry row or value restrictions from its team permissions. Public rendering can use an explicit public-access path, but normal users still pass the same source and table checks before query work proceeds. insights/…/insights_team.py• L241-309

The permission setting is therefore a site-wide switch, not a user preference. The client exposes it in the Permissions settings with a separate option for applying the host site’s own user permissions to site data. Download access is also split between a site-level setting and export permission on the query. frontend/…/PermissionsSettings.vue• L81-104

Visibility of a chart does not by itself grant its underlying rows. A guest receives the saved chart only. A reader may get more data when the chart runs with that reader’s permissions, while a chart that runs as its owner requires the owner or an admin to authorize that behavior. File export requires both site-level download access and permission to read the chart’s rows. insights/permissions.py• L1305-1344 insights/permissions.py• L1509-1550 insights/permissions.py• L999-1119

References: insights/permissions.py• L56-194 insights/permissions.py• L196-430 insights/permissions.py• L433-489 insights/permissions.py• L609-848 insights/permissions.py• L1305-1344 insights/permissions.py• L1509-1550 insights/…/insights_team.py• L241-309 insights/…/insights_settings.json• L136-159 frontend/…/PermissionsSettings.vue• L81-104

Published content

Published charts and dashboards can widen the audience for stored content. A public chart runs as its owner so a guest can see rows, and a public dashboard may publish every chart on it. Only the chart owner or an admin may publish owner rows. The share flow also reports when a dashboard makes a chart public in practice. insights/permissions.py• L999-1191 insights/permissions.py• L1194-1236

Trusted code is a separate elevated permission. Scripts, SQL-running expressions, and stored procedure calls can bypass normal data restrictions, so only an Insights Admin may add or change them. Existing trusted code can continue to run, but new or changed trusted code is checked on save, import, copy, and execution. insights/permissions.py• L1612-1669

References: insights/permissions.py• L999-1050 insights/permissions.py• L1062-1119 insights/permissions.py• L1168-1236 insights/permissions.py• L1612-1669

The following flow shows how role access and resource access combine before a protected operation can continue.

flowchart TD
    A[Request or client action] --> B{Insights role or allowed reader?}
    B -- No --> C[Permission error]
    B -- Yes --> D{Resource rule applies?}
    D -- No --> E[Continue]
    D -- Yes --> F{Owner, share, visibility, team, or linked access?}
    F -- No --> C
    F -- Yes --> G{Rows or export requested?}
    G -- No --> E
    G -- Yes --> H{Row and download checks pass?}
    H -- No --> C
    H -- Yes --> E

References: insights/permissions.py• L284-393 insights/permissions.py• L451-496 insights/permissions.py• L609-764 insights/permissions.py• L1305-1344 insights/permissions.py• L1509-1550 insights/permissions.py• L1597-1609

User directory

The user API provides a small directory for sharing and administration. It returns only identity and status fields from the set of enabled users who have an Insights role. The same Insights-user cohort supports both picker results and share validation, so a user offered by the client can also be accepted when a share is saved. A name or email search narrows that set. The API marks each result as an Insights user or admin. insights/permissions.py• L168-181 insights/…/user.py• L16-18 insights/…/user.py• L32-67

The directory has a privacy control for sites where users can sign up openly. When disable_user_lookup is on, a normal user sees only their own profile. Sharing can still name an email address directly, but the backend accepts only a real Insights user or Administrator. Admins retain the full directory so they can manage users. The default remains lookup enabled when the setting has never been saved. insights/permissions.py• L258-281 insights/…/user.py• L21-43 insights/…/insights_settings.json• L136-153

The client keeps the directory in a shared user store. It loads the roster for lists and selectors, merges search results into the known users, and provides names and images to sharing and team dialogs. The Users settings page and the standalone Users page present the same core roster, with status and activity information suited to each view. frontend/…/users.ts• L17-54 frontend/…/UsersSettings.vue• L11-24 frontend/…/UserList.vue• L11-24

User administration

User administration covers invitations and profile names rather than role assignment. An admin can submit one or more email addresses. The backend validates them, avoids duplicate pending or accepted invitations, and creates an invitation record that sends a link. insights/…/user.py• L242-267 frontend/…/users.ts• L56-77

An invitation expires after one day. A valid recipient accepts it without an existing session. Acceptance creates the Frappe user when needed, grants the Insights User role, marks the invitation accepted, and logs the recipient into Insights. Pending and expired invitations appear in the admin directory so an administrator can see the state of access that is still in progress. insights/…/insights_user_invitation.py• L8-26 insights/…/insights_user_invitation.py• L29-59 insights/…/insights_user_invitation.py• L67-98 insights/…/user.py• L69-96

Users can update their first and last names. A user can update only their own profile, while an admin can update another user’s profile. Email and password are not changed by this API. insights/…/user.py• L269-282 frontend/…/ProfileSettings.vue• L7-29

References: insights/permissions.py• L168-181 insights/permissions.py• L258-281 insights/…/user.py• L16-96 insights/…/user.py• L242-282 insights/…/insights_user_invitation.py• L29-98 frontend/…/users.ts• L17-107 frontend/…/UsersSettings.vue• L26-142 frontend/…/ProfileSettings.vue• L7-29

Permission settings

Permission settings give admins one place to turn on team-based restrictions and manage the related user-facing controls. The settings dialog separates account profile work from organization controls. Users and Permissions are organization views. Only admins receive controls that create invitations, create teams, or delete teams. frontend/…/Settings.vue• L8-46 frontend/…/UsersSettings.vue• L79-94 frontend/…/PermissionsSettings.vue• L106-134

The main permission controls have distinct effects:

  • Enable permissions turns team-based limits on or off for data sources and tables.
  • Apply User Permissions applies roles and user permissions from the host site to site data.
  • Allow Data Download sets the site-level download gate. Non-admin users also need export permission on the query.
  • Disable User Lookup hides the shared user directory from normal users while preserving direct email sharing.

The settings resource holds these values as site-level configuration. The backend reads the values during authorization, so a client toggle changes policy only after the settings save reaches the server. frontend/…/settings.ts• L11-39 insights/…/insights_settings.json• L74-84 insights/permissions.py• L296-303 insights/permissions.py• L1509-1541

User and team administration

The Permissions view uses the team API to show teams and opens a management dialog for members and data access. A team is the bridge between users and source or table permissions. The built-in Admin team has all data access and identifies users who may manage teams, users, and admin settings. For the team data model and resource selection, see Teams and resource access. frontend/…/PermissionsSettings.vue• L16-20 frontend/…/ManageTeamDialog.vue• L109-190

The client updates these views after invitation, profile, or team changes. This keeps names, membership, and access choices aligned across user selectors and settings dialogs. The server still rechecks each action through the role and document permission boundaries. frontend/…/users.ts• L56-129 insights/…/user.py• L162-214

References: frontend/…/Settings.vue• L8-46 frontend/…/settings.ts• L11-39 frontend/…/PermissionsSettings.vue• L81-134 frontend/…/ManageTeamDialog.vue• L58-190 insights/…/insights_settings.json• L136-197 insights/permissions.py• L296-303 insights/permissions.py• L850-871

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the roles accepted by insights_whitelist, check_app_permission, session flags, and the Insights Settings DocType aligned.
  • Keep the shared Insights-user cohort aligned between directory results, sharing pickers, and share validation.
  • Preserve the invitation state contract between invitation records, get_users, and the client status labels.
  • Recheck both list query conditions and document checks when adding an Insights resource that must be protected.
  • When changing enable_permissions, review source access, table access, linked analytical assets, and the query path that uses those assets.
  • When changing download policy, preserve the combined site setting and query export permission rule.
  • When changing links between queries, charts, or dashboards, preserve the checks that stop a readable asset from granting access to an unreadable linked asset.
  • When changing team resource grants, preserve the empty-team case so users with no team do not receive an accidental grant.
  • When changing visibility or publication, review role audiences, guest access, dashboard-linked charts, and the run_as_owner row rule together.
  • When changing chart row or export access, preserve the distinction between seeing a saved chart and reading its underlying rows.
  • When changing trusted-code paths, preserve the Insights Admin check on save, import, copy, and execution.

Important failure modes

TriggerConsequenceGuard
A protected API method loses insights_whitelist or uses the wrong roleA caller can reach a method without the intended Insights role, or a valid user is blockedKeep the decorator role and check_app_permission role set consistent
Team permissions are enabled for a user with no team membershipThe user receives no team-based resource grant and cannot reach the affected sources or assetsTreat an empty team set as no access and add the user to an appropriate team
A user outside the Insights role cohort is added to the sharing rosterSharing can target an account that the backend rejects as an Insights userBuild both picker results and share validation from the same Insights user cohort
An invitation is accepted after its one-day lifetime or after prior acceptanceNo user access is granted and the recipient receives an invalid or duplicate invitation errorCheck invitation status and expiry before creating or assigning the user
User lookup is disabled but a client assumes the full roster is availableNormal users cannot resolve names in selectors even though direct email sharing still worksHandle the self-only roster and use email entry for sharing
A new protected doctype is omitted from permission query conditionsList views or document reads can bypass the intended resource policyAdd the doctype to the protected set and its permission path together
A chart or dashboard links to an asset that the caller cannot readThe link can expose a hidden query or chart through an otherwise permitted analytical assetValidate linked query and chart access when the link is written and when referenced content runs
A visible chart is treated as permission to read its rowsA guest or shared reader can receive data beyond the saved chartRun can_read_rows before drill, filter, breakdown, or export operations
A non-owner publishes a chart that runs as its ownerReaders can receive the owner’s rows without the owner’s approvalAllow owner-row publication only for the owner or an admin
A non-admin adds trusted code to a query, chart, or alertThe content can read outside normal data restrictionsCompare new trusted code with stored content and require Insights Admin

Key files

FileWhy to read it
insights/permissions.pyDefines the central role, ownership, sharing, visibility, team, linked-resource, row, export, publication, and user-cohort rules.
insights/decorators.pyDefines the backend role and document permission boundaries for callable methods.
insights/…/__init__.pyDefines the session information returned to the client.
insights/…/user.pyDefines the user directory, invitations, profile updates, and admin team endpoints.
insights/…/insights_user_invitation.pyDefines invitation expiry, acceptance, and user creation.
insights/…/insights_settings.jsonDefines the site-level controls that affect permissions, lookup, and downloads.
insights/…/insights_team.pyConnects team membership to source and table access checks.
frontend/…/session.tsHolds client session identity and authorization state.
frontend/…/users.tsShares the user directory and user administration actions across the client.
frontend/…/PermissionsSettings.vuePresents permission controls and team administration entry points.
frontend/…/UsersSettings.vuePresents the organization user list and invitation flow.
frontend/…/ProfileSettings.vuePresents the self-service profile update flow.
frontend/…/Settings.vueDefines where profile, users, and permissions fit in the settings experience.