Authentication and single sign-on
Teams authentication runs inside the Electron session that hosts the Teams workspace. The application supports normal web sign-in, HTTP Basic or NTLM prompts, optional credential prefill, hardware security keys, and corporate client certificates while keeping secret entry outside the Teams page where possible. The result is an authenticated Teams session whose cookies and token state can be reused by the workspace.
Authentication boundary
The authentication boundary separates the Teams web page from native app services. Teams starts the sign-in flow in the main window or an authentication popup. The main process handles native prompts and protected operations, while small preload bridges expose only the action needed by each page.
The main login dialog is a short-lived modal window for HTTP Basic or NTLM challenges. Its form sends only a username and password through the submitForm IPC channel. The preload at app/…/preload.js exposes window.api.submitForm instead of giving the form direct access to Electron or Node APIs. After the main process passes the credentials to Chromium, it closes the dialog and does not cache the values. app/…/index.js
The normal Teams window has a broader preload because it hosts the product as well as sign-in pages. Authentication-specific actions still pass through the main process. For example, the WebAuthn browser bridge is loaded by the browser preload and forwards hardware-key requests to guarded main-process handlers. app/…/preload.js
This diagram shows the boundary between a sign-in page, the preload layer, the main process, and the resulting Teams session.
flowchart LR
Page[Teams or identity-provider page]
Login[Short-lived login dialog]
Preload[Preload bridge]
Main[Electron main process]
Native[Native auth service or device]
Session[Teams session cookies and tokens]
Page -->|web sign-in| Main
Page -->|WebAuthn request| Preload
Login -->|submitForm| Preload
Preload -->|validated IPC| Main
Main --> Native
Main -->|auth response| Page
Page --> Session
References: app/…/index.js• L19-59 app/…/preload.js• L1-7 app/…/preload.js• L434-463
Sign-in completion flow
The sign-in flow begins when Teams needs an interactive response. The main window registers a Chromium login handler for HTTP authentication challenges. The handler prevents Chromium from showing an uncontrolled prompt, then uses configured Basic or NTLM credentials when available or opens the native login dialog for the user. app/…/index.js, app/…/index.js
The handler treats the first challenge for each web contents instance as the active sign-in attempt. If the supplied or entered credentials fail and Chromium asks again, the app relaunches instead of reusing a closed dialog. This keeps a failed secret from being silently retried and keeps challenge state separate between profile-backed workspaces.
The web sign-in path can also use Microsoft or a federated identity provider directly in the Teams window. The app recognizes the Microsoft login hosts for login-related popup and frame handling. A normal authentication popup is allowed to complete its web flow. A popup that follows a trusted stale-session failure can instead trigger in-app recovery so the result returns to the Teams window rather than an external browser. app/…/index.js, app/…/index.js
When an existing session has stale authentication state, recovery clears the relevant local token state and authentication cookies, then reloads Teams. This forces a fresh interactive sign-in. The startup path also removes expired authentication cookies before the first Teams load so old state does not leave a misleading sign-in banner. app/…/index.js, app/…/index.js
The sign-in sequence has these high-level stages:
- Teams or Chromium requests an authentication response.
- The app keeps the request in the Teams session or opens a controlled native prompt.
- The user, a configured credential source, or a native authentication device supplies the response.
- The response returns to the login page and Teams stores the resulting session state.
- A failed or stale session either asks again through the normal web flow or starts a clean recovery reload.
References: app/…/index.js• L638-673 app/…/index.js• L787-846 app/…/index.js• L1280-1325 app/…/index.js• L61-92
Web sign-in prefilling
Web sign-in prefilling reduces repeated typing for tenants that expire Teams sessions often. The ssoPasswordPrefill service watches only HTTPS pages on known Microsoft login hosts or explicitly configured federated hosts. It fills an empty account field, obtains the first line of a password-manager command when configured, and can advance the email, password, and MFA method steps. app/…/index.js
The password command runs in the main process. Its output is used only to set the password field in the current recognized login page. The app does not store the password. Each navigation starts a new guarded attempt, which matters because Microsoft sign-in can move through several pages and frames before the Teams session is complete. app/…/index.js, app/…/index.js
The feature is optional and is attached when the main window is ready. Its controls are separate from the Basic or NTLM dialog settings: web login settings act on Microsoft or federated HTML forms, while the native login dialog handles Chromium HTTP authentication challenges. app/…/index.js, app/…/options.js
| Setting | Session effect |
|---|---|
auth.webLogin.user | Prefills an empty account field. |
auth.webLogin.passwordCommand | Supplies the first output line to the password field. |
auth.webLogin.autoSubmit | Advances the account and password steps after stable field values. |
auth.webLogin.verifyMethod | Selects a matching MFA method when the method page appears. |
auth.webLogin.extraHosts | Adds HTTPS federated hosts that may receive the prefill action. |
References: app/…/index.js• L3-41 app/…/index.js• L280-415 app/…/index.js• L1390-1402 app/…/options.js• L1041-1054
WebAuthn security keys
WebAuthn lets a user register or use a hardware security key during Microsoft or federated sign-in. On Linux, the app provides the missing hardware path through fido2-tools; on macOS and Windows, Electron's Chromium handles WebAuthn natively. The feature is enabled only when configured and when the Linux tool is available. app/…/index.js, app/index.js
The browser bridge covers both the main page and login iframes. The preload intercepts public-key credential calls in the main frame. For a login iframe, an injected bridge relays the request through postMessage, and the main process checks both the outer and actual frame origins before it signs anything. Only the built-in Microsoft HTTPS origins and exact configured extra origins are accepted. app/…/webauthnOverride.js, app/…/webauthnOverride.js, app/…/index.js
The main process turns the browser request into a hardware-key operation. If the ceremony needs user verification, it collects the security-key PIN in an isolated prompt before the device call. It then shows a separate waiting prompt while the key waits for a touch. A cancel action aborts the in-flight operation, and the prompt closes for success, failure, or timeout. app/…/index.js, app/…/pinDialog.js, app/…/touchPrompt.js
The WebAuthn path therefore preserves the browser contract while moving device access to a native boundary:
sequenceDiagram
participant Login as Login page
participant Bridge as Preload or iframe bridge
participant Main as Main process
participant Prompt as PIN and touch prompts
participant Key as Security key
Login->>Bridge: navigator.credentials.create/get
Bridge->>Main: IPC request with allowed origin
Main->>Main: Check origin and ceremony type
Main->>Prompt: Request PIN when needed
Prompt-->>Main: PIN or cancel
Main->>Prompt: Show waiting-for-key prompt
Main->>Key: Perform credential or assertion operation
Key-->>Main: WebAuthn response
Main-->>Bridge: Browser-shaped response or error
Bridge-->>Login: Complete sign-in ceremony
References: app/…/webauthnOverride.js• L41-126 app/…/webauthnOverride.js• L128-161 app/…/index.js• L83-185 app/…/index.js• L333-384 app/…/pinDialog.js• L39-106 app/…/touchPrompt.js• L36-113
Client certificate authentication
Client certificates support corporate sign-in schemes that identify the user or device during TLS authentication. The app can import a configured PKCS#12 certificate before the Teams window loads. The certificate then belongs to the session and can be offered when the identity provider requests it. app/…/index.js, app/…/options.js
Smartcard-backed certificates add a PIN step on Linux. When the feature is enabled, the app registers the client-certificate password handler before the first TLS handshake. Chromium asks the handler for the smartcard PIN, and the app shows a secure prompt instead of leaving the request without a response. macOS and Windows use their native PIN prompts. app/index.js, app/…/index.js
The prompt rejects on cancel and stops after three submitted PINs for one token in a session. This prevents an accidental loop from spending the card's retry budget. A wrong PIN produces a retry warning; a successful PIN lets the certificate handshake continue. app/…/index.js, app/…/index.js
Certificate trust and client identity are separate concerns. The custom CA allowlist can trust a user-approved issuing authority for enterprise TLS connections, including profile sessions. It does not replace the client certificate or its smartcard PIN. app/…/index.js, app/…/index.js
References: app/…/index.js• L928-945 app/index.js• L684-695 app/…/index.js• L31-90 app/…/index.js• L47-65 app/…/index.js• L129-145 app/…/options.js• L289-301
Related workspace behavior
Authentication state belongs to the session that loads a Teams workspace. Window and navigation policy decide whether an authentication popup stays inside the app or is sent to an external browser. Profile workspaces use separate session partitions, so their sign-in state and first HTTP authentication challenge remain isolated. See Application lifecycle and workspace shell for startup ownership, Desktop window management and navigation for popup and navigation policy, and User profiles and workspace switching for profile-backed session separation.
References: app/…/index.js• L5-10 app/…/index.js• L1280-1325 app/…/index.js• L5-10 app/index.js• L691-716
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the login dialog's preload contract aligned with the single
submitFormlistener and its active dialog target. - Keep the WebAuthn origin set aligned between the main-process IPC check and the browser preload's iframe relay.
- Keep the actual iframe origin in the WebAuthn request so the identity provider verifies the origin that started the ceremony.
- Register client-certificate PIN handling before the first TLS handshake and keep Linux-only setup separate from native prompts on other systems.
- Keep web-login host checks HTTPS-only and update both default host lists when Microsoft changes its sign-in endpoints.
- Treat profile session creation as part of authentication scope because each profile can hold separate cookies and challenge state.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The login dialog sends credentials through an unapproved renderer path. | The credential can become visible to the Teams page or to arbitrary renderer code. | The dialog exposes only submitForm through its preload and the main process owns the callback. |
| A WebAuthn request comes from an unapproved or missing origin. | The sign-in ceremony is rejected before the key signs data. | The main process checks both the sender origin and the actual frame origin against the exact HTTPS allowlist. |
A federated identity provider is not in auth.webauthn.extraOrigins. | The provider's security-key prompt is blocked even when the key works. | Add the provider's exact HTTPS origin and restart the app. |
Linux lacks fido2-tools while WebAuthn is enabled. | Hardware-key sign-in is unavailable and the browser request fails. | The app checks tool availability before registering WebAuthn handlers. |
| A user cancels or repeatedly submits a smartcard PIN. | The certificate request stops, or the token is protected from more PIN attempts after the session cap. | Cancellation rejects the request and the handler caps submitted PINs per token. |
| A session keeps expired auth cookies or stale token state. | Teams shows a stale sign-in banner or cannot complete silent renewal. | Startup cleanup and opt-in recovery clear stale state and reload the Teams session. |
Key files
| File | Why to read it |
|---|---|
| app/…/index.js | Main login window lifecycle and HTTP Basic or NTLM challenge handling. |
| app/…/preload.js | Narrow credential form bridge for the login dialog. |
| app/…/index.js | Teams session setup, auth popup policy, recovery reload, certificate import, and SSO attachment. |
| app/…/index.js | Safe scope and page-by-page behavior for web sign-in prefilling. |
| app/…/webauthnOverride.js | Browser-side WebAuthn interception and iframe relay. |
| app/…/index.js | Main-process origin checks and security-key ceremony coordination. |
| app/…/pinDialog.js and app/…/touchPrompt.js | User prompts that support PIN entry and key touch during Linux ceremonies. |
| app/…/index.js | Linux smartcard client-certificate PIN handling and retry protection. |
| app/…/index.js | Custom certificate-authority trust checks for enterprise TLS. |
| app/…/options.js | User-facing controls for Basic or NTLM SSO, web login, WebAuthn, and client certificates. |