Dify Enterprise SSO with Microsoft Entra ID

Entra ID SAML sign-in for Dify Enterprise, planned so workspace and web app access follow your identity provider, with the iframe restriction that affects embedded apps covered up front.

On this page

How Entra ID SAML sign-in fits Dify Enterprise

If your organization runs self-hosted Dify and wants Microsoft Entra ID to control sign-in, the first thing to know is that Dify Enterprise supports SAML, OpenID Connect and OAuth2 with Entra ID as a named identity provider. Dify Enterprise keeps workspace access and web app access under separate SSO scopes, so you decide who can sign in to the console and who can reach a published app as two distinct policies. The Community edition does not carry SSO at all. It is free and limited to a single workspace, so an Entra ID connection requires an Enterprise license before any other setup begins.

Because the two scopes are configured separately, plan them as two decisions rather than one. Workspace sign-in governs builders and administrators who edit prompts, workflows and knowledge bases. Web app sign-in governs the people who only use a finished app. Each scope needs its own application registration or callback configuration in Entra ID, so ask your Dify Enterprise contact to confirm the exact callback values for each scope before you create anything in your tenant. Also confirm which protocol the current Enterprise release expects for Entra ID, since the SSO introduction lists more than one option. The Dify Enterprise SSO introduction is the right starting point for the scope and protocol matrix.

The SAML path also depends on decisions outside Dify. Your Entra ID tenant owns the signing certificate, the attribute claims that Dify maps to user identity, and the assignment of users and groups to the enterprise application. Decide early who holds those Entra ID roles, how certificate rotation will be scheduled, and whether a break-glass administrator exists that does not depend on Entra ID. Changing the SECRET_KEY after deployment logs out all users, so keep that value stable through any SSO cutover. Record each decision in your change plan before the configuration work starts.

What you need before configuring Entra ID

Entra ID sign-in only works once the Dify Enterprise platform, a public console hostname and a tenant with the right app registration rights are in place. The decisions on workspace and web app access should be made before anyone opens the Entra admin center, because they shape the app registrations and the users who reach each surface.

Dify Enterprise platform baseline

Dify Enterprise is deployed on Kubernetes, so the cluster must run Kubernetes 1.24 or later and be managed with Helm 3.14 or later. Plan PostgreSQL 14 or later, Redis 6 or later, a Qdrant vector database and S3-compatible or cloud object storage. The production example in the resources checklist uses six worker nodes with 8 CPUs and 32 GB of RAM each, and a three-node Qdrant cluster. Confirm sizing against your own load, not only the example.

Public HTTPS hostname for the console

Entra ID redirects users back to the Dify console after sign-in, so the console needs a stable public HTTPS hostname that matches the redirect URIs you register. Decide the hostname, issue a certificate you control, and point DNS at the ingress before registration. Changing the hostname later means updating the Entra registration and the Dify settings together, and users with bookmarks will need to sign in again.

Entra ID tenant and app registration rights

Someone must hold rights in the Microsoft Entra tenant to register enterprise applications, configure SAML single sign-on, and assign users or groups. Confirm with your Microsoft account team and your tenant administrators which roles and license tier your organization has, because these requirements vary and should not be assumed. Agree who owns the registration, who approves changes, and where the signing certificate will be stored.

Workspace access scope decision

The Dify SSO documentation separates workspace access from web app access, so each has its own sign-in scope. Decide which Entra users and groups may sign in to the Dify console and build apps, and which roles they receive once inside. Keep this list short and group-based. Record the decision, because it determines which users and groups you assign to the enterprise application.

Web app access scope decision

Published web apps can be opened to a different audience from the console. Decide whether apps will be limited to named members or groups, all platform members, or external users, and whether any app needs to be embedded in another page. Embedding matters because Entra ID blocks its sign-in pages inside iframes, so the embedding design must be settled before you configure sign-in.

Configure Entra ID SAML for Dify Enterprise in order

This sequence takes a Microsoft Entra ID tenant from an empty enterprise application to working SAML sign-in for a Dify Enterprise workspace, with a separate path for web app scope if you use it. Each step ends with a check, so a fault is caught where it was introduced.

  1. Record the Dify SSO values for your version

    Open the Dify Enterprise SSO documentation for the version you have installed and copy the assistance-page values exactly: the assertion consumer service (ACS) URL, the entity ID and any scope-specific settings. Versions differ, so do not reuse values from an older guide or a blog post. The platform engineer or identity lead owns this sheet. You know it is done when the values sit in one written reference that the Entra administrator and the Dify administrator both sign off on.

  2. Create the Entra enterprise application with SAML

    In the Entra admin center, create a non-gallery enterprise application for Dify, then open its single sign-on settings and choose SAML. Enter the ACS URL and entity ID from your value sheet character for character, since a trailing slash or a mismatched scheme will stop the exchange. The Entra administrator completes this step. You know it is done when the basic SAML configuration saves without error and the values displayed match the sheet.

  3. Map NameID and user attributes

    Set the NameID format and source attribute to match what the Dify documentation specifies for account matching. Confirm which attribute Dify uses to link an incoming sign-in to a user record, since many deployments rely on the user's email address, and add any additional claims the docs list. Keep the claim names exactly as written in the docs. You know it is done when a decoded test SAML response, captured with a browser developer tool or a SAML tracer, shows the expected NameID and attribute values for a test user.

  4. Assign users and groups to the application

    Assign the Dify enterprise application to the users or security groups that should reach the platform, and leave everyone else unassigned. Decide whether nested groups are needed and whether the assignment should require user assignment in Entra. The identity administrator performs this step with the Dify workspace owner. You know it is done when a test user from an assigned group appears in the application's user list and an unassigned test account is blocked at the Entra sign-in page.

  5. Enter Entra metadata into Dify workspace SSO

    Download the federation metadata or copy the Entra login URL, Entra identifier and signing certificate from the SAML configuration, then paste them into the workspace-scope SSO settings in Dify Enterprise. Save the configuration while a second administrator session stays open, so a mistake does not lock every admin out. The Dify workspace administrator completes this step. You know it is done when Dify shows the SAML provider as saved and the signing certificate matches the one shown in Entra.

  6. Repeat the configuration for web app scope

    If you plan to control access to published web apps through SSO, repeat the configuration for web app scope using the values the Dify documentation gives for that scope. Treat it as its own configuration, with its own callback values and its own Entra application if the docs call for one, and do not assume the workspace settings carry over. The identity administrator and the Dify app owner should agree on which users reach which apps first. You know it is done when the web app scope shows its own saved provider and its values match the documentation for your version.

  7. Test sign-in in a top-level browser window

    Sign in with an assigned user, an unassigned user and a user from a different group, using a fresh browser session for each. Open sign-in in a top-level browser window, because Entra blocks its sign-in pages from loading inside an iframe, so a web app embedded in another site may fail to complete SSO even when the configuration is correct. Record which flows work and which fail. You know it is done when the assigned user lands in Dify, the unassigned user is refused, and any embedded failure is reproduced and written into the runbook with a decision on how to handle it.

How a Dify sign-in travels between Entra ID and Dify

A Dify sign-in is a chain of handoffs, and each one needs an owner on your side. When a user opens the Dify console, Dify does not check a password itself. It redirects the browser to Microsoft Entra ID, which authenticates the user under the policies your tenant enforces, such as multifactor authentication and conditional access. Entra then returns a signed SAML assertion through the browser to Dify's assertion consumer endpoint. Dify validates the signature against the certificate you registered, reads the subject and attributes, and either matches an existing account or creates one. Before you configure the Entra enterprise application, confirm the endpoint URLs, the attribute names Dify expects and the account-matching rule in the Dify Enterprise SSO documentation. A mismatch here usually produces a failed login with little detail.

After the assertion is accepted, Dify issues its own session, and this is where SECRET_KEY matters. The environment reference says SECRET_KEY signs session cookies and JWTs and encrypts OAuth credentials. Entra's own sign-in lifetime does not set how long a Dify session stays valid, so confirm the session lifetime setting for your Enterprise version and align it with your policy for administrators and build users. Generate SECRET_KEY once, store it in your secrets manager and treat it as a deployment secret. Changing it after deployment logs out all users, so schedule any rotation as a maintenance event and tell users in advance.

