Authentication Service
- 1 Authentication Service Overview
- 2 QR Code Authentication
- 3 Methods in the Authentication Service
- 3.1 Initiate Authentication Method
- 3.2 Get One Authentication Result Method
- 3.2.1 JSON Example for getOneAuthResultRequest
- 3.2.2 Example Request
- 3.2.3 Possible Errors
- 3.2.4 JSON Response Value
- 3.2.4.1 requestedAttributes
- 3.2.4.2 details
- 3.2.5 JSON Response Body with Mock Data for an APPROVED Response
- 3.2.6 JWS Payload with Mock Data for an APPROVED Response
- 3.2.6.1 Final JWS
- 3.3 Get Authentication Results Method
- 3.3.1 JSON Example for getAuthResultsRequest
- 3.3.2 Example Request
- 3.3.3 Possible Errors
- 3.3.4 JSON Response Value
- 3.4 Cancel Authentication Method
- 3.4.1 JSON Example for cancelAuthRequest
- 3.4.2 Example Request
- 3.4.3 Possible Errors
- 4 Authentication With Different userInfoType
Authentication Service Overview
The Freja eID Authentication Service allows Relying Parties to authenticate end users through the use of the Freja eID mobile application. The end user will have previously downloaded the Freja mobile application on one or more devices they possess.
We differentiate between 3 types of users based on assurance of the user's identity.
Basic - for users who have only registered with an email address
Extended - for users whose identity was verified with an ID document
Plus - for users whose identity has been verified to a higher level of assurance
The level of the user allows you to refer to them in different ways (via the userInfoType value). This is important because depending on the userInfoType you implement, that is the identifier that users will have to enter in your login form.
Types of userInfoType supported in Freja are:
INFERRED used for QR code authentication;
EMAIL with the user’s email;
PHONE with the user’s phone number;
SSN with the user’s Swedish personnummer.
UPI with the user’s unique personal identifier in Freja.
This page is written assuming you implement QR code authentication where userInfoType is set to INFERRED. This is the method of authentication we recommend as the safest and easiest to implement.
Most of the principles and logic described here apply to authentication with other userInfoType so you can still use this page for general information. For specific information about implementation with other userInfoType, you can refer to this page.
QR Code Authentication
With QR code authentication, users authenticate themselves by scanning a generated QR code and approving the authentication action. This method is very secure because users must physically be presented with a QR code to scan, otherwise an action cannot be generated in their name.
On mobile the process is even simpler since the user does not need to scan a QR code physically. Everything takes place within their device thereby making authentication even more secure because the authentication process is initiated and approved on the same device. In addition, this method is the most user friendly since it foregoes typing in user identifiers (emails, phone numbers, social security number etc.).
In summary, we recommend implementing this kind of authentication because:
It is much more user friendly, especially on mobile.
It is a much safer method of authentication.
This document goes more into depth regarding the Freja eID API. If you would like to see more details QR code login implementation, please refer to this page about Implementation and Best Practices.
Dynamic QR Code Implementation
If you would like more information about implementing dynamic QR codes, refer to this dedicated page about Dynamic QR Code Implementation.
Don’t Forget
There are several technical requirements that must be in place before implementation can begin. Please refer to the section 'Before You Begin' on this page.
Methods in the Authentication Service
The Freja eID Relying Party Authentication Service allows you to:
Initiate an authentication request;
Get one authentication result;
Get multiple authentication results;
Cancel an authentication request.
When it comes to getting authentication results, we recommend using the method for multiple results to reduce the number of polling requests.
Initiate Authentication Method
Use this method to initiate an authentication request. These requests are intended to be used when a user initiates an action to access your online service. Important features of this method are:
Authentication requests are short-lived i.e. from the point of initiation the user has 2 minutes to confirm it via Freja;
Only one active authentication request may exist for any given user at any given time. If the user initiates another authentication request either with your or another service, both will be cancelled.
The method is called using HTTP POST through the URLs below:
Environment | Endpoint |
|---|---|
TEST |
|
PRODUCTION |
|
JSON Example for initAuthRequest
The parameter of the method is a Base64 UTF8-encoded JSON payload according to the following:
{
"userInfoType":"User info type",
"userInfo":"User information corresponding to user info type",
"attributesToReturn":[
{
"attribute":"Type of attribute to be returned"
}
],
"minRegistrationLevel":"Minimum required registration level of a user",
"userConfirmationMethod":"Method used to confirm user's identity",
"useDynamicQrCode":"Flag to enable dynamic QR code"
} |
Concerning minRegistrationLevel When set to INFERRED, the transaction can proceed without enforcing a specific registration level. Instead, the system will infer and use the user's actual registration level at runtime. The set of returned attributes will vary based on the user's actual level. For example, if the BASIC_USER_INFO attribute is requested and the user is at the BASIC level, the attribute will not be returned (null), as it is not available at that level. If the user is at EXTENDED or PLUS, the attribute will be included in the response. In order to be able to use INFERRED as the minimal registration level, you must first get in touch with partnersupport@frejaeid.com.
The following attributes: BASIC_USER_INFO, DATE_OF_BIRTH, AGE, PHOTO, ADDRESSES, SSN, DOCUMENT or DOCUMENT_PHOTO are not available for BASIC users. |
Example Request with INFERRED userInfoType
Create the JSON structure {"userInfoType":"INFERRED","userInfo":"N/A"}
Encode the JSON structure to Base64.
Create the HTTP POST request with a POST parameter name initAuthRequest and the Base64 encoded JSON structure from step 2 as its value.
The HTTP body should be the following:
|
Possible Errors
Code Returned | Explanation |
|---|---|
0 | Internal error. |
1001 | Invalid or missing userInfoType. |
1002 | Invalid or missing userInfo. |
1003 | Invalid restrict. |
1004 | You are not allowed to call this method. |
1005 | User has disabled your service. |
1007 | Invalid min registration level. |
1008 | Unknown Relying Party. |
1009 | You are not allowed to request integratorSpecificUserId parameter. |
1010 | JSON request cannot be parsed. |
1012 | User with the specified userInfo does not exist in Freja eID database. |
2000 | Authentication request failed. Previous authentication request was rejected due to security reasons. |
2002 | Invalid attributesToReturn parameter. |
2003 | Custom identifier has to exist when it is requested. |
JSON Response Value
If HTTP 200 is returned from the method, the following return value will be present in the body of the response:
{
"authRef":"Reference to be submitted in getAuthResults method"
} |
|
JSON Response Value if useDynamicQrCode is set to TRUE
{
"authRef":"Reference to be submitted in getAuthResults method",
"qrCodeSecret":"Secret used for generating dynamic QR code"
} |
|
Get One Authentication Result Method
The method is called using HTTP POST through the URLs below:
Environment | Endpoint |
|---|---|
TEST |
|
PRODUCTION |
|
JSON Example for getOneAuthResultRequest
The parameter of the method is a Base64 UTF8-encoded JSON payload according to the following:
{
"authRef":"Authentication reference"
} | authRef: string, mandatory. The value must be equal to an authentication reference previously returned from a call to the Initiate Authentication Method. Because authentications are short-lived, fetching the result of a given authRef is only possible within 10 minutes from the time the initial authentication request was made. |
Example Request
If you wish to fetch an authentication result with the authentication reference previously returned from a call to initAuthRequest, follow these steps:
Create the JSON structure {"authRef":"GOHPyJcoKLJ+zKCEy4abi6jOO+q5VK+S1+UO5OXRmOPu42ixvVnsVgs7ADYUfG8m"}
Encode the JSON structure to Base64.
Create the HTTP POST request with a POST parameter name getOneAuthResultRequest and the Base64 encoded JSON structure from step 2 as its value.
The HTTP body should be the following:
|
Possible Errors
Code Returned | Explanation |
|---|---|
1004 | You are not allowed to call this method. |
1008 | Unknown Relying Party. |
1100 | Invalid reference (for example, nonexistent or expired). |
JSON Response Value
If HTTP 200 is returned from the method, the following return value will be present in the body of the response:
{
"authRef":"Authentication reference",
"status":"Authentication status",
"requestedAttributes":"Additional attributes about the user",
"details":"JWS signed data"
} |
|
requestedAttributes
Below is an example with all possible requestedAttributes and their information:
{
"basicUserInfo":{
"name":"User's name",
"surname":"User's surname"
},
"emailAddress":"User's primary email address",
"allEmailAddresses":[
{
"emailAddress":"User's email address"
},
{
"emailAddress":"User's email address"
}
],
"allPhoneNumbers":[
{
"phoneNumber":"User's phone number"
},
{
"phoneNumber":"User's phone number"
}
],
"dateOfBirth":"User's date of birth",
"age":"User's age",
"gender":"User's gender",
"photo":"User's photo, Base64 encoded JPEG bytes",
"nfcIdPhoto":"User's photo from ID document, Base64 encoded JPEG bytes",
"addresses":[
{
"country":"Country",
"city":"City",
"postCode":"Postal code",
"address1":"Street, number or equivalent",
"address2":"Street, number or equivalent",
"address3":"Street, number or equivalent",
"validFrom":"Date from which the address is valid",
"type":"Type of user's address",
"sourceType":"Source from which the address is obtained"
}
],
"customIdentifier":"Custom identifier set by the Relying Party",
"ssn":{
"ssn":"Social security number of the end user",
"country":"Country of SSN"
},
"document" : {
"type":"Type of document used for registration e.g. passport",
"country":"Document issuing country",
"serialNumber":"Document serial number",
"expirationDate":"Document expiration date"
},
"documentPhoto":"Document photo, Base64 encoded JPEG bytes",
"registrationLevel":"User's registration level in Freja eID",
"uniquePersonalIdentifier":"User's unique personal identifier in Freja eID",
"loaLevel":"User's level of assurance (LOA) in Freja eID",
"relyingPartyUserId":"Unique user ID reserved for Relying Parties",
"integratorSpecificUserId":"Unique user ID reserved for Integrators",
"customIdentifier":"Unique identifier set by the Relying Party"
} |
|
details
JWS in compact serialised form as following:
BASE64URL(UTF8(JWS Protected Header)) || ’.’ || BASE64URL(JWS Payload) || ’.’ || BASE64URL(JWS Signature)
JWS Protected Header | |
{
"x5t":"SHA-1 digest of the signing certificate",
"alg":"algorithm used to secure the JWS"
} |
|
JWS Payload | |
{
"authRef":"Authentication reference",
"status":"Authentication status",
"userInfoType":"User info type",
"userInfo":"User information corresponding to user info type",
"minRegistrationLevel":"Minimum required registration level of a user",
"requestedAttributes":{
JSON object, see below.
},
"timestamp":"Time when authentication is confirmed by end user"
} |
|
JSON Response Body with Mock Data for an APPROVED Response
{
"authRef":"12345-67890-abcdef",
"status":"APPROVED",
"details":"JWS content as per below",
"requestedAttributes":{
"basicUserInfo":{
"name":"Joe",
"surname":"Black"
},
"emailAddress":"joe.black@frejaeid.com",
"allEmailAddresses":[
{
"emailAddress":"joe.black@frejaeid.com"
},
{
"emailAddress":"joebl@domain.com"
}
],
"allPhoneNumbers":[
{
"phoneNumber":"+4600000000"
},
{
"phoneNumber":"+4611111111"
}
],
"dateOfBirth":"1985-11-17",
"age":"36",
"gender":"MALE",
"photo":"SlBFRyBpbWFnZSBieXRlcyBnb2VzIGhlcmUgLi4u",
"nfcIdPhoto":"aGVsbG93b3JsZF8yMDI1Q1RQX2V4YW1wbGU=",
"addresses":[
{
"country":"SE",
"city":"Stockholm",
"postCode":"11120",
"address1":"C/O Joe Black",
"address2":"Visdomsgatan 55",
"validFrom":"2020-03-19",
"type":"RESIDENTIAL",
"sourceType":"GOVERNMENT_REGISTRY"
},
{
"country":"NO",
"city":"Oslo",
"postCode":"0001",
"address1":"P.O. Box 456",
"validFrom":"2020-03-19",
"type":"POSTAL",
"sourceType":"GOVERNMENT_REGISTRY"
}
],
"ssn":{
"ssn":"198511170040",
"country":"SE"
},
"document" : {
"type":"PASS",
"country":"SE",
"serialNumber":"XA0000001",
"expirationDate":"2027-01-01"
},
"documentPhoto":"SlBFRyBpbWFnZSBieXRlcyBnb2VzIGhlcmUgLi4u"
"registrationLevel":"PLUS",
"uniquePersonalIdentifier": "5753-979204-7861",
"loaLevel": "LOA3",
"relyingPartyUserId":"94039a98c8d",
"integratorSpecificUserId":"54059a95c8d",
"customIdentifier":"vejobla"
} |
JWS Payload with Mock Data for an APPROVED Response
Certificate Info: for more information refer to REST API Documentation | [inlineExtension]Certificates in Freja eID |
Header: BASE64URL(UTF8(JWS Protected Header)) || ’.’ || BASE64URL(JWS Payload) || ’.’ || BASE64URL(JWS Signature) |
{
"authRef":"12345-67890-abcdef",
"status":"APPROVED",
"userInfoType":"EMAIL",
"userInfo":"joe.black@freja.com",
"requestedAttributes":{
"basicUserInfo":{
"name":"Joe",
"surname":"Black"
},
"emailAddress":"joe.black@freja.com",
...
},
"timestamp":1584701027510
} |
Final JWS
|
Get Authentication Results Method
The method allows a relying party to fetch the results of multiple outstanding authentications. It is our recommendation that you generally use the aggregate method, as it is more efficient and reduces network traffic. This is the default behaviour of the client library supplied by Freja eID.
The method is called using HTTP POST through the URLs below:
Environment | Endpoint |
|---|---|
TEST |
|
PRODUCTION |
|
JSON Example for getAuthResultsRequest
The parameter of the method is a Base64 UTF8-encoded JSON payload according to the following:
{
"includePrevious":"Include previously returned results"
} |
|
Example Request
If you wish to fetch multiple authentication results, follow these steps:
Create the JSON structure {"includePrevious":"ALL"}
Encode the JSON structure to Base64.
Create the HTTP POST request with a POST parameter name getAuthResultsRequest and the Base64 encoded JSON structure from the step 2 as its value.
The HTTP body should be the following:
|
Possible Errors
Code Returned | Explanation |
|---|---|
1004 | You are not allowed to call this method. |
1008 | Unknown Relying Party. |
1200 | Invalid or missing includePrevious parameter. |
JSON Response Value
If HTTP 200 is returned from the method, the following return value will be present in the body of the response:
{
"authenticationResults":[
{
"authRef":"Authentication reference",
"status":"Authentication status",
"details":"JWS signed data, see below",
"requestedAttributes":{
"basicUserInfo":{
"name":"Joe",
"surname":"Black"
},
"emailAddress":"joe.black@freja.com",
"allEmailAddresses":[
{
"emailAddress":"joe.black@freja.com"
},
{
"emailAddress":"joebl@domain.com"
}
],
"allPhoneNumbers":[
{
"phoneNumber":"+4600000000"
},
{
"phoneNumber":"+4611111111"
}
],
"dateOfBirth":"1987-10-18",
"age":"34",
"gender":"MALE",
"photo":"SlBFRyBpbWFnZSBieXRlcyBnb2VzIGhlcmUgLi4u",
"nfcIdPhoto":"aGVsbG93b3JsZF8yMDI1Q1RQX2V4YW1wbGU=",
"addresses":[
{
"country":"SE",
"city":"Stockholm",
"postCode":"11120",
"address1":"c/o Joe Black",
"address2":"Visdomsgatan 55",
"validFrom":"2020-03-19",
"type":"RESIDENTIAL",
"sourceType":"GOVERNMENT_REGISTRY"
},
{
"country":"NO",
"city":"Oslo",
"postCode":"0001",
"address1":"P.O. Box 456",
"validFrom":"2020-03-19",
"type":"POSTAL",
"sourceType":"GOVERNMENT_REGISTRY"
}
],
"ssn":{
"ssn":"198710180040",
"country":"SE"
},
"document" : {
"type":"PASS",
"country":"SE",
"serialNumber":"XA0000001",
"expirationDate":"2027-01-01"
},
"documentPhoto":"SlBFRyBpbWFnZSBieXRlcyBnb2VzIGhlcmUgLi4u",
"registrationLevel":"PLUS",
"uniquePersonalIdentifier": "5753-979204-7861",
"loaLevel": "LOA3",
"relyingPartyUserId":"94039a98c8d",
"integratorSpecificUserId":"54059a95c8d",
"customIdentifier":"vejobla"
},
{
"authRef":"..."
}
]
} |
|
Cancel Authentication Method
This method is used by a relying party to cancel an authentication request. The method is called using HTTP POST through the URLs below:
Environment | Endpoint |
|---|---|
TEST |
|