Skip to content

Repository files navigation

Acknowledgement

This project builds on Stephan Traub's original provider v1.3.8.2.

Requirements

The .NET Framework 4.8 is required on the target machine. It is included in-box on Windows Server 2022 and newer, but not on Server 2016 (ships with 4.6.2) or Server 2019 (ships with 4.7.2) — installing the ADFS role does not add it. On those versions install .NET Framework 4.8 first (it is also commonly delivered via Windows Update). Install.ps1 checks for it and aborts with instructions if it is missing.

Configuration

Starting with v1.3.0, this provider can be used as primary authentication method in ADFS. However, ADFS will inject a form to request the username before this provider, even if it is configured as primary, which makes the experience of passkey usernameless authentication not great in ADFS. You could then choose to add "Forms Authentication" as additional, to have the password checked in the last step. Alternatively, have only this provider as primary and none as additional, if you are sure that there has been a multifactor authentication with this provider. This would be the case if you use passkey or webauthn with user_verification=required, because the PIN/Biometrics is the second factor.

The provider is configured using the registry. The keys are located at HKEY_LOCAL_MACHINE\SOFTWARE\Netknights GmbH\PrivacyIDEA-ADFS. After changing the configuration, the AD FS Service has to be restarted for the changes to become active. This can be done using the PowerShell command Restart-Service adfssrv.

Install.ps1 hardens the access control list on this key: by default HKLM\SOFTWARE grants the local Users group read access, which would let any non-admin on the machine read the service_pass in cleartext. After installation only SYSTEM, Administrators, and the AD FS service account can access the key. If you create the configuration key after running the installer, re-run Install.ps1 so the ACL is applied.

The service_pass is additionally encrypted at rest using Windows DPAPI. You can enter it as plaintext (via the installer dialog or directly in the registry); the provider encrypts it in place the first time it reads it, replacing the value with an enc:-prefixed ciphertext. To change it later, simply enter a new plaintext value — it will be re-encrypted on the next read. This protects the password in registry exports and backups; it is not a boundary against a local administrator, who on an AD FS server already controls the token-signing key.

DPAPI encryption is bound to the machine, so an encrypted value cannot be decrypted on a different server (e.g. after a restore, clone, or migration). On a new machine — including each node of an AD FS farm — enter the password again and it will be re-encrypted locally. The provider logs an event if it finds an enc: value it cannot decrypt.