Session behavior also shapes offboarding. Disabling a user in Entra stops new sign-ins, but a Dify session that is already open remains valid until it expires. Ask your team to confirm how Dify handles existing sessions when an account is disabled or removed, and document the maximum window in which a leaver could still reach the console. If that window is too long for your regulated users, plan for shorter session lifetimes and for the provisioning work covered in the SCIM section of this page.

Entra ID attributes and groups mapped to Dify identities

This table pairs each identity element in a Microsoft Entra ID SAML sign-in with where it comes from in Entra and what to confirm in Dify Enterprise. Read it before you configure the enterprise application, because the account key and group claims are hard to change once users have signed in. Treat each Dify mapping as a check to complete against the Dify Enterprise SSO documentation and your Entra attribute configuration.

Identity elementEntra ID sourceDify mapping to confirm
SAML NameIDFormat set on the enterprise application, such as persistent or emailConfirm which value Dify uses as the account key and test one sign-in before rollout
Email claimUser mail or UPN attribute emitted as an email claimConfirm the claim name Dify expects and whether it matches existing accounts
Stable unique identifierEntra object ID, which does not change when a user is renamedPrefer a stable value if Dify allows it; email and UPN can change
Group claimSecurity groups added to the SAML token, by group ID or nameConfirm whether Dify reads group IDs or display names and test users in many groups
Workspace roleDedicated Entra groups for builders, deployers and viewersConfirm how Dify assigns roles on first sign-in and on later group changes
Web app accessSeparate groups or app role assignments for web app usersConfirm these map to the web app SSO scope, separate from workspace access
Assignment enforcementUser assignment required setting on the enterprise applicationConfirm that unassigned users are refused before reaching Dify
Leaver handlingGroup removal or account disablement in EntraConfirm how existing Dify sessions end and whether SCIM is needed for deprovisioning

Why Entra blocks SSO pages in iframes and what it means for embedded apps

Why does Microsoft Entra ID refuse to show sign-in pages inside an iframe?

Entra ID restricts its sign-in pages from being rendered inside a frame on another site, a control that protects users against clickjacking and credential phishing through embedded pages. When a Dify web app is placed in an iframe on another product's page, the browser attempts to load the Entra login screen inside that frame, and the sign-in fails or shows an error instead of the login form. The exact response headers and frame rules Entra applies can change, so confirm the current behavior with Microsoft's documentation or a test tenant before you commit the design. The restriction applies to the identity provider's pages, not to the Dify app's own pages.

What breaks when a Dify web app is embedded in another product's page?

The embedded app loads, but any request that needs a Dify SSO sign-in redirect to Entra fails inside the frame. Users see a blank or error panel where the chat or workflow should be, and support teams often read this as a Dify fault. The failure appears only after the session expires or when a user has no existing Entra session in that browser, so it can pass a quick test by a signed-in tester. Check the embedding flow with a fresh browser profile and with an expired session before launch.

Can a Dify web app embedded in an iframe still use Entra SSO?

Usually not without changing how sign-in happens. Teams normally choose one of three options and evaluate each against their product and user base:

Should embedded Dify apps open in a new window or tab?

Opening the app in a new window or tab is the simplest option because the Entra sign-in runs at the top level of the browser, where it is permitted. The trade-offs are a visible context switch for users, a need to pass the user's context to the app if it should be personalized, and a separate browser session that must be handled carefully on shared devices. Confirm with your product owners whether users can accept leaving the host page, and test the return path after sign-in.

How does a top-level redirect work for embedded Dify apps?

A top-level redirect moves the whole browser tab to the Dify sign-in flow, then returns the user to the host page or the app. It keeps the user in one tab, but the host product must handle the redirect cleanly, preserve any unsaved state, and return the user to the right place after Entra authenticates. Engineers should test the callback URLs for each Dify scope, since workspace and web app access use separate SSO scopes. Plan for the case where the user's Entra session has expired mid-task.

When is a different sign-in method better for embedded use?

