glyphox
How-to guides · 14 of 15Roles and permissions

Documentation / How-to guides

Roles and permissions

Define roles in the model, decide who may open each page, call each action and use each table, and manage who holds each role in the Console.

Applies to Glyphox 1.0.10

Before you begin

  • A solution with a web or mobile module, for example the Acme Service Desk sample.

Permissions have two parts. What each role may do is part of the model: it is reviewed in a pull request and enforced by the exported application. Who holds each role is managed in the running application's Console, so membership changes without a deployment.

Step 1: Require sign-in

Open Module Settings → Security. Under Authentication, Require sign-in to use the app is selected for every new web and mobile module. The application then has a sign-in page, and its API refuses calls from anyone who is not signed in. The article Customise the Sign In page, in this section, describes how to change that page.

When the setting is cleared, anyone can open every page and call the API.

Step 2: Declare the roles

Under Roles on the same screen, select Add a role and name it, for example Manager or Clerk. In a module with no roles, every signed-in user may do everything.

Module Settings, Security: Require sign-in to use the app selected, Role for new sign-ups, the sign-in methods, and the roles manager and agent with Add a role
Module Settings → Security: authentication and roles.

Role for new sign-ups sets the role that an account created on the sign-in page receives. With None, a new user can open the application but nothing that requires a role, until an administrator grants one.

A role keeps its holders when you rename it, so a rename needs no change in the Console.

Step 3: Decide who may open each page

Every page requires sign-in when its module does. To leave one page open, such as a landing page, turn off Sign-in required in the page's Access section. This is the only exception a page can make to its module's setting.

To restrict a page to certain roles, select them under Accessible by in the page designer's Access section. With none selected, anyone signed in has access. For a page written as code, the page's Properties show its roles, and the Assistant can set them.

Step 4: Decide who may read and write each table

Open the table in its editor. The Access section has one rule for each operation: Read, Create, Update and Delete. Each rule is one of the following.

The Access section of the Ticket table: Read, Create, Update and Delete, each set to Module default (signed in)
The table editor's Access section, with one rule for each operation.
Module defaultAny signed-in user when the module requires sign-in, otherwise anyone.
AnyoneNo sign-in is required.
Any signed-in userEvery account that has signed in.
Only these roles…The holders of the roles you select.

The generated API enforces these rules on the server, so they apply to every caller and not only to the pages. A lookup table is read-only, so it has a Read rule only.

Public, at the top of the section, decides which modules and which addresses reach the table, not which people. The rules below it apply to a public table in the same way. The Problems view warns about a public table that anyone can read.

Step 5: Decide who may call each server action

Open a server action and set Who may call it in its properties, with the same four choices. The rule applies to calls over the API, including a published service operation that runs the action. A workflow, a trigger or another action of the same module runs the action directly and is not checked.

A client action runs in the browser, where a rule would protect nothing, so the field is offered for server actions only.

Step 6: Manage membership in the Console

Run or deploy the application and sign in to the Console at /console as the platform administrator. Users lists each person with a checkbox for each role, and a person may hold several roles. Invite a person creates an account with a one-time password that you hand over. No email is sent.

A granted role takes effect when the person's sign-in is next renewed. Removing a role signs the person out on every device within the lifetime of their access token, 15 minutes by default, and the Console asks for confirmation first.

Access lists every table, action and agent with the rule in force. It is read-only, because the rules belong to the model.

When people sign in through an identity provider, its groups can be mapped to roles under Security → Identity provider. The article Add an identity provider describes how to add one.

What a person sees when access is refused

A person who is not signed in and opens a page that requires sign-in is taken to the sign-in page, and returns to the page they asked for after signing in.

A signed-in person who holds none of the roles a page requires is taken to the application's Not allowed page. It reads "You don't have access to this page." and offers Sign out. With the standard error handling, a call that the server refuses, such as a server action restricted to another role, leads to the same page.

Not Allowed is a page of the web module, at /not-allowed. It is listed with the module's pages in the Solution tree, is open to everyone and is not in the menu, and you can edit it like any other page. Every new web module starts with this page and with the standard error handling that leads to it. The article Logic flows and actions, under Reference, describes that error handling and how to refuse a person from your own logic.

The platform administrator

The platform administrator manages the Console and holds none of the application's roles. On a run on your computer it is admin@local. To use the application as one of its roles, open Sign in as a role… on the application's sign-in page. These accounts are offered only on a local run.

Ask the Assistant

The Assistant and a connected coding agent set the same rules through their tools, for example a table's Delete rule for one role, and each change appears in the diff like any other.

If a step fails, see Troubleshoot the first run or contact support.