Key Name Explanation
url The url of the privacyIDEA server. Has to include https://!
disable_ssl Set to 1 if ssl verification should be disabled. DO NOT DISABLE THIS IN A PRODUCTION ENVIRONMENT! While active, the provider writes a warning to the Windows Application event log on every service start, since disabling certificate validation leaves the connection to privacyIDEA open to interception.
debug_log Set to 1 if a detailed debug log should be written. By default it is located at C:\PrivacyIDEA-ADFS log.txt; use log_path to change the location.
log_path The full path of the file the debug log is written to when debug_log is enabled. Defaults to C:\PrivacyIDEA-ADFS log.txt. Missing parent directories are created automatically on the first write, provided the AD FS service account has permission to create them. If the location still cannot be written (e.g. insufficient permissions or an invalid drive), the provider logs a single error to the Windows Application event log and keeps retrying on subsequent writes.
enable_enrollment Set to 1 if users should automatically enroll a TOTP code if they do not have any other tokens enrolled. !!! This feature is deprecated in favor of server-driven enrollment (enroll_via_multichallenge, configured on the privacyIDEA server from v3.8.0), and will be removed in a future version of this provider. !!! Because it is deprecated, the installer does not offer it. The code still works, so set this registry value to 1 by hand if you need it.
realm Set the realm that should be appended to every request. If this is empty, the realm parameter will be omitted from requests.
service_user Set the username of a privacyIDEA service account that can be used to trigger challenges. Configuring this is only required to use the trigger_challenges or enable_enrollment settings!
service_pass Set the password of a privacyIDEA service account that can be used to trigger challenges. Configuring this is only required to use the trigger_challenges or enable_enrollment settings!
service_realm Set the realm of a privacyIDEA service account that can be used to trigger challenges. This realm setting can be used if the service account is found in a different realm than the other one specified.
trigger_challenges Set this to 1 to trigger challenges prior to the login using the configured service account. This setting takes precedence over send_empty_pass.
send_empty_pass Set this to 1 to send a request to validate/check with the username and an empty pass prior to the login. This can be used to trigger challenges depending on the configuration in privacyIDEA and requires no service account. If trigger_challenges is enabled, this setting has no effect.
use_upn Set this to 1 to use the Windows UPN (person@company.com) as the username for requests to privacyIDEA.
tls_version If you want to pin the TLS version, set it to tls12 or tls13. TLS 1.2 is the minimum; deprecated values (tls11 and older) are rejected — the provider logs a warning to the event log and uses the system-default negotiation (TLS 1.2/1.3) instead. Other/unrecognized values are ignored and the TLS version stays at the system default.
forward_headers If you want to forward specific headers to the privacyIDEA server, you can set them here. If the header does not exist or has no value, it will be ignored. The headers names should be separated with ','.
preferred_token_type Set the token type for which the UI should be first shown. This only matters if such token was triggered before. Possible values are otp, push or webauthn. The default is OTP mode. !!! This feature has been removed in v1.3.0 in favor of the preferred_client_mode policy in the privacyIDEA Server. !!!
auto_submit_otp_length Set an OTP digit count for which to automatically submit the form. Off by default. A form that submits itself while the user types fails the accessibility criterion WCAG 3.2.2 (On Input) and can surprise users. In privacyIDEA the field often holds the token PIN followed by the OTP, so a fixed length can also submit too early.
push_poll_interval The number of seconds between two push checks of the login page, a whole number from 1 to 60. The default is 3. Each check sends one request to AD FS and one to privacyIDEA for every user who waits for a push, so a small value adds load. See Push login.
disable_passkey Disable the "Passkey Login" button
otp_hint The hint that is shown in the input field. If the server sends no challenge message, the field also shows it as its label. The default is "One-Time-Password" in the language of the login page. A value that you set here is not translated.
forward_client_ip Set to 1 to forward the client IP to privacyIDEA (as the client parameter), so server-side policies can use it. See the security note below on trusted_proxies.
forward_client_user_agent Set to 1 to forward the client's User-Agent header to privacyIDEA.
trusted_proxies Comma-separated list of reverse-proxy IPs or CIDR ranges (e.g. 10.0.0.5, 192.168.10.0/24) that are allowed to set X-Forwarded-For. When set, the forwarded client IP is only trusted if the request actually arrived from one of these proxies. Strongly recommended whenever forward_client_ip is enabled — see the note below.
api_key API key that identifies this provider to privacyIDEA as an API client. Required for the "remember this device" feature (see below). Stored encrypted at rest (DPAPI), like service_pass.
enable_remember_device Set to 1 to turn on the "remember this device" feature in the plugin. Off by default. The feature also needs api_key and a server-side remember_device policy; all three are required (see below).

Domain to Realm Mapping

It is possible to map different Windows domains to different privacyIDEA realms. To achieve this, add the subkey HKLM\SOFTWARE\Netknights GmbH\PrivacyIDEA-ADFS\realm-mapping. Now you can add REG_SZ entries that have the name of the Windows domain and the value of the corresponding privacyIDEA realm. Note that the realm mapping takes precedence over the general realm that can be configured as explained in the previous section.

Forwarding the client IP (X-Forwarded-For) safely

X-Forwarded-For is set by the caller and can be forged. If privacyIDEA uses the client IP for policy decisions (geo-fencing, IP allow/deny lists, conditional MFA), a request that reaches AD FS directly could spoof this header and bypass those policies. To prevent that, set trusted_proxies to the IP(s)/CIDR(s) of your reverse proxy: the forwarded IP is then only trusted when the request actually originates from a listed proxy, and the real connection IP is used otherwise.

If trusted_proxies is left empty, the provider keeps the previous behavior of trusting X-Forwarded-For unconditionally — this is kept for backward compatibility but is not recommended when IP-based policies are in use.

Remember this device

The provider can offer a "remember this device" checkbox. When the user ticks it, a successful login stores a persistent cookie in the browser. On the next login from that browser, the second factor is skipped until the cookie expires or is revoked on the server.