A different sign-in method fits embedded use when the audience is external or when embedding needs to be seamless and the frame restriction cannot be worked around in the host product. Options to evaluate include a separate identity provider configured for web app access, or a token-based handoff from the host product, which must be designed with your security team. Dify's Enterprise SSO documentation lists OpenID Connect, SAML and OAuth2 protocols, so confirm which methods your Dify Enterprise edition supports for each scope before choosing. Keep staff sign-in on Entra for workspace access where possible.

Can our own team handle this, or do we need a partner?

Your team can handle this if it already runs Entra and Dify, has an owner for both the host product and the Dify app, and can test the embedded flow across browsers. A partner is useful when the choice of embedding pattern affects product architecture, security review or several identity providers at once. Most DeployOpen engagements are fixed-scope, with the embedding options, deliverables and timeline agreed in writing before work starts. The cost depends on how many embedding paths and identity scopes are in scope.

What should we ask a vendor or partner before choosing an embedding approach?

Ask how the proposed approach handles Entra's frame restrictions in current browsers, which Dify SSO scopes each step uses, and how the callback and return paths are tested. Ask who owns the host product changes, how session expiry and shared devices are handled, and what happens when Entra behavior changes. Request a written scope listing the embedding option chosen, the test cases, and who confirms the current Microsoft behavior before launch.

Hardening the Entra ID integration

Getting Entra ID sign-in working is only the first step. The controls below decide whether the integration stays safe after go-live, covering certificates, assignment, secrets, leaver handling and where sign-in traffic travels. Review them together, because a gap in one area, such as an expired certificate or a stale account, undermines the others.

Track signing certificate expiry

The SAML signing certificate that Entra ID uses to sign assertions has a fixed validity period, and when it expires sign-in to Dify Enterprise fails for every user at once. Record the expiry date in your change calendar, and plan the rotation so the new certificate is added to the Dify SAML configuration before Entra switches to it. Confirm with your Entra administrator whether the tenant sends renewal notifications to a named mailbox, and make sure that mailbox is monitored by someone other than the person who configured the integration.

Restrict assignment to named groups

In the Entra enterprise application, turn on user assignment required so that only users or groups you assign can sign in through Dify. Without it, any account in the tenant may be able to reach the sign-in flow. Assign Dify access through groups that map to your workspace roles, and review those groups on a fixed schedule so that people who change teams lose access they no longer need.

Keep SECRET_KEY unchanged

The Dify environment reference states that SECRET_KEY signs session cookies and JWTs and encrypts OAuth credentials, and that changing it after deployment logs out all users. Treat it as a long-lived secret stored in your secrets manager, never in a shared configuration file. Before any rotation, confirm the impact with your team, since a change ends every active session and may affect stored OAuth credentials.

Keep SSRF_PROXY controls in place

The SSRF_PROXY settings route outbound requests through a proxy that blocks internal and private IP ranges. Changing or bypassing that proxy while troubleshooting SSO metadata fetches or identity lookups can open a path from Dify to internal services. If the identity provider endpoints need an exception, add the specific destination rather than disabling the proxy, and record the change for your security review.

Pair SSO with SCIM deprovisioning

Single sign-on controls new sign-ins, but it does not remove access that a leaver already holds inside Dify. Pair the Entra integration with SCIM provisioning so that disabling a user in Entra also deactivates the matching Dify account. Test the leaver path with a disposable account before go-live, and confirm that an account removed in Entra can no longer reach workspaces or published web apps.

Keep sign-in traffic in your network

Sign-in requests and assertions travel between the browser, Dify and Entra ID, so the Dify endpoints should be reachable only where your policies allow, with TLS terminated by infrastructure you operate. Confirm the Entra ID endpoints and redirect addresses your firewall and reverse proxy must allow, and avoid designs that send session data through third-party relays. Document the path so an auditor can trace where authentication happens.

Common Entra ID sign-in failures and fixes

This table pairs each common Entra ID sign-in failure with its likely cause and the first check to run. Read it from the symptom column: find what the user or administrator sees, then work down the cause and check cells in order. The main takeaway is that most failures trace to a mismatched value in the SAML configuration, an unassigned user or a proxy or framing setting, so check those before changing certificates or the Dify deployment.

SymptomLikely causeFirst check
SAML response rejected after the Entra sign-in succeedsReply URL (ACS) or Identifier (Entity ID) in Entra does not match the value Dify Enterprise expects for the scope being usedCompare the reply URL and identifier character by character, including scheme, host, trailing slash and the workspace or web app scope path
Error about an invalid or expired signatureSigning certificate in Dify was copied from an older Entra certificate, or the active certificate was rotatedConfirm the certificate in Dify matches the active signing certificate in the Entra enterprise application and has not expired
Assertion appears not yet valid or expiredClock skew between the Entra service and the Dify api host, often from an unsynchronized server clockCheck the time source on the Dify hosts and confirm NTP is running before changing SSO settings
User is blocked with an access denied message in EntraThe user or their group is not assigned to the enterprise application, or assignment required is enabledOpen the enterprise application's Users and groups list and confirm the user or a group containing them is assigned
Sign-in completes but the user has no name or email in DifyEntra is not sending the claim Dify maps to the account, such as email or name, because the attribute mapping was not configuredInspect a sample SAML response from the sign-in log and confirm the expected claims are present with the names Dify uses
Browser loops between Dify and EntraDify builds the callback with an internal host or http scheme behind a reverse proxy, so the session cookie or redirect does not matchConfirm the public URL, forwarded protocol and host headers the proxy sends, and that the external hostname in Dify matches the Entra reply URL
Sign-in page fails to load or stays blank in an embedded web appEntra blocks its sign-in pages from loading inside an iframe, so the embedded app cannot complete authenticationOpen the web app directly in a browser tab to confirm sign-in works, then review whether the host page frames it and plan a top-level redirect
Single sign-on works for the console but not for web appsThe web app scope uses a separate application registration or callback URL that was not added in EntraVerify that the web app scope has its own reply URL entry and that the matching SSO configuration is enabled for that scope

Questions buyers ask before setting up Entra ID SSO

How much does Dify Enterprise SSO with Entra ID cost?

The self-hosted Enterprise edition is custom priced, so there is no published license price for SSO. The Dify pricing page lists SSO as one of the features that Enterprise adds to the free Community edition, which is limited to a single workspace. Ask for a quote that separates the cost components: the Dify Enterprise license, the infrastructure (the Enterprise resources checklist requires Kubernetes, PostgreSQL, Redis, a Qdrant vector database and object storage), your Microsoft Entra licensing under your existing agreement, and the implementation work. Licensing and infrastructure recur, while configuration and testing are usually one-time.

How long does Entra ID SSO setup take for Dify?

No fixed duration can be stated from the supplied facts, and the time depends mostly on identity review and testing. Your identity team must confirm which Entra app registration, claims and group mappings match your policy, and each Dify SSO scope (workspace access and web app access) needs its own test pass. Time also goes to change approvals, test users and any embedded apps that need extra checks. A fixed-scope engagement is agreed in writing before work starts, so ask for the timeline in that written scope, with each review gate and who signs it off.

What makes Entra ID SSO effort larger or smaller?

Effort rises with the number of SSO scopes, the number of Entra groups that map to Dify roles, and the number of embedded web apps. The Dify SSO documentation separates workspace access from web app access, so each scope needs its own configuration and test. Embedded apps add work because Entra sign-in pages can refuse to render inside a frame. Other drivers include external users who sign in through a separate identity provider, the number of environments (for example staging and production), and whether the deployment runs on the Enterprise Kubernetes layout. Fewer scopes, a short group list and one environment keep effort small.

What must our organization provide for Entra ID SSO?

Three roles are needed, plus a named sign-off owner. First, an Entra administrator who can register the enterprise application, set claims and manage groups. Second, a Dify administrator with access to the Enterprise console to enter the SSO settings and change them later. Third, a test tenant or a test group of users, so sign-in can be verified without disrupting production users. You also need the public URLs and TLS certificates for the Dify instance, and a change window for go-live. Confirm with your security team who holds the Entra administrator rights before work starts.

Can our internal team set up Entra ID SSO without a partner?

