Embedded flow (advanced)
This guide shows you how to embed the Norwegian BankID authentication inside an iframe in your own flow (as opposed to redirecting to another page).
Using an iframe in authentication comes with security considerations. It is NOT supported for regular BankID authentication. However, we support using iframes for ecommerce customers under certain conditions.
iframe is used with BankID Biometric (BIS), which gives a substantial level of assurance.
If you want access to the iframe functionality, please contact us by creating a support ticket in the Signicat Dashboard.
Prerequisites
- Follow the steps on the Initial preparations page to establish a connection with Norwegian BankID.
-
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:
- Authentication REST API for conceptual documentation.
- API Reference for endpoint descriptions.
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 new 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 new 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 embedding the Norwegian BankID login in an iframe:
{
"flow": "embedded",
"allowedProviders": [
"nbid"
],
"embeddedParentDomains" : ["someparentdomain.example"],
"returnUrl": "https://example.com/",
"requestedAttributes": [
"name",
"firstName",
"lastName",
"dateOfBirth",
"idpId",
"nin",
"nbidUpdateAt",
"nbidSid",
"nbidOriginator",
"nbidIdp",
"nbidAuthTime",
"nbidAlternativeSubject",
"nbidSubjectUuid",
"nbidMethod"
],
"additionalParameters": {
"nbid_stepup" : "high"
},
"prefilledInput": {
"nin": "17029012345"
}
}
Upon sending this request, the Norwegian BankID session will start.
If the authentication completes successfully, the final result will contain the attributes that were requested.
Attribute descriptions
To initialise an authentication with Norwegian BankID, 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.
- BankID conducts an internal risk assessment and if deemed necessary, they force end-users to do a step-up.
- If you have your own risk assessment strategy, then you can specify
highto force a step-up. - Transactions with forced step-up are billed differently to transactions where it is not forced.
- A benefit of step-up is that a BankID High authentication is performed within a BankID Biometrics context. This provides your end-users with a richer context and potentially a more familiar user interface.
Prefill user information (prefilledInput)
You can use the prefilledInput parameter to prefill information about the user, for example, so the user does not have to fill in this information manually. If prefilled, only the user with the prefilled information will be able to authenticate. This is not a required field.
For Norwegian BankID, you can prefill the national identity number, nin:
"prefilledInput": {"nin": "17029012345"}
nin is not a required attribute for the embedded flow.
User attributes (requestedAttributes)
You can request the following attributes from users of Norwegian BankID.
Response
Here is an example response after you have created a session for an embedded flow:
{
"id": "ccba90...",
"accountId": "<ACCOUNT_ID>",
"authenticationUrl": "https://api.signicat.com/idps/sandbox/nbid/ciba/initialize-auth?transactionId=ccba90...&messageId=55b435...",
"status": "CREATED",
"allowedProviders": [
"nbid"
],
"flow": "embedded",
"requestedAttributes": [
"name",
"firstName",
"lastName",
"dateOfBirth",
"idpId",
"nin",
"nbidUpdateAt",
"nbidSid",
"nbidOriginator",
"nbidIdp",
"nbidAuthTime",
"nbidAlternativeSubject",
"nbidSubjectUuid"
],
"sessionLifetime": 1200,
"expiresAt": "2024-10-07T11:45:29.4275228+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 Norwegian BankID authentication in context of the session you just created.
End-user authentication
The end-user follows these steps:
- On your website/application, the end-user clicks on a button to authenticate with BankID. Your application sends a request to start an authentication with BankID, as described in the previous section.
- The BankID login page is opened in an iframe inside your website/application.
- The end-user logs in using their BankID credentials (this step may involve two-factor authentication).
After the end-user has finished the authentication in the iframe, the iframe is redirected to the returnUrl specified in the CreateSession request.
During certain error situations the user will also be redirected to the returnUrl, and more information regarding the error will be available by getting the session information as explained below.
2. Retrieve the sessionNonce
After the user has finished the authentication and been redirected to your specified returnUrl, you must retrieve the returned sessionNonce value and include it in the GetSession request (see below) to get information about the transaction and the user.
We return the sessionNonce value to ensure that the communication session is unique and cannot be used in replay attacks.
The sessionNonce value is returned at the end of the returnUrl, for example:
https://example.com/?sessionNonce=P-zvdIDsW6ZKGn5__48Df9RitMlxHvUe1RHZ-PLxczc
3. Obtain user information (GetSession)
You use the GetSession endpoint to get information about the session you created earlier. It will contain the user information if the authentication is successful.
Request
No data specific for Norwegian BankID 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}?sessionNonce={sessionNonceValue}.
Ensure you include the sessionNonce (see the Retrieve the sessionNonce section). 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": "ccba90...",
"accountId": "<ACCOUNT_ID>",
"authenticationUrl": "https://api.signicat.com/idps/sandbox/nbid/ciba/initialize-auth?transactionId=ccba90...&messageId=55b435...",
"status": "SUCCESS",
"provider": "nbid",
"subject": {
"id": "IgGIO1BBMio6uOV8OzrbfJcWR1o91ANOY9l6I96NhG8=",
"idpId": "9578-6000-4-1663921",
"name": "Kari Nordmann",
"firstName": "Kari",
"lastName": "Nordmann",
"dateOfBirth": "1990-02-17",
"nin": {
"value": "17029012345",
"issuingCountry": "NO",
"type": "BIRTH"
},
"nbidAlternativeSubject": "9578-6000-4-1663921",
"nbidIdp": "BIS",
"nbidSubjectUuid": "vFafzatjbz1_k_FlizIpRzxrPspN_i_0mGLd0mWRVNM",
"nbidOriginator": "CN=BankID - TestBank1 - Bank CA 3,OU=123456789,O=TestBank1 AS,C=NO;OrginatorId=9980;OriginatorName=BINAS;OriginatorId=9980",
"nbidSid": "2me2o_eoI4TZQpv4z8qN2GSsWgfMZxCtWowY9s38p8Y"
},
"allowedProviders": [
"nbid"
],
"flow": "embedded",
"requestedAttributes": [
"dateOfBirth",
"firstName",
"idpId",
"lastName",
"name",
"nbidAlternativeSubject",
"nbidAuthTime",
"nbidIdp",
"nbidOriginator",
"nbidSid",
"nbidSubjectUuid",
"nbidUpdateAt",
"nin"
],
"sessionLifetime": 1200,
"expiresAt": "2024-10-10T12:46:07.1061872+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.
You have now completed an authentication flow with Norwegian BankID.
Next steps
Dive deeper into Authentication REST API and improve your application with advanced security features: