Homepage

Associating an Authorization Policy with Form

Last edit: Jul 14, 2023

This guide will help you associate an Authorization Policy with Form.

Requirements

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

Steps

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

Step 1: Create Form

Assuming you have a simple form that allows changing the user's last name, the configuration file can look like this:

---
name: update_last_name
resource: User
fields:
  last_name:
    validation:
      presence: {}
---
...

Step 2: Add authorization_policies key to Form

In order to associate the Authorization Policy with the form, add a new authorization_policies key, and then specify the array of policy names associated with this form.

To ensure that only Johns will be able to submit this form, update the configuration to include the policy:

---
name: update_last_name
resource: User
authorization_policies:
  - only_allowed_by_johns
...

Next steps

Congratulations! You know how to associate an Authorization Policy with Form. Now you can learn about associating an Authorization Policy with a page.

Questions?

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

contact us