An internal team can do it if it already has Entra administration skills and access to Dify Enterprise, and the Dify SSO documentation covers the supported protocols (OpenID Connect, SAML and OAuth2). The risk lies in the details: claim mapping errors, missing test coverage for each scope, and embedded apps that fail under Entra's frame rules. Changing the SECRET_KEY after deployment logs out all users, so plan any change carefully. A partner works from a written scope and deliverables. Ask either option for a test plan, a rollback path and a named owner for each scope.

Do we need SCIM provisioning along with Entra ID SSO?

SSO and SCIM solve different problems. SSO controls sign-in, while SCIM provisioning creates, updates and deactivates users and group memberships in Dify from your identity provider. Without SCIM, accounts and group membership must be maintained by hand, and a leaver can keep access until someone removes the account. Whether you need SCIM depends on your joiner, mover and leaver process and on how many users and groups you manage. Confirm with Dify whether SCIM is included in your Enterprise agreement, and plan it as a separate step with its own testing.

Why does Entra ID block SSO pages inside iframes?

Entra restricts its sign-in pages from rendering inside an iframe, a framing restriction that protects users from clickjacking attacks. When an embedded Dify web app starts a sign-in inside a frame, the Entra page can fail to load, so the user never reaches the login form. Plan for this by opening sign-in in a top-level window or redirecting the user, and test every embedded app on the production URL. Confirm the current Entra framing behavior in Microsoft's documentation before you finalize the design, because the rules can change.

Keeping SSO working through Dify upgrades

Minor Dify releases arrive roughly monthly, according to the release history on the langgenius/dify GitHub releases page, so the Entra ID SAML configuration will be exposed to upgrades far more often than most identity integrations. Treat each upgrade as a change to the sign-in path, not only to the application. Follow the upgrade guide for the target version, take a backup before you start, and check the .env.example file for variables the new version expects. Keep your SAML-related environment values in version control or a secrets store so that a rebuilt environment can be compared against a known good state.

After every upgrade, and after any change to the Entra ID signing certificate, repeat the SAML test login from a clean browser session before you let users rely on the new build. Confirm that the workspace sign-in path and the web app sign-in path both complete, since the two scopes are configured separately. Check that the assertion consumer URL, entity ID and attribute mappings still match the values registered in the Entra ID enterprise application, and that the signing certificate in Dify is the one Entra ID currently uses. Confirm these details against your own tenant and the current Dify Enterprise SSO documentation, because the exact fields can change between versions.

Write the post-upgrade check as a short runbook with a named owner and a rollback decision point. If the test login fails, the fastest recovery is usually to restore the backup taken before the upgrade and to keep the previous release running while the identity configuration is corrected. Ask your implementation partner to include this check in the upgrade scope and in any retainer, so that SSO verification is recorded as part of each change rather than discovered by users.

How DeployOpen scopes and delivers Dify SSO work

DeployOpen plans, implements, documents and supports Dify Enterprise SSO with Microsoft Entra ID inside your own infrastructure, so the sign-in path stays under your control. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Written scope names the Dify Enterprise version, Kubernetes target and hostnames for workspace and web app sign-in.
  • We confirm which Entra ID tenant, app registrations and user groups will be used for each access scope.
  • Scope states whether SCIM provisioning, custom roles or external user access are included or handled separately.

How we build

  • We configure the Entra ID SAML application, claim mappings and certificate handling against your tenant policies.
  • We test sign-in for workspace access and web app access separately, including the iframe embedding case for embedded apps.
  • Changes are made in your environment under your change control, with secrets kept out of source files and tickets.

How we hand over

  • You receive configuration records, a test log for each access scope and a list of the settings you own afterward.
  • Runbooks cover certificate renewal, redirect URL changes, and what to check before each Dify upgrade.
  • Handover includes a walkthrough with your identity and platform team so they can operate the integration without us.

How we support

  • Post-handover support is available as a retainer covering troubleshooting, upgrades and periodic sign-in testing.
  • Retainer scope, response expectations and reporting are written into the agreement before work begins.
  • Ask for a quote based on your written scope, since DeployOpen does not publish a price list.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.