Skip to main content

Authentication REST API

This guide shows you how to set up authentication for MitID using the Signicat Authentication REST API with redirect flow. The redirect flow allows you to pass a URL to your end-users which they will open in a browser.

Prerequisites

  1. Follow the steps on the Initial preparations page to establish a connection with MitID.
  2. Before you can start making requests to the Authentication REST API, you need to learn how to connect to it. To do this, see Connect to Signicat APIs Quick start guide.

    Want to learn more?

    To learn more about the Signicat Authentication REST API, see:

Implement the authentication flow

1. Build the authentication request (CreateSession)

This section describes how to make an HTTP POST request to the /sessions endpoint, to create a session and start an authentication.

To begin the authentication flow, your application must first start a session by utilising the /sessions endpoint. The endpoint automatically creates a session when you send a request. The flow and resulting information from the transaction depends on the parameters you pass in the body.

The response from this endpoint contains an authentication URL, to which you can embed in an iframe and present to the end-user to start their transaction.

To create a session, send a POST request to https://api.signicat.com/auth/rest/sessions?signicat-accountId={accountId}.

You can find your accountId in the Signicat Dashboard.

The following sub-sections show examples and descriptions of attributes that you can include in the request.

Request example

Here is an example request body for a "basic" MitID authentication:

{
"flow": "redirect",
"allowedProviders": [
"mitid"
],
"additionalParameters": {
"mitid_reference_text": "c29tZXRleHQgZm9yIHRlc3Rpbmc="
},
"requestedAttributes": [
"name",
"firstName",
"lastName",
"dateOfBirth",
"mitidHasCpr",
"mitidReferenceTextBody",
"mitidCprSource",
"mitidNameAndAddressProtection",
"mitidIal",
"mitidLoa",
"mitidAal",
"mitidFal",
"mitidUuid"
],
"callbackUrls": {
"success": "https://signicat.com",
"abort": "https://example.test/abort",
"error": "https://example.test/error"
}
}

Upon sending this request, a session will be created with MitID.

If the authentication completes successfully, the final result will contain the attributes that were requested.

Attribute descriptions

To initialise an authentication with MitID, you can use the following attributes in the initial request:

For more detailed field descriptions, see the API reference.

Control the user flow (additionalParameters)

You use additionalParameters to control the redirect flow. This is not a required field.

User attributes (requestedAttributes)

You can request the following attributes from users of MitID.

You add them in the requestedAttributes as shown in the request example above.

Response example (CreateSession)

Here is an example response after you have created a session:

{
"id": "1cac32ef-38a...",
"accountId": "a-sdge-...",
"authenticationUrl": "https://<YOUR_SIGNICAT_DOMAIN>/broker/sp/external-service/login?messageId=9102c493-b816-ea4f-b120-cdd95f982bf6&transactionId=1cac32ef-38a7-9249-969b-61af48bc49c2",
"status": "CREATED",
"callbackUrls": {
"success": "https://example.com/success??sessionId=1cac32ef-38a7-...",
"abort": "https://example.com/abort?sessionId=1cac32ef-38a7-...",
"error": "https://example.com/error?sessionId=1cac32ef-38a7-..."
},
"allowedProviders": [
"mitid"
],
"flow": "redirect",
"additionalParameters": {
"mitid_reference_text": "VHJhbnNmZXIgMjAwIERLSyB0byBBY2NvdW50IFhZWg0K"
},
"requestedAttributes": [
"name",
"firstName",
"lastName",
"dateOfBirth",
"mitidHasCpr",
"mitidReferenceTextBody",
"mitidCprSource",
"mitidNameAndAddressProtection",
"mitidIal",
"mitidLoa",
"mitidAal",
"mitidFal",
"mitidUuid"
],
"sessionLifetime": 1200,
"expiresAt": "2024-11-15T15:08:25.7016512+00:00"
}

What you need to do with the response

You must redirect the end-user to the authenticationUrl found in the response. This is a unique URL which allows the user to perform the MitID authentication in context of the session you just created.

"https://<YOUR_SIGNICAT_DOMAIN>/broker/sp/external-service/login?messageId=9102c493-b816-ea4f-b120-cdd95f982bf6&transactionId=1cac32ef-38a7-9249-969b-61af48bc49c2"

End-user authentication

The end-user follows these steps:

  1. On your website/application, the end-user clicks on a button to authenticate with MitID. Your application sends a request to start an authentication with MitID, as described in the previous section.
  2. The end-user is redirected to the MitID login page.
  3. The end-user logs in using their MitID credentials (this step may involve two-factor authentication).

After the end-user approves the request, the browser is redirected back to the relevant callbackUrls specified in the CreateSession request.

2. Obtain user information (GetSession)

Make an HTTP GET request to the /sessions endpoint to poll for information regarding the session and ongoing authentication.

Upon successful authentication, a response is returned that contains the user information requested in the "Create a new session" call carried out earlier.

Request

No data specific for MitID needs to be provided in this request.

To get the status of a session, send a GET request to https://api.signicat.com/auth/rest/sessions/{id}.

You can find the id value in the response that was returned when you created the session.

Response

The response contains a status field, which indicates the current status of the session. Below you can see an example response for a successfully completed session:

{
"id": "a993cc3a-cad8-...",
"accountId": "a-sdge-...",
"authenticationUrl": "https://<YOUR_SIGNICAT_DOMAIN>/broker/sp/external-service/login?messageId=27c019f1-de66-5840-a220-5f66e673c65e&transactionId=a993cc3a-cad8-f041-ae83-351a55ca5202",
"status": "SUCCESS",
"provider": "mitid",
"subject": {
"id": "MbLYMQJMSQAwk-...",
"name": "Valona Jensen",
"firstName": "Valona",
"lastName": "Jensen",
"dateOfBirth": "1990-02-17",
"mitidFal": "HIGH",
"mitidHasCpr": "true",
"mitidAal": "SUBSTANTIAL",
"mitidUuid": "8cb1e51c-13aa-4044-b9ac-8978cf1f113c",
"mitidIal": "SUBSTANTIAL",
"mitidReferenceTextBody": "Transfer 200 DKK to Account XYZ",
"mitidLoa": "SUBSTANTIAL"
},
"callbackUrls": {
"success": "https://example.com/success?sessionId=a993cc3a-cad8-f041-ae83-351a55ca5202",
"abort": "https://example.com/abort?sessionId=a993cc3a-cad8-f041-ae83-351a55ca5202",
"error": "https://example.com/error?sessionId=a993cc3a-cad8-f041-ae83-351a55ca5202"
},
"environment": {
"ipAddress": "192.0.2.0",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
},
"allowedProviders": [
"mitid"
],
"flow": "redirect",
"requestedAttributes": [
"name",
"firstName",
"lastName",
"dateOfBirth",
"mitidHasCpr",
"mitidReferenceTextBody",
"mitidCprSource",
"mitidNameAndAddressProtection",
"mitidIal",
"mitidLoa",
"mitidAal",
"mitidFal",
"mitidUuid"
],
"sessionLifetime": 1200,
"expiresAt": "2024-11-18T09:06:07.4162996+00:00"
}

Status overview

What you need to do with the response

If the returned status is SUCCESS, you will find information about the authenticated user in the subject object.

You will also see what identity provider was actually used by checking the provider field. This can be useful if you allowed more than one identity provider when you created the session.

Success

You have now completed an authentication flow with MitID.

Next steps

Learn more about available request and response attributes for MitID:

Dive deeper into Authentication REST API and improve your application with advanced security features: