Access requests

Some forms are only for certain people, for example a medical form that only physicians and nurses in Alberta can fill in. Signing in with an Alberta.ca account doesn’t prove that, so the form is restricted, and people ask for access first:

  1. A person opens the form in the Form App. They don’t have access yet, so they see an Access request page with a few questions, such as their profession and licence number, and submit it.
  2. A reviewer (someone in the form’s approver group) opens the request in the Form Admin app, checks the answers, and approves or rejects it.
  3. If the request is approved, the person is added to the form’s user group in Keycloak. That group gives them the roles the form needs. They get an email, sign in again, and can use the form.
  4. If the request is rejected, nothing changes in Keycloak. They get an email and can send a new request later.

This page explains the Keycloak groups and roles to set up so that this works. You need to be a tenant administrator (you need to be able to manage users, groups and roles in your tenant’s Keycloak realm).

Before you start

  • The form must not allow anonymous applicants. Access requests need a signed-in user.
  • Pick names for two groups, for example medical-intake-users and medical-intake-approvers. The examples below use these names.

Step 1: Create the role that opens the form

The form only accepts people who have one of its applicant roles (see Securing access).

  1. In Keycloak, create a role for this form, for example the realm role medical-intake-applicant.
  2. In the tenant management webapp, open the form definition, go to the Roles tab, and make that role an Applicant role of the form.

Don’t use a role that everyone already has, such as a default role of the realm or form-applicant (the Form App gives it to everyone who signs in). If everyone has it, the form isn’t restricted.

Step 2: Create the user group (for approved people)

Approved people are added to this group, so it holds everything they need to fill in the form.

  1. In Keycloak, create the group, for example medical-intake-users.
  2. Under Role mapping for the group, assign:
    • the role from step 1 (medical-intake-applicant),
    • the form service role form-applicant (client urn:ads:platform:form-service), so they get updates in the Form App. You can skip it if the Form App client already gives it to everyone (see step 3),
    • the form service role form-file-uploader if the form has file uploads. You can skip it if it’s already a default role of the realm. Don’t add form-file-reader: it lets a user read every supporting document in the tenant, and applicants can read their own files without it. See file uploads in the Form App.

You don’t need to add anyone to this group yourself: when a reviewer selects Approve in the Form Admin app, form service adds the person to this group automatically. You can still add someone by hand to give them access without a request.

Step 3: Let people ask for access

Everyone who might ask for access needs the form service role form-access-requester. Without it, they see “Form not found” instead of the Access request page. It only lets people read the access request questions, send a request, and see the status of their own request.

Give it through the Form App’s Keycloak client, the same way the client gives everyone form-applicant. You do this once per realm, not per form:

  1. In the Keycloak admin console of your realm, select Clients, search for form-app, and open urn:ads:platform:form-app.
  2. Open the Client scopes tab and select urn:ads:platform:form-app-dedicated. The mapper that gives form-applicant (usually named form-applicant-role) is listed there.
  3. Select Add mapper > By configuration > Hardcoded role.
  4. For Name, enter form-access-requester-role.
  5. For Role, select Select role, switch the filter to Filter by clients, search for form-access-requester, tick the one for urn:ads:platform:form-service, and select Assign.
  6. Select Save.

The role is then in every token the Form App gets, for everyone who signs in to it, but not in tokens for other apps. People get it on their next sign-in or page reload. Don’t add it to the realm’s default roles: that would give it to every user of every app in the realm.

To check it worked, sign in to the Form App as someone without the form’s applicant role, and open a form that accepts access requests. They should see the Access request page, not “Form not found”.

Step 4: Create the approver group (for reviewers)

Members of this group are the only people who can see and decide on the form’s requests.

  1. In Keycloak, create the group, for example medical-intake-approvers.
  2. Under Role mapping for the group, assign:
Role Why it’s needed
form-access-writer (client urn:ads:platform:form-service) See, approve and reject access requests. For people who should only look at requests, use form-access-reader instead.
view-users (client realm-management) Form service checks in Keycloak that the reviewer is in the approver group, using the reviewer’s own sign-in. Every reviewer needs this.
manage-users (client realm-management) Approving adds the person to the user group in Keycloak, using the approver’s own sign-in. Only people who approve need this.
  1. Add the reviewers to the group.

