ADFS Email OTP Provider
OTP authentication for Microsoft Active Directory Federation Service (ADFS). It enables ADFS servers to provide multi-factor authentication (MFA) using a Time-Based One-Time Password (TOTP) Algorithm which is based on RFC6238. Using this MFA provider users are required to enter a one-time pass-code to complete a second factor authentication logon process. OTP code is delivered using SMTP service.
Multi-language UI: English, Spanish, French, German, Chinese, Portuguese, Russian, Italian, Arabic, Turkish, Dutch, Finnish, Swedish, Norwegian, Polish, Danish and Lithuanian.
OTP pass-codes for 24 user accounts
OTP codes delivery using SMTP service
OTP user accounts deactivation
OTP data storage in MS SQL service
Logs in Windows Applications Log
ADFS 2016 and ADFS 2019 support
Support of ADFS CSS themes
Licensed version (additional features)
OTP pass-codes for unlimited user accounts
OTP data storage in MS Active Directory attributes or MS SQL Service
OTP account lockout
OTP validity length can be customised
SSL and user authentication support for SMTP service
Secrets encryption with AES 256-bit encryption
Domain restrictions to receive OTP codes
User interface customizations
Free version notes are removed
Latest version has major configuration changes which are aligned against all other SecureMFA Providers
Some features which were used in old provider's versions have been depreciated. Please see documentation which features remain available.
If system has old version (version before 1.0.2.x) of this provider it must be uninstalled first before deploying the latest one.
Deploy SecureMFA Email Time Based OTP Provider into ADFS Farm
Before you can start registering “SecureMfaEmailOtpProvider” into your ADFS farm you must complete bellow steps. All commands must be executed in elevated PowerShell (PS) command prompt.
1) Deploy latest “SecureMfaEmailOtpProvider” PowerShell module from Microsoft PSGallery using bellow PS command.
Install-Module -Name SecureMFA_EMAIL_OTP -Repository PSGallery -Scope AllUsers
NOTE: If your ADFS server doesn’t have access to the Internet you can pull PowerShell module from Windows client which will have Internet access and copy “C:\Program Files\WindowsPowerShell\Modules\SecureMFA_EMAIL_OTP ” folder from client’s computer into ADFS server (same location).
As alternative you can download “SecureMFA_EMAIL_OTP ” nupkg file manually from https://www.powershellgallery.com/ website. Rename nupkg file’s extension into ZIP. Unzip content into a folder “SecureMFA_EMAIL_OTP ” and place it into PS Modules default location on the server. That will work the same way as pulling package with native windows PS Tools.
2) Within “C:\Program Files\WindowsPowerShell\Modules\SecureMFA_EMAIL_OTP ” directory you will find “sql_Create_Database_SecureMfaOTP.txt”
Modify FILENAME location to reflect your sql server storage configuration. Open the script in SQL manager and execute it. This will create a new SQL database for “SecureMfaEmailOtpProvider”
3) Within “C:\Program Files\WindowsPowerShell\Modules\SecureMFA_EMAIL_OTP ” directory update “SecureMfaEmailOtpProvider.json” file.
If you are using a free version you only need to modify "sqlserver" server settings. If you will buy a license for unlimited users you will need to update "company" , "serialkey" and "subscriptionid" information to unlock licensed provider features.
If you are not running your ADFS servers using service account and you cannot use SQL integrated security to access database, you need to change:
"sqlintegratedsecurity": "false“ and update "sqluseraccount" and "sqluserpassword" with relevant information.
4) If you need to generate verbose logs in windows events for troubleshooting reasons change verboselog value from “false” to “true”. Please note that verbose logging can affect your servers’ performance, use it only for troubleshooting reasons. Don’t enable “verboselog” in production environments as it may reveal configuration secrets
5) Using SQL manager provision dbo access to “SecureMfaOTP” database for ADFS service account or SQL user.
Below is a sample of a SecureMfaEmailOtpProvider.json file
NOTE: Any configuration changes in json configuration file requires Install-SecureMfaEmailOtpProvider to be executed again.
SecureMFA Email OTP Provider Installation
Before a SecureMfaEmailOtpprovider will be invoked by AD FS, it must be registered in the system. with PowerShell command which performs the necessary installation actions including installation in the GAC, and registration in AD FS farm.
Primary ADFS node
Bellow command will install OTP authentication provider on the MAIN ADFS node.
Other ADFS node(s)
Bellow command will install OTP authentication provider on OTHER ADFS node(s).
NOTE: If you are using federation server farm that uses Windows Internal Database, you must start installation using the primary federation server of the farm as a MAIN node. Installation needs to be executed on ADFS farm server (not web application proxy servers).
To verify if “SecureMFA Email OTP Provider” has been installed successfully.
1) Open the AD FS Management Snap-in (from Server Manager Tools menu)
2) Click Authentication Policies at left
3) In the center pane, under Multi-Factor Authentication, click the blue Edit link to the right of Global Settings.
Under Select additional authentication methods at the bottom of the page, check if “Email Time Based OTP Authentication” is selected.
When you will login into your ADFS application which requires multifactor authentication user will be able to request an authorization code to an e-mail address which is registered with user’s Active Directory account.
Below is print screen of “SecureMFA Email OTP Provider”.
By default, authorization pass-code which will be send to user’s e-mail address is valid up to 1 minute.
User interface customizations
Licensed clients can customize providers text which is presented to the users during logon. You can use simple html code like links to provide users with self-service portal links etc. Text is configured in configuration file “SecureMfaEmailOtpProvider.json” .
SecureMfaEmailOtpProvider.json config settings for user interface customization:
"login_text": "Enter a code received from MFA Email Authenticator.”
You will have to chnage "ui_customization" to be "true" for this change to take effect.
This feature only works for licensed adapters. If you set “login_failures” to be more than a zero in SecureMFA data store you will see failed user authentication attempts. When user reaches “failedlogoncount” number of attempts set in “login_failures” value user’s account will be locked out for a period of time set in "lockout_minutes" . If you want to disable this feature you must set “login_failures” to zero. All values are configured in SecureMfaApiOtpProvider.json file.
SecureMfaApiOtpProvider.json config settings to enable 5 min lockouts for 15 failed OTP passcode attemps :
This feature allows to disable SecureMFA OTP account and immediately restricts MFA authentication without disabling user in Active Directory.
User will be getting following message If user’s SecureMFA OTP account has been disabled by support team.
How to disable SecureMFA OTP accounts please read “SecureMFA Support Tools” documentation.
Support tools are packaged into a separate PowerShell module which is used for OTP support and maintenance tasks.
Encryption only works for licensed adapters. AES 256-bit encryption is created with AesManaged class in the System.Security.Cryptography module: This class uses Windows CryptoAPI (CAPI) which uses FIPS-compliant .NET Assemblies. The cipher mode is Cipher Block Chaining (CBC). The passphrase can be configured in configuration file and it is recommended to be between 16-18 random characters. It is salted with 16 bytes string, zero padding and 4 key iterations. Full documentation on “AesManaged .NET class” can be found in Microsoft documentation for “System.Security.Cryptography.AesManaged “ constructors)
SecureMfaApiOtpProvider.json config settings to enable encryption:
When it is enabled your secret code is encrypted in Database and it looks like bellow.
Configure Allowed Domain List
When "ui_customization" is set to "true" you can add a list of custom domains or root domains which are allowed to receive OTP codes (You must use Semicolons to Separate a List values). This could be helpful if for security reasons you may need to restricts some domains to receive OTP tokens. Bellow is a sample of configuration in json file.
All successful second factor authentication sessions will issue a new Actual Authentication method value: http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod
Enable OTP Data Store in Microsoft Active Directory Attributes
This feature is only available for licensed OTP providers. It allows to store User OTP attributes in Active Directory domain. This removes dependency and cost of having MS SQL service configuration to store OTP database. To enable this feature, you have to update SecureMfaApiOtpProvider.json file to enable AD mode and update encryption passphrase with your custom string which will be used to encrypt secret data in AD attribute. AD mode doesn’t support unencrypted secrets.
You will have to execute following script “Create_SecureMFA_API_OTP _AD_attributes.ps1” which comes with OTP provider on Read-Write domain controller. You need to execute this script on Read-Write domain controller with AD account which is member of Schema Admins group. SecureMFA OTP provider when operates in AD mode it requires custom Active Directory (AD) attributes to be created to store OTP data for the user. This action cannot be undone and needs to be tested in your TEST domain first before moving into PRODUCTION. New AD Schema Attributes will be added into custom SecureMFA Auxiliary Class and that Class will be added into Existing User Class as AD Schema best practices suggest. OID numbers for custom attributes are from SecureMFA Private Enterprise range assigned by iana.org . Which do not overlap with other vendors OIDs numbers used to create custom AD attributes.
Note: THIS ONLY REQUIRES IF YOU PLAN TO RUN SecureMFA API OTP Provider in AD MODE.
Bellow print screen shows how AD user’s custom attributes will look like.
By default provider works with default SMTP TCP port 25 and anonymous authentication. You can update SMTP server’s hostname / VIP address and port number (if required) by updating bellow settings in Secure MfaEmailOtpProvider.json file. Change “smtp_mailfrom" address which will appear for users as reply address.
Licensed providers can enable Secure SMTP connection via SSL and use service account credentials for authentication, by updating bellow settings:
If you need to hide user’s account prefix information as additional security feature in authorization emails. Set “smtp_remove_user_prefix” in json config file to be “true”
Bellow pictures shows how authorization email looks like with enabled and disabled user’s prefix.
This feature is only available for licensed OTP providers. By default OTP time drift is allowed to be 30 seconds in the future and in the past as defined in RFC6238 , this makes provider to be compatible with other providers (SecureMfaOtp ) which allow to use QR apps on mobile device to generate OTP tokens. If your SMTP service cannot deliver OTP message within default timeframe you can increase OTP validity value by adding extra seconds, but this will break compatibility with other authentication providers indicated above.
SecureMfaApiOtpProvider.json config settings to enable 90 seconds time drift:
The below system events in Windows Event log may be used to verify and troubleshoot SecureMfa OTP Provider:
Log Name: AD FS/Admin
All provider related logs are stored in Windows Application Event logs and some data in SQL table or AD Attributes.
Windows Application Event:
Source: Secure MFA OTP
Patching and Upgrades
Provider is highly integrated with MS Framework classes and uses Windows OS components to deliver functionality.
To keep up to date with latest security updates you must constantly update your Operating System and MS Framework components using Microsoft Security updates.
For any feature updates please upgrade a provider by pulling latest version from PowerShell Gallery by using bellow command:
You’ll need to repeating all deployment steps as it was done for original installation. If it is highlited in deployment notes that attribute store needs to be extended for OTP data, you’ll need extra step to complete your upgrade.
· If you are using to store your user OTP data in MS SQL you may need to execute “sql_Upgrade_From_Previous_Version.txt” on your SQL database.
· If you are using to store your user OTP data in AD you may need to execute “Create_SecureMFA_OTP_AD_attributes.ps1” on your Domain controller. (this usually is highlighted in a new release documentation)
Files can be found in a directory with other installation files. This will add any extra missing columns/attributes in the Database or AD.
OTP Users Management
Support tools for OTP Users management are packaged into a separate PowerShell module which can be used for OTP accounts management tasks.
For more details please read “SecureMFA Support Tools” documentation.