Multi Factor Authentication
Multi-Factor Authentication (MFA) adds an extra layer of security to your login process by requiring users to verify their identity using more than just a...
🔐 Understanding and Setting Up Multi-Factor Authentication (MFA)
Multi-Factor Authentication (MFA) adds an extra layer of security to your login process by requiring users to verify their identity using more than just a password. This helps protect accounts from unauthorized access—even if a password is compromised. The Portal now allows for configuration of MFA via email for local logins (i.e. logins that use the built in authentication, and do not use external authentication providers).
🧠 What Is MFA?
MFA requires users to provide two or more verification factors to gain access:
- Something you know (e.g., password)
- Something you have (e.g., a one-time code from an app or SMS)
- Something you are (e.g., fingerprint or facial recognition)
For Klevr Portal, MFA can be enabled for local logins (i.e. not using B2C or an external authentication provider) and it involves entering a 6-digit code that is received via email after logging in with a username and password.
⚙️ MFA Configuration Settings Explained
Klevr Portal uses the following settings to control how MFA behaves:
Klevr:LocalLoginMFA
Controls whether MFA is required for users logging in locally. It should be set to one of the following three values. By default it is set to none to be backwards compatible with existing implementations.
| Setting | Meaning |
|---|---|
none | Disable MFA requirements for all local logins. Will take effect immediately when the user logs in next. |
selective | Evaluate the Klevr_PortalEnforceMFA boolean value on the contact record to determine if they require MFA to log in. Evaluated at the time of login, so if the value changes it takes effect the next time the user logs in. |
all | Enable MFA for all logins. Takes effect on next login. |
Recommended: Use selective to allow gradual rollout or all for full protection. Each time a user logs in, it will check the current setting and alter the user to comply. This means that if you change an existing site to all, users will be forced to enter the code. Similarly, if you set a site from all to none, it will stop asking users to enter their codes.
Selective works as follows: once a user logs in, their contact record in CE is checked. A new boolean field called klevr_PortalEnforceMFA is checked to see if this particular user should use MFA or not. This boolean can change over time, and each time they log in, it will be checked to see if they require it currently or not. The recommended approach for using this is to have a plugin in CE set this value if for example a specific web role is assigned to the user (e.g. assessor), but you could also do something like add this field to the profile screen to allow users to decide if they want to use it or not (probably not the best idea, but certainly possible). Keep in mind that the default value is off. Keep in mind that this value is only checked if the app setting is "Selective", and is ignored for "All" or "None".
Klevr:LocalLoginMFACodeValidityInSeconds
Defines how long a one-time MFA code remains valid.
- Default:
120seconds (2 minutes) - Actual validity: Between 120 and 240 seconds (1 to 2 times the value specified)
- Codes are valid for the current time block and the previous one to account for clock drift. Which means at any time there is actually two valid codes that overlap.
- Another way to look at it: If you generate a 2 minute code at 3:59, it will expire at the next 2 minute interval, which is at 4:00, but will still be accepted until 4:02, so there is a rolling window of 2 valid codes that overlap each other for the interval specified above.
Tip: Keep this between 60–180 seconds for balance between usability and security. Keep in mind that it is sent via email, which can take some time to sync to the users mailbox.
Klevr:LocalLoginMFACookieValidityInDays
Controls how long the “Remember me on this device” option lasts.
- Default:
7days - Behavior:
- If the user selects “Remember me,” a cookie is stored for 7 days.
- If not selected, the MFA session lasts only until the browser is closed.
Benefit: Reduces friction for trusted devices while maintaining security.
🛠️ How to Set Up MFA on Your Site
Set LocalLoginMFA to selective or all by updating your library variables and doing a deploy. For advanced users, you can edit the setting directly in the appsettings.json file, and it will take immediate effect, no restart required. Keep in mind that it will be overwritten by the library variables during the next deploy.
Adjust LocalLoginMFACodeValidityInSeconds to suit your security needs. Will take immediate effect when changed in app settings as above.
Use LocalLoginMFACookieValidityInDays to define how long trusted devices bypass MFA. Evaluated during startup of the portal, so will require a site restart or deploy to take effect.
Ensure you have a communication plan or rollout strategy that works for your customer and their portal users.
Test your Invite, Register and Log in processes with a test account and verify the MFA prompt, email and user flow matches your required behavior.
✅ Best Practices
- Use
allfor high-security environments. - Keep code validity short to reduce attack windows.
- Offer “Remember this device” for convenience—but limit duration.
- Educate users on why MFA matters.
Technical info
the MFA code implemented in the portal is based on Umbraco and C#'s standard MFA implementation. This means that if MFA is enabled for a user, you will be able to see it in Umbraco under the member details, but keep in mind that it is integrated to Dynamics, so setting or changing this value won't have an effect, since the next time the user logs in, their dynamics setting and the global setting is evaluated and applied.
The MFA code screen is implemented as an additional template on the login document template in Umbraco. If you wish to alter the look and feel, you can copy this template and create your own, or request us to add paramters into product for further fine tuning. It ueses the CSS variables, so should adhere to typical style changes.
You require the new MFA content page, so for existing sites, after upgrade and after importing usync settings, run a usync report on content, find the MFA page, and apply this page to bring in this single change only.
The "Remember me on this device" option will store a cookie in the user's browser with the validity period specified in the settings. There are cases where the cookie can be deleted before it expires, so it may not always allow the user to log in without MFA even though they are in the specified time period and have ticked the box.
Codes can be copied and pasted from the email to the code screen.
The email contents is in a new EmailLayout template called MFACodeEmail. You can adjust it if neccesary.
User Flow
When a user registers, the MFA settings are evaluated, and if the user requires MFA, the email validation is bypassed, since they will be asked for an emailed code upon first login, which effectively validates their email in any case.
Password resets does not require an MFA code, as the password reset link is emailed so negates the need for a code as well.
Invitation will follow the normal registration process. At the end of registration, if MFA is required, the user will be directed to log in, instead of verifying their email, since the MFA code on login will effectively verify the email.
Last updated on