manage-users lets someone change any user in the realm, not just add people to this group. Only give it to people you trust with that. Without it, a reviewer can still see and reject requests, but approving fails with a message that names the missing role, and the request stays pending.

Reviewers who aren’t form administrators (they don’t have the form-admin role) can’t browse the list of forms in the Form Admin app. Send them the direct link to the form’s requests: /<tenant>/definitions/<form definition ID>/access-requests on the Form Admin app.

People added to the approver group, or given new roles, need to sign out and sign in again before the change takes effect.

The Form Admin app signs in with the urn:ads:platform:form-admin-app client of your realm, and the view-users and manage-users roles have to be in its tokens. If the client has Full scope allowed turned off, add those two roles to its dedicated client scope (Clients > urn:ads:platform:form-admin-app > Client scopes > the dedicated scope > Scope).

Step 5: Turn on access requests for the form

In the tenant management webapp, open the form definition and go to the Access requests tab:

  1. Check Users must request access to this form.
  2. User group: pick the group from step 2.
  3. Approver group: pick the group from step 4.
  4. Notification email: the address to tell about new requests. Sending this email isn’t available yet, so tell reviewers to check the Form Admin app.
  5. Add the questions reviewers need answered, for example the person’s profession and licence number. Their name and email address are always included.
  6. Save the form definition.

Step 6: Review requests

In the Form Admin app, open the form. Forms with access requests turned on have two tabs under the form name: Responses (the same as before) and Access requests. Reviewers who don’t have a role that can view responses see a note on the Responses tab instead of the list.

  • The Access requests tab lists requests, showing pending ones first by default. Use Status to see approved, rejected or all requests.
  • Select a request to see the person’s name, email address, answers and status.
  • Select Approve or Reject. You can add a comment (up to 1,000 characters). It’s kept with the request for other reviewers and isn’t sent to the person.
  • Approved and rejected requests stay in the list for reference, without the buttons.

When you approve, form service adds the person to the form’s user group (the one picked on the form’s Access requests tab in step 5) first, and only then marks the request approved. If Keycloak refuses (for example, you don’t have manage-users), the request stays pending and you can try again. Approving the same person twice changes nothing.

To take access away, remove the person from the user group in Keycloak. Their approved request stays in the list. If they open the form again, the Form App tells them they can’t open it right now and lets them send a new request, which you review like any other.

Who gets which roles

Who Roles What they can do
Anyone signed in to the Form App form-applicant, form-access-requester (from the Form App client, step 3) Ask for access and see the status of their own request.
An approved person (user group) The form’s applicant role, and form-file-uploader if needed Open, fill in and submit the form, after signing in again or reloading.
A reviewer who only looks (approver group) form-access-reader, view-users See the form’s requests.
A reviewer who decides (approver group) form-access-writer, view-users, manage-users See, approve and reject the form’s requests.

A person whose request was rejected keeps only the default roles. They can send a new request.

If something doesn’t work

What you see What to check
The person sees “Form not found” instead of the Access request page They need form-access-requester (step 3), and the form needs access requests turned on (step 5).
An approved person sees “You can’t open this form right now” If they were approved in the last few minutes, they sign out and sign in again. If they were removed from the user group, they can send a new request. Otherwise check that the user group has the form’s applicant role (steps 1 and 2).
“Only members of the form’s approver group can…” Add the reviewer to the approver group (step 4).
“Keycloak didn’t allow checking that you’re in the form’s approver group” The reviewer needs view-users (step 4).
“Keycloak didn’t allow adding the applicant to the form’s user group” The approver needs manage-users (step 4). The request is still pending.
“The form has no user group to add the applicant to” Pick a user group on the form’s Access requests tab (step 5).
“The form’s user group doesn’t exist in Keycloak” The group was renamed or deleted. Pick it again on the Access requests tab (step 5).
“The request doesn’t record the applicant’s account” The request was sent before this feature was released. Reject it and ask the person to send a new request.

For the API, see the access request section of the form service documentation.


This site uses Just the Docs, a documentation theme for Jekyll.