@@ -40,6 +40,7 @@ The most common scenbario is to use Active Login for BankID auth/login, so most
4040 + [ Event listeners] ( #event-listeners )
4141 + [ Store data on auth completion] ( #store-data-on-auth-completion )
4242 + [ Resolve the end user ip] ( #resolve-the-end-user-ip )
43+ + [ Resolve the end user device data] ( #resolve-the-end-user-device-data )
4344 + [ Resolve requirements on Auth request] ( #resolve-requirements-on-auth-request )
4445 + [ Resolve user data on Auth request] ( #resolve-user-data-on-auth-request )
4546 + [ Custom QR code generation] ( #custom-qr-code-generation )
@@ -998,14 +999,148 @@ services.RemoveAll(typeof(IBankIdResultStore));
998999
9991000### Resolve the end user ip
10001001
1001- In some scenarios , like running behind a proxy , you might want to resolve the end user IP yourself and override the default implementaion .
1002+ In some scenarios , like running behind a proxy , you might want to resolve the end user IP yourself and override the default implementation .
10021003
10031004Either register a class implementing `IBankIdEndUserIpResolver `:
10041005
10051006```csharp
10061007services .AddTransient <IBankIdEndUserIpResolver , EndUserIpResolver >();
10071008```
10081009
1010+ -- -
1011+ ### Device data
1012+
1013+ When initiating a flow with BankID , the objects " app" or " web" can be included in the request .
1014+ The information in these two objects differs , but including either of them allows BankID to
1015+ provide a better risk indication .
1016+
1017+ When using BankID , device information provides valuable metadata that enhances security and ensures a smoother user experience .
1018+ Including the ** device type ** (e .g ., `APP ` or `WEB `) helps BankID :
1019+ - ** Evaluate risk ** for each request .
1020+ - ** Take automated actions ** based on high - risk scenarios (if enabled ).
1021+ - Provide ** better insights ** into the context of the request .
1022+
1023+ #### Configuring Device Data
1024+
1025+ Active Login has a default implementation of the User Device feature that uses a
1026+ web browser as the device type . You can customize the default implementation or create your own .
1027+
1028+ The following service interface must be implemented to use the User Device feature :
1029+ - `IBankIdEndUserDeviceDataResolverFactory `: Factory that provides the resolvers for the device type .
1030+ - `IBankIdEndUserDeviceDataResolver `: Resolver that provides the device data for a given device type .
1031+ - `IBankIdEndUserDeviceDataConfiguration `: Configuration that specifies the device type to use .
1032+
1033+ #### What is included in the requests?
1034+
1035+ | Device Type | Default Resolver Implementation | Metadata Included |
1036+ | -------------- - | ------------------------------------------ - | -------------------------------------------- |
1037+ | ** Web ** | `BankIdDefaultEndUserWebDeviceDataResolver ` | Referring domain , User - Agent , DeviceIdentifier |
1038+ | ** App ** | `BankIdDefaultEndUserAppDeviceDataResolver ` | App Identifier , Device OS , Model , DeviceIdentifier |
1039+
1040+ The Device identifier must be identical between requests .
1041+
1042+ The `BankIdDefaultEndUserWebDeviceDataResolver ` will set a protected cookie named `__ActiveLogin .BankIdDeviceData ` that contains
1043+ unique identifier (DeviceIdentifier ) to ensure that the identifier is persistent across requests .
1044+
1045+ #### Customizing the User Device feature
1046+ To customize the User Device feature , use the `UseDeviceData ` extension in the BankID client builder .
1047+ This allows you to specify the device type and any relevant metadata using resolvers .
1048+
1049+ The BankIdFlowService will automatically include the device data in the BankID request ,
1050+ since it is dependent of the `IBankIdEndUserDeviceDataResolverFactory ` service .
1051+
1052+ ##### Configuration examples
1053+
1054+ If no configuration of the UseDeviceData has been set , the default implementation will be used .
1055+ This implementation will set the device type to `BankIdEndUserDeviceType .Web ` and use
1056+ the `BankIdDefaultEndUserDeviceDataResolverFactory ` to find the correct resolver for the device type .
1057+ The `BankIdDefaultEndUserWebDeviceDataResolver ` is used to fetch the web browser information .
1058+
1059+ *If no custom implementation is made the device data defaults to this : *
1060+ ```csharp
1061+ services
1062+ .AddBankId (bankId =>
1063+ {
1064+ bankId .UseDeviceData (config =>
1065+ {
1066+ // Set the device type for the request
1067+ config .DeviceType = BankIdEndUserDeviceType .Web ;
1068+
1069+ // Use the default resolver factory
1070+ config .UseResolverFactory <BankIdDefaultEndUserDeviceDataResolverFactory >();
1071+
1072+ // Add the default resolver for Web
1073+ config .AddDeviceResolver <BankIdDefaultEndUserWebDeviceDataResolver >();
1074+ });
1075+ });
1076+ ```
1077+
1078+ * Custom implementation requests initiated by av web browser :*
1079+ ```csharp
1080+ services
1081+ .AddBankId (bankId =>
1082+ {
1083+ bankId .UseDeviceData (config =>
1084+ {
1085+ // Set the device type for the request
1086+ config .DeviceType = BankIdEndUserDeviceType .Web ;
1087+
1088+ // Use a custom resolver factory
1089+ // that implements IBankIdEndUserDeviceDataResolverFactory
1090+ config .UseResolverFactory <MyCustomResolverFactory >();
1091+
1092+ // Add a custom resolver for the device type Web
1093+ // that implements IBankIdEndUserDeviceDataResolver
1094+ config .AddDeviceResolver <MyCustomWebDeviceDataResolver >();
1095+ });
1096+ });
1097+ ```
1098+
1099+
1100+ * Custom implementation requests initiated by a mobile app :*
1101+
1102+ ```csharp
1103+ services
1104+ .AddBankId (bankId =>
1105+ {
1106+ bankId .UseDeviceData (config =>
1107+ {
1108+ // Set the device type starting the request
1109+ config .DeviceType = BankIdEndUserDeviceType .App ;
1110+
1111+ // Use the default resolver factory to find what device data resolvers to use
1112+ config .UseResolverFactory <BankIdDefaultEndUserDeviceDataResolverFactory >();
1113+
1114+ // Use the default data resolver for the device type app
1115+ // On app devices (e.g. MAUI, Xamarin, etc.) we need to set the
1116+ // device data manually at start
1117+ config .AddDeviceResolver (s => new BankIdDefaultEndUserAppDeviceDataResolver ()
1118+ {
1119+ // App ID or package name
1120+ AppIdentifier = " com.example.app" ,
1121+
1122+ // Device operating system
1123+ DeviceOs = " iOS 16.7.7" ,
1124+
1125+ // Device model
1126+ DeviceModelName = " Apple iPhone14,3" ,
1127+
1128+ // Unique hardware ID
1129+ DeviceIdentifier = " 1234567890"
1130+ });
1131+
1132+ });
1133+ });
1134+ ```
1135+ The information for the BankIdDefaultEndUserAppDeviceDataResolver has to be set during startup .
1136+
1137+ #### More information available at:
1138+ - [BankID Risk Indication ](https :// www.bankid.com/en/foretag/the-service/risk-indication)
1139+ - [BankID Api - Auth ](https :// developers.bankid.com/api-references/auth--sign/auth)
1140+ - [BankID Api - Sign ](https :// developers.bankid.com/api-references/auth--sign/sign)
1141+ - [BankID Api - Payment ](https :// developers.bankid.com/api-references/auth--sign/payment)
1142+
1143+ -- -
10091144### Resolve requirements on Auth request
10101145
10111146If you want to set the requirements on how the authentication order must be performed dynamically for each order instead of statically during startup in `Program .cs `, it can be done by overriding the default implementation of the `IBankIdAuthRequestRequirementsResolver `.
@@ -1320,15 +1455,19 @@ We have choosen not to normalize the capitalization of the names as it´s hard o
13201455
13211456The `* .AspNetCore ` package will issue a cookie to make the auth flow work
13221457
1323- The cookie is called : `__ActiveLogin .BankIdUiState `
1324-
1325- The cookie is there to store state during the auth process , as the user will / might be redirected during the flow . The cookie is session based only and will be deleted once the auth process is finished and / or when the user closes the browser.
1326-
1327- Because it is strictly related to temp storage during auth , you should not have to inform the user about these specific cookies (according to the [EU " cookie law" ](https :// www.cookielaw.org/the-cookie-law/)).
1328-
1329- With the current implementaiton (following the convention from Microsoft ASP .NET ) the usage of cookies is not optional .
1330-
1331- A more technical deep dive of the cookies can be found in [this issue ](https :// github.com/ActiveLogin/ActiveLogin.Authentication/issues/156).
1458+ - Cookie : `__ActiveLogin .BankIdUiState `
1459+ - This cookie is there to store state during the auth process , as the user will / might be redirected during the flow . The cookie is session based only and will be deleted once the auth process is finished and / or when the user closes the browser.
1460+
1461+ - Because it is strictly related to temp storage during auth , you should not have to inform the user about these specific cookies (according to the [EU " cookie law" ](https :// www.cookielaw.org/the-cookie-law/)).
1462+
1463+ - With the current implementation (following the convention from Microsoft ASP .NET ) the usage of cookies is not optional .
1464+
1465+ - A more technical deep dive of this cookie can be found in [this issue ](https :// github.com/ActiveLogin/ActiveLogin.Authentication/issues/156).
1466+
1467+ - Cookie : `__ActiveLogin .BankIdDeviceData `
1468+ - This cookie is used to store the device data for the user , in the default implementation ,
1469+ It is used to ensure that the device data is persistent across requests .
1470+
13321471
13331472
13341473### Browser support
0 commit comments