The feature has three independent gates, and all of them are required. The feature stays off unless every gate is set, so it cannot activate by accident:

  1. Plugin switch: set enable_remember_device=1. Off by default. Without it the plugin does not even send the API key.
  2. API client: register this provider as an API client in privacyIDEA (client type privacyidea-cp). This gives you one API key. Set it as the api_key registry value.
  3. Server policy: create a remember_device policy (scope auth) on the server. The provider shows the checkbox only when this policy exists. The server also sets the cookie lifetime (remember_device_validity) and an optional per-user device cap (remember_device_max_devices).

The provider must also reach the server over https. The browser never talks to privacyIDEA directly, so the provider relays the cookie between the browser and the server.

The provider asks the server whether it offers the feature when AD FS starts. If the answer is no, for example because privacyIDEA was not reachable at that moment, the provider writes a warning to the event log and asks again during sign-ins, at most every 5 minutes. So you do not need to restart AD FS after you create the policy. If you remove the policy later, the server stops issuing and recognizing device cookies at once, and the checkbox disappears after the next AD FS restart.

Security notes:

  • Do not enable this when the provider is the primary authentication method. Recognition skips the factor this provider contributes. As an additional (MFA) provider it is the second factor, and AD FS already enforced the first factor before calling it. As the primary provider it is the only factor, so a recognised device would log in on the cookie alone.
  • The cookie is a rotating token. Each use issues a new value, and a replayed old value is treated as theft, which revokes the user's remembered devices on the server.
  • The cookie is Secure and SameSite=Lax (see the next section for why not Strict), but not HttpOnly. An AD FS adapter cannot set a response header, so the sign-in page sets the cookie with JavaScript, which cannot set HttpOnly. A cross-site-scripting flaw on the sign-in page could therefore read it. The rotating-token scheme limits the value of a stolen cookie.

The checkbox works for every login that finishes in the provider: one-time password, push, WebAuthn, passkey, and a passkey registration. The page reads the checkbox when it sends the result, so the box must be ticked before the WebAuthn or passkey prompt completes. If the server prefers WebAuthn, the prompt starts as soon as the page loads. To remember the device in that case, cancel the prompt, tick the box, and select WebAuthn again. For a passkey, tick the box before you select Passkey or Retry Passkey Login.

Why the cookie is SameSite=Lax, not Strict

The provider reads the device cookie only when AD FS asks for the second factor. In many sign-ins, that request is part of a navigation that started on another site:

  • The user comes from Microsoft 365 (login.microsoftonline.com) or from a relying party on another domain, and is redirected to AD FS.
  • AD FS accepts the first factor without showing its own login form, for example with Windows Integrated Authentication (Kerberos) on the intranet, or with an existing AD FS single sign-on session.

Browsers do not send a SameSite=Strict cookie on a navigation that started on another site. With Strict, a remembered device would therefore never be recognized in these sign-ins, and the second factor would be asked every time. It would work only when the user types the password into the AD FS login form, because that form posts to AD FS itself.

With SameSite=Lax, the browser sends the cookie on top-level navigations from other sites, so recognition works in these sign-ins too. The browser still does not send it on cross-site POST requests, inside frames, or with images, scripts and other requests that another site embeds.

What this means:

  • A sign-in that another site starts can complete without a second-factor prompt when two things hold: the browser has a valid device cookie for the user, and AD FS accepts the first factor without user interaction (for example Windows Integrated Authentication). Skipping the second factor on a remembered device is the purpose of the feature. The security token that AD FS issues still goes only to the relying party's registered reply address, never to the site that started the sign-in.
  • The first factor is still checked by AD FS on every sign-in. The device cookie replaces only the second factor.
  • The cookie is bound to the user and rotates on every use. A copied cookie works at most until its next use, and a replayed old value revokes all of the user's remembered devices.

If you do not want a remembered device to skip the second factor in sign-ins that AD FS completes without user interaction, do not enable the feature for the users or realms concerned. The remember_device policy on the server controls who can use it.

Languages of the login page

