Homepage

Associating an Authorization Policy with a Page

Last edit: Jul 14, 2023

This guide will help you associate an Authorization Policy with a page.

Similarly to form (visit Associating an Authorization Policy with Form, you can also associate a policy with a page.

Requirements

So that you can follow the steps in this tutorial, you should understand the concept of Authorization Policy, and you should have created a page and an Authorization Policy.

Steps

Associating an Authorization Policy with a page is a two-step process:

Step 1: Edit page configuration

Create a custom page that you only want users with the first name John to be able to access:

app/views/pages/john-private-page.liquid
<h1>Hello John!</h1>

Step 2: Add authorization_policies key to page configuration

Add the authorization_policies key to page configuration and specify the Authorization Policy for the page:

app/views/pages/john-private-page.liquid
---
authorization_policies:
  - only_allowed_by_johns
---
<h1>Hello John!</h1>

Next steps

Congratulations! You know how to associate an Authorization Policy with a page. Now you can learn about handling violated Authorization Policies:

Questions?

We are always happy to help with any questions you may have.

contact us