Skip to content

Permissions

meta-d edited this page Mar 22, 2024 · 1 revision

Permissions

What's permissions?

Permissions are the way to control the access to the resources of the system. It's a way to ensure that only the authorized users can access the resources they need.

There are two types of permissions: Frontend and Backend.

Frontend permissions

Frontend permissions are the permissions that are controlled by the frontend. They are used to control the access to the frontend resources, like pages, buttons, etc.

How to use frontend permissions?

We use package ngx-permissions to manage frontend permissions. This package helps you gain control of your routes, by using simple concepts for you to decide who can access them.

import { NgxPermissionsGuard } from 'ngx-permissions';

const appRoutes: Routes = [
  { path: 'home',
    component: HomeComponent,
    canActivate: [NgxPermissionsGuard],
    data: {
      permissions: {
        only: ['ADMIN', 'MODERATOR'],
        except: ['GUEST']
      }
    }
  },
];

You can access mgx-permission's wiki page to see more details.

You can also control element in the template using *ngxPermissionsOnly directive.

<div *ngxPermissionsOnly="['ADMIN', 'GUEST']">
    <div>You can see this text congrats</div>
</div>

Backend permissions

Backend permissions are the permissions that are controlled by the backend. They are used to control the access to the backend resources, like APIs, databases, etc.

How to use backend permissions?

todo

For Metad OCAP adopters

For Metad OCAP developers

Clone this wiki locally