The login page is available in English, German and French. AD FS chooses the language of the sign-in page from the browser language and passes it to the provider. Every German and French regional variant uses the German or French texts. Any other language gets the English texts.

The messages that the privacyIDEA server sends, for example the challenge text of a token, come from the server. The provider forwards the browser's Accept-Language header, so the server translates them. A value that you set in otp_hint is shown as it is.

Push login

AD FS calls the provider only when the login page posts its form. So the page cannot wait for a push confirmation in the background: it posts itself on a timer, and each post asks privacyIDEA once whether the user confirmed the push.

  • The page checks every push_poll_interval seconds, 3 by default.
  • After each check, the keyboard focus goes back to the control that had it, so a keyboard user can continue to another login option.
  • The user can select Stop automatic check. The page then shows I confirmed on my device, which checks once per press.
  • The page stops the automatic checks by itself 5 minutes after the first check. An expired push never becomes confirmed, and an abandoned page would otherwise post forever.
  • If the user declines the push on the device, or cancels it, the page says so and stops checking. The other login options stay available. If the user has push tokens on more than one device, the page keeps checking after a decline, because the user can still confirm on another device. This needs privacyIDEA 3.10 or later for a declined push, and 3.14 or later for a cancelled push. With an older server the page keeps checking until the time limit.

Client JavaScript requirements

The login page uses JavaScript for the modern token types and for convenience features. One-time-password and push login do not need it.

The page script is plain ES5, so it also runs in Internet Explorer 11 and in the legacy Edge engine (EdgeHTML 18) that older Office sign-in windows embed. Internet Explorer 11 has no WebAuthn API, so the page hides the security key and passkey options there. One-time password, push and "remember this device" work. CI checks every change to the page script with the Internet Explorer script engine (tools/Check-AuthPageEcmaScript.ps1).

The page falls back to the no-JavaScript form described below in two cases: when JavaScript is disabled, and when JavaScript is on but the page script cannot run to the end (for example in an engine that cannot parse it).

Works without JavaScript:

  • One-time-password entry. The user types the OTP and selects Submit. This covers HOTP, TOTP, and any challenge-response token whose answer is an OTP (email, SMS).
  • Push login, through a manual "I confirmed on my device" button. With JavaScript the page polls automatically (see Push login). Without it, each button press polls the transaction once.
  • Switching between one-time password and push. When both are offered, the page shows a "Use push" or "Use one-time password" button, so the user can change token type without JavaScript. "Use push" is shown in every mode other than push (one-time password, WebAuthn, an enrollment), so no-JavaScript push works whenever a push token is triggered, not only when the server sets preferred_client_mode=poll.
  • The enrollment QR code shown by enroll_via_multichallenge. The user scans it, then enters the resulting OTP.

Needs JavaScript (hidden when it is disabled):

  • WebAuthn and passkey, including the buttons that switch to them. They also require a browser that supports the WebAuthn API and a secure https context.
  • "Remember this device". The provider cannot set a browser cookie from an AD FS adapter, so the page stores the device cookie with JavaScript. Without JavaScript the checkbox is not shown. The browser still logs in, but the device is not remembered.
  • The "Not Now" button that skips an optional enrollment (enroll_via_multichallenge with the optional setting). Without JavaScript the user cannot skip, and completes the enrollment.
  • The "copy to clipboard" button for the enrollment code.

