#Permissioning
Permissioning decides which Adaptable features a user sees. It works on two levels:
- modules — which feature modules are available in the app at all (a design time choice, the same for every user);
- user permissions — what the current user may do with the available modules, based on roles and permissions.
Permissions only change what the UI offers. They do not affect how state is evaluated, and API calls are not checked.
#Choosing the modules
By default every module is available. Use the modules prop of the
Adaptable.Provider to narrow that down — either list the module objects to
register:
<script setup lang="ts">
import { Adaptable, type AdaptableProps } from '@adaptabletools/datagrid-vue';
import {
viewModule,
themeModule,
exportModule,
} from '@adaptabletools/datagrid-vue/modules';
import type { Developer } from '../getting-started/basic.data';
declare const props: AdaptableProps<Developer>;
const modules = [viewModule, themeModule, exportModule];
</script>
<template>
<Adaptable.Provider v-bind="props" :modules="modules">
<Adaptable.Workspace />
</Adaptable.Provider>
</template>or filter the built-in catalog by module id, with include (only these) or
exclude (everything but these):
<Adaptable.Provider
v-bind="props"
:modules="{ include: ['theme', 'calculatedColumn', 'styledCell'] }"
/>
<Adaptable.Provider v-bind="props" :modules="{ exclude: ['flashingCell', 'styledCell'] }" />The module ids are alert, calculatedColumn, cellNote, cell-summary, contextMenu,
customSort, dashboard, export, flashingCell, namedQuery,
quickSearch, settingsPanel, styledCell, theme, view, grid, state
and config.
A module that is not available contributes no dashboard widget, no column menu
items and no context menu items. You can give the Provider a new modules
value at any time, and the UI follows.
The quickSearch, styledCell and flashingCell modules are excluded. The top
dashboard lists four widgets but shows only the view and theme ones, and the
column menus have no Add Styled Cell or Add Flashing Cell items.
Module availability always wins over user permissions: a user with permissions for an excluded module still doesn't see it.
#User permissions
Pass the current user via the userInfo prop — an object, or a function that
returns one:
type UserInformation = {
userId: string;
userName: string;
auth?: {
// roles, or a function returning roles
roles?: string[] | ((context: AuthContext) => string[]);
// permissions (also negated ones, like '!styledCell_delete'), or a function returning them
permissions?: string[] | ((context: AuthContext) => string[]);
// optional — has the final say on every permission check
checkPermission?: (context: CheckPermissionContext) => boolean;
};
};Without userInfo.auth, the user has every permission of the available
modules. As soon as you provide auth, the user has only the permissions
granted by its roles and permissions.
<Adaptable.Provider
v-bind="props"
:userInfo="{
userId: 'jdoe',
userName: 'John Doe',
auth: {
roles: ['exportViewer'],
permissions: ['styledCell_create'],
},
}"
>
<Adaptable.UI />
</Adaptable.Provider>A module that defines permissions is only available to a user who has at least
one of them. Modules without permissions (such as view, theme or
quickSearch) are always available.
The user has the exportViewer role and the styledCell_create permission. The
export widget lets them pick and run a report, without the edit, delete and new
buttons. The styled cells widget is shown and the column menus offer Add
Styled Cell; the flashing cells widget and Add Flashing Cell are hidden,
because the user has no flashing cell permissions.
#Available permissions
| Module | Permissions |
|---|---|
| Alert | alert_create, alert_delete, alert_edit, alert_add_to_view, alert_remove_from_view |
| Cell Note | cellNote_view, cellNote_create, cellNote_edit, cellNote_delete, cellNote_admin |
| Calculated Column | calculatedColumn_create, calculatedColumn_delete, calculatedColumn_edit, calculatedColumn_add_to_view, calculatedColumn_remove_from_view |
| Export | export_create, export_delete, export_edit, export_run |
| Flashing Cell | flashingCell_create, flashingCell_delete, flashingCell_edit, flashingCell_add_to_view, flashingCell_remove_from_view |
| Named Query | namedQuery_create, namedQuery_edit, namedQuery_delete |
| Styled Cell | styledCell_create, styledCell_delete, styledCell_edit, styledCell_add_to_view, styledCell_remove_from_view |
The other modules don't define permissions.
#Available roles
A role is a named set of permissions, granted together.
| Role | Permissions |
|---|---|
alertAdmin | all alert permissions |
cellNoteViewer | cellNote_view |
cellNoteAdmin | all cell note permissions |
calculatedColumnViewer | calculatedColumn_add_to_view, calculatedColumn_remove_from_view |
calculatedColumnAdmin | all calculated column permissions |
exportViewer | export_run |
exportAdmin | all export permissions |
flashingCellViewer | flashingCell_add_to_view, flashingCell_remove_from_view |
flashingCellAdmin | all flashing cell permissions |
namedQueryAdmin | all named query permissions |
styledCellViewer | styledCell_add_to_view, styledCell_remove_from_view |
styledCellAdmin | all styled cell permissions |
#Custom roles
Define your own roles — or redefine the built-in ones — with the authRoles
prop, a map of role name to permissions:
<Adaptable.Provider
:authRoles="{
calculatedColumnEditor: ['calculatedColumn_edit'],
}"
:userInfo="{
userId: 'jdoe',
userName: 'John Doe',
auth: {
roles: ['calculatedColumnEditor'],
},
}"
v-bind="props"
/>#Negated permissions
Prefix a permission with ! to take it away from what the roles grant. This
user has every styled cell permission except deleting:
auth: {
roles: ['styledCellAdmin'],
permissions: ['!styledCell_delete'],
},#How a permission is checked
Every check goes through three levels, the later ones overriding the earlier:
- Roles and permissions from
userInfo.auth(or everything, withoutauth). - Object flags — Adaptable objects in state (styled cells, flashing cells,
reports, views, …) accept
permissions: { editable, deletable }. When a check is made for a specific object and the flag is set, the flag decides its_editor_deletepermission, whatever the user's roles. checkPermission— when provided, it's called for every check with the result of the first two levels asdefaultPermissionCheckResult, and its return value is final.
const userInfo: AdaptableProps['userInfo'] = {
userId: 'jdoe',
userName: 'John Doe',
auth: {
roles: ['calculatedColumnAdmin'],
checkPermission: (context) => {
if (context.permission === 'calculatedColumn_delete') {
return isAllowedToDelete(context.userId);
}
return context.defaultPermissionCheckResult;
},
},
};The checkPermission context carries permission, defaultPermissionCheckResult,
userId, userName, userPermissions (the resolved permission list),
adaptableObject (when the check is about a specific object), adaptableId and
adaptableApi. The roles and permissions functions receive userId,
userName, adaptableId and adaptableApi.
#Where permissions apply
These parts of the UI check permissions today:
- Dashboard — module widgets are hidden when their module is not available to the user (see Dashboard).
- Column menu — Add Styled Cell needs
styledCell_create, Add Flashing Cell needsflashingCell_create, Edit Calculated Column needscalculatedColumn_edit. - Export — running a report (from the export widget or the context menu)
needs
export_run; the export widget's edit, delete and new buttons needexport_edit,export_deleteandexport_create. - Context menu — module items only appear for available modules (see Context Menu).
The settings panel pages don't check modules or user permissions yet — every
page is shown to every user.