Search…
Guide: Enable Organisations to Make Requests to an Application
This document describes how you can go enable an orginization to interact with the application system.

Prerequisites

For an orginasation to be able to able to read/update an application the setup is as follows
  1. 1.
    Create a connection between their x-road server (handled by the institution) and our x-road server (handled by Andes)
  2. 2.
    Create a new client In the IDS with:
    • Machine Client type
    • client claims prefix: client_
    • relevant scopes application:read and/or application:write
    • claim with key: nationalId and The orginasation's national Id as value
This client can be created in the IDS admin panel on dev using Gervimaður Útlönd 010-7789. For Staging and Prod a make request on #ids_changes

Orginization and Application Interaction

1. Add and map a role for the Orginization

In the Application template map the orginasation's nationalId like so
1
mapUserToRole(
2
id: string,
3
application: Application,
4
): ApplicationRole | undefined {
5
...
6
if (id === 'xxxxxx-xxxx') { // The nationalId added as claim in the Ids earlier.
7
return Roles.ORGINISATION_REVIEWER
8
}
9
...
10
},
Copied!

2. Create an interaction state for the orginisation

For the org to be able to interact we need to add the role permission to a relevant state for the them to interact with the application.
Add an entry action:
1
stateMachineOptions: {
2
actions: {
3
assignToInstitution: assign((context) => {
4
const { application } = context
5
const institution_ID = 'xxxxxx-xxxx'
6
7
set(application, 'assignees', [institution_ID])
8
9
return context
10
})
11
}
12
}
Copied!
An example of an approve/reject state from an orginisation. Add your state with entry and exit that handles the assign of the institution
1
[States.ORGINISATION_APPROVAL]: {
2
entry: 'assignToInstitution',
3
exit: ['clearAssignees'], //ideally you would clear the assignees here
4
meta: {
5
name: States.ORGINISATION_APPROVAL,
6
...
7
roles: [
8
...
9
{
10
id: Roles.ORGINISATION_REVIEWER,
11
formLoader: () =>
12
import('../forms/InReview').then((val) =>
13
Promise.resolve(val.InReview),
14
),
15
read: 'all',
16
write: 'all',
17
},
18
...
19
],
20
},
21
on: {
22
[DefaultEvents.APPROVE]: { target: States.APPROVED },
23
[DefaultEvents.REJECT]: { target: States.REJECT },
24
},
Copied!

3. Originisation API requests

To invoke a state change the machine client would for approving make a PUT request like so:
1
curl --location -g --request PUT '{{baseUrl}}/applications/{applicationId}/submit' \
2
--header 'authorization: xxx' \
3
--header 'Content-Type: application/x-www-form-urlencoded' \
4
--data-raw '{
5
"event": "APPROVE",
6
"answers": {},
7
"message": ""
8
}'
Copied!

Postman local testing setup

Log in to the IDS admin panel on dev using Gervimaður Útlönd 010-7789. Find the client you created earlier, create a new secret and copy it to your clipboard:
image
Choose Oauth 2.0 and use the settings below. Insert your Client id, client secret and the Scope should be @island.is/applications:read @island.is/applications:write press "Get New Access Token" and you have your token.
image