This matters for clients that do not run page JavaScript, such as a legacy embedded WebView (for example Outlook's) or a passive federation flow like device registration and Windows Hello for Business provisioning. Those clients can complete one-time-password and push login.

Installing, upgrading and uninstalling

The MSI runs Install.ps1 and Uninstall.ps1 from the installation folder. You can also run them by hand.

Install. Install.ps1 puts the provider into the GAC and registers it with AD FS. After the first installation, enable it as a second factor: AD FS Management > Authentication Methods > Additional Authentication Methods, or Set-AdfsGlobalAuthenticationPolicy -AdditionalAuthenticationProvider. AD FS ties a registration to one assembly version. If another version of the provider is registered, for example after the DLL was replaced by hand, Install.ps1 replaces that registration and keeps the provider in the authentication policy lists it was in. Running Install.ps1 again with the same version changes nothing except the access control list of the configuration key.

Upgrade. Run the new MSI. It removes the old version and installs the new one.

  • From 1.5.0 on, the upgrade keeps the provider enabled: the old version's uninstall records the global authentication policy lists that contain the provider (policy_membership in the configuration key), and the new version's install puts it back into the same lists.
  • Upgrading from 1.4.x or older: the old version's uninstaller takes the provider out of the global authentication policy and does not record it. After the upgrade, enable the provider again as an additional authentication method (see Install). Until you do, AD FS does not offer it as a second factor.
  • A newer build of the same version, for example a test build or a rebuilt release, also replaces the installed build. Windows Installer ignores the fourth version field, so 1.5.0.0 and 1.5.0.1 count as the same version. A side effect: an older build of the same version also replaces a newer one.

Uninstall. The uninstall takes the provider out of the global authentication policy lists, unregisters it, and then removes the assembly from the GAC. If AD FS refuses to unregister it, the uninstall stops with an error before anything is removed, and the provider stays installed and working. This prevents an AD FS registration that points to a removed assembly, which would break every sign-in that uses the provider. Make sure that the AD FS service runs and that no authentication policy still requires the provider, then run the uninstall again.

Signing and verifying the installer

The dll that is created by this solution requires to be strong-name signed to be deployed. Change the key file to your own in the project settings of the provider.

Officially distributed installer packages are additionally Authenticode code-signed. Before deploying a release, verify the signature on the .msi:

  • PowerShell: Get-AuthenticodeSignature .\<installer>.msi — Status must be Valid, and confirm the listed signer matches the publisher you obtained the package from.
  • Or right-click the file → Properties → Digital Signatures.

Do not install a package whose signature is missing or invalid.

A Software Bill of Materials (CycloneDX bom.json) listing the third-party components is generated by CI and attached to published releases (see .github/workflows/ci.yml).

Windows Server 2019

If you use a Windows Server 2019 please activate TLS 1.x for your .NET because TLS 1.0 is deprecated. Adding "SchUseStrongCrypto"=dword:00000001 to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v4.0.30319 and HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft.NETFramework\v4.0.30319 fixes the problem.

Event Log

Errors will be written to the Windows Application event log under the privacyIDEAProvider source. To get a more detailed log, activate the debug_log setting as explained in the next section.

Logging and personal data

The detailed debug log (debug_log, written to C:\PrivacyIDEA-ADFS log.txt) is off by default and should only be enabled while troubleshooting. When enabled, it contains personal data and should be treated accordingly:

  • Usernames, UPNs and domains are recorded so that an authentication can be traced end to end. This is required for the log to be useful for diagnostics and for security auditing.
  • Full server responses from privacyIDEA are recorded as well; these may include token serials and any user attributes the server returns.
  • Secrets are masked. The service account password (password), the user credential (pass, which in privacyIDEA carries the static PIN in front of the OTP), the Authorization header (JWT), the X-API-Key header (api_key) and the Cookie header (a presented remember-device token) are redacted before anything is written. One-time values such as transaction IDs are not secrets and are logged in clear text.

This log lives on your own AD FS server and is under your control as the data controller. To meet your obligations (GDPR / ISO 27001):

  • Keep debug_log disabled in normal operation and re-disable it once a problem is resolved.
  • Restrict read access to the log file to administrators, and define a retention period after which it is deleted.
  • Treat the file as in scope for your access-control, retention and audit-logging controls.

Debugging

Errors in the provider can be found by looking at the Windows Event Log or activating the debug_log setting. If the installer fails to install/uninstall the Provider, a logfile for that process can be created using the cmd:

install: msiexec /i ADFSProvider.msi /L*V install.log

uninstall: msiexec /x ADFSProvider.msi /L*V uninstall.log

The problematic part will probably be found in the last third of the log file.

If the provider fails to uninstall, you can uninstall it manually by navigating to C:\Program Files\PrivacyIDEA AD FS\ and run the uninstall script. Doing this will leave the registry untouched and the provider in the installed software list. To remove it from the list, remove it's registry entry at HKLM\SOFTWARE\Classes\Installer\Products\.

Releases

Packages

Used by

Contributors

Languages