Moodle SSO with Microsoft Entra ID: OAuth 2 or SAML2

Moodle can sign users in with Microsoft Entra ID through the core OAuth 2 service or the SAML2 plugin. This page explains how to choose, what to configure and what to confirm before rollout.

On this page

Moodle SSO with Microsoft Entra ID: when your team needs it

If your university, school or company runs self-hosted Moodle and wants staff and learners to sign in with their Microsoft work or school accounts, you have to decide how Moodle will trust Entra ID before anything else. The two realistic paths are the core OAuth 2 authentication plugin and the SAML2 Single sign on plugin (auth_saml2), which Catalyst IT maintains. Moodle core ships OAuth 2, so it adds no third-party code to review. The SAML2 plugin is a community plugin, so its version, its Moodle compatibility and its maintenance status need to be checked against the release you plan to run. Neither choice is the better one in general. It depends on which protocol your identity team already standardizes on and on which user data Moodle must receive at sign-in.

Entra ID sign-in changes account lifecycle more than it changes the login screen. Once users authenticate against Entra ID, the directory becomes the place where access starts and stops. A disabled Microsoft account should stop working in Moodle, but only if the Moodle side is set up to match accounts reliably and to handle suspended users. Ask your identity team which attributes they will release (for example the immutable identifier, userPrincipalName or the email address), whether they can supply group membership, and whether the tenant uses conditional access. Those answers decide whether you match on an immutable identifier or on an email address that can change, and whether Moodle receives enough data to place users in the right cohorts or roles.

Before you build, write down three things: the protocol you will standardize on across other applications, the attributes Moodle must receive, and who owns the Entra ID app registration and its redirect settings. Confirm the Moodle version you will run and the plugin release that supports it in the plugin directory, because support ranges change between releases. Then ask your partner or internal team to test a sign-in with a suspended account, a renamed account and a user in a group that should not have course access. Those three tests show more about your design than the login screen does. The detailed settings for each path follow in the sections below.

OAuth 2 or SAML2: which option fits which requirement

This table compares Moodle's core OAuth 2 authentication path with the auth_saml2 plugin for Entra ID sign-in. Read each row against your own requirements for account matching, attribute mapping, group-based access and maintenance, then check the items marked for confirmation against the Moodle and plugin versions you plan to run.

RequirementCore OAuth 2 pathauth_saml2 plugin
Protocol and sign-in flowOpenID Connect style sign-in through an OAuth 2 issuer configured in MoodleSAML 2.0 assertions from Entra ID to Moodle as the service provider
Account matchingMatches on a configured identifier from the token; confirm which claim your tenant should useMatches on a configured attribute from the assertion; confirm the NameID or attribute choice with your identity team
Attribute mappingMapping of token claims to Moodle profile fields in the auth plugin settingsField mapping configured in Moodle from SAML attributes; confirm attribute names in your Entra ID claims setup
User creation at first sign-inSupported through the auth plugin settings; confirm the behaviour for your Moodle versionCreates users with field mapping configured in Moodle, per the plugin documentation
Group-based accessGroup membership needs a Graph call or claim configuration; plan this as extra design workGroup claims can be sent in the assertion; confirm the claim setup and how Moodle maps groups to roles
Entra ID app registrationRedirect URI, client secret or certificate, and the API permissions needed for the chosen claimsEnterprise application with SAML settings, signing certificate, entity ID and reply URL taken from Moodle
Maintenance and upgradesCore code, so it moves with each Moodle release; confirm any changes to OAuth 2 settings in release notesThird-party plugin maintained outside core; check its listed Moodle version support before each upgrade
Microsoft 365 plugin setSeparate Microsoft 365 integrations may depend on the OAuth 2 issuer; confirm which plugins require itCompatibility with Microsoft 365 plugins should be confirmed in writing before the plugin choice is fixed

How to configure Entra ID sign-in in Moodle

This sequence takes a Moodle site from version and server checks through an Entra ID app registration, a working sign-in method, account matching and attribute mapping, a pilot group, and finally sign-in for all users. Each step closes with a check, so the team knows when to move on.

  1. Confirm the Moodle version and server requirements

    Before anything is registered, confirm which Moodle release the site will run and check that the PHP, database and web server meet that release's requirements. For Moodle 5.1, the supplied requirements are 64-bit PHP 8.2 or later (8.3 and 8.4 supported), PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or Microsoft SQL Server 2017 or later, and an upgrade path that starts from Moodle 4.2.3 or later. For Moodle 5.1 the web server document root must point to the /public directory. Your platform team confirms the target release and the server stack. Done when the site runs the target version, the document root check passes, and the sign-in test page loads over HTTPS with the correct site URL.

  2. Register the application in Entra ID

    A Microsoft Entra ID administrator registers Moodle as an application in the tenant, sets the redirect URI that Moodle shows for the chosen method, and records the client ID and tenant details. For OAuth 2, the redirect and client secret or certificate come from Moodle's OAuth 2 service setup. For SAML2, the entity ID and assertion consumer URL come from the SAML2 plugin settings. Decide which user attributes and group claims the application will release before this step closes. Confirm the registration with the identity team, check that only the intended users or groups are assigned to the application, and store the secret in your secrets manager, not in the Moodle configuration screen.

  3. Configure the chosen authentication method in Moodle

    Choose one method for this site: the core OAuth 2 service with an Entra ID issuer, or the SAML2 Single sign on plugin (auth_saml2) maintained by Catalyst IT, which lists support for Moodle 2.7 through 5.1. Enable the authentication plugin, paste the tenant and application values, and set the sign-in button label. Keep manual sign-in available for a named break-glass administrator until the pilot is complete. Check that the sign-in button appears on the login page, that a test sign-in by a pilot user reaches the Moodle dashboard, and that the login log records the authentication method used.

  4. Set account matching and attribute mapping

    Decide how an Entra ID identity is matched to a Moodle account. Typically this is the email address or a stable identifier such as the user principal name, and the choice must be tested against existing accounts so duplicates are not created. Map the Entra ID claims to Moodle profile fields such as first name, last name, email, department and institution ID. Confirm with your identity team which claim is stable over time. Check the mapping with a claim inspection: sign in with a test account, review the attributes received, and compare them with the Moodle user profile to confirm each field landed where expected.

  5. Control user creation and group-based access

    Decide whether Moodle should create accounts on first sign-in and which Entra ID groups grant access to the site or to cohorts. Creating accounts on first sign-in is simple, but it needs an agreed rule for who may enter. Where group membership controls access, confirm that the group claim or group filter is delivered by the chosen method, and that users outside the groups are refused. Pilot checks: a user in the approved group is created with the expected profile fields, and a user outside the group is refused without an account being created.

  6. Test with a pilot group

    Select a small pilot group that represents the main account types, such as staff, learners and a user who already has a local Moodle account. Run the full sign-in path for each: first sign-in, returning sign-in, sign-out, password reset handled by Entra ID, and the case of an existing manual account that should be matched rather than duplicated. Review the Moodle logs and the authentication plugin's error output for failed claims or mismatches. Record each result. The step is done when every pilot account lands on the correct profile with the correct access and no duplicate accounts exist.

  7. Enable sign-in for all users

    Once the pilot results are signed off, enable the Entra ID sign-in method as the default for the site and decide whether to hide or retain the manual sign-in form for staff. Keep the break-glass administrator documented and tested. Communicate the new sign-in button to users with the support route for sign-in problems. Check the final state: the sign-in page shows the Entra ID option, a random sample of users from each group can sign in, the Microsoft 365 plugin set you use, if any, is confirmed separately, and the rollback steps are written down and known to the operations team.

How a Microsoft sign-in reaches a Moodle account

The flow starts in the user's browser at the Moodle login page, which redirects the user to Microsoft Entra ID for sign-in. Entra ID returns a token (OAuth 2) or a SAML assertion to the Moodle authentication plugin, and that hand-off is the trust boundary to check. Moodle then matches the identity to an existing account or creates or updates the user record, and reads group claims in the returned data to decide access. Confirm which identifier the plugin matches on and which claims it trusts.

Sign-in hand-offs between the browser, Entra ID and Moodle, with the trust boundary.

Security risks in Entra ID sign-in for Moodle

Entra ID sign-in moves the trust decision to Microsoft, but Moodle still holds the account, the session and the course data. The cards below cover the points where a misconfigured integration can let the wrong person in, keep a former employee in, or leave an administrator locked out.

Client secret and certificate handling

The Entra ID application registration holds a client secret or certificate that lets Moodle request tokens. Store the secret outside the Moodle web root and restrict who can read the Moodle configuration and database. Set an expiry date on every secret and record the owner, because an expired secret stops sign-in for every user at once. Ask the Entra ID administrator who can create new secrets on the application.

Redirect URI control

Each redirect URI registered in Entra ID tells Microsoft where to send the sign-in response. A wildcard or a stale staging address can let a response reach a host you do not operate. Register only the exact Moodle callback URLs for production and each test site, use HTTPS, and review the list after every domain change or Moodle upgrade.

Account takeover through email matching

If Moodle links an incoming Entra ID identity to an existing account by email address alone, anyone who can register or change an address that matches a staff or student record may inherit that account. Match on a stable identifier such as the Entra ID object ID or a verified immutable attribute where possible, and check that the mapping only applies to users your tenant has verified.

Users removed from Entra ID

Deleting or disabling a user in Entra ID does not delete the matching Moodle account. The Moodle account stays active until something suspends it. Decide whether removed users are suspended or deleted, which sync or login step performs that action, and how course enrolments and grades are kept. Test with a disabled test user before you rely on the process.

Local login for administrators

If the Entra ID tenant, federation or the Moodle SSO plugin fails, administrators with only SSO accounts cannot sign in to fix the site. Keep at least two named Moodle administrators with a local password, stored under your break-glass process, and confirm they can sign in without Entra ID. Restrict local login to those accounts and monitor it.

Session and logout behavior

Signing out of Moodle does not necessarily end the Entra ID session in the browser, and a session left open on a shared lab machine can reopen Moodle without a new password prompt. Confirm the session lifetime in Moodle, whether single logout is supported by your chosen method, and what Conditional Access policies apply to sign-in. Test logout from a shared device.

Patching the plugin across upgrades

The SAML2 plugin and the OAuth 2 setup both depend on the Moodle version in use. A Moodle major upgrade can break the plugin or leave it unmaintained for the new release. Check the plugin's supported Moodle range before each upgrade, test sign-in on a staging copy, and track plugin security releases in your change calendar.

How the setup changes by tenant and user population

When every user is a member of one Entra ID tenant, the design is the most direct. Staff accounts already carry a stable identifier, a UPN and usually a department and job title, so Moodle can match users on a single attribute and create accounts with predictable fields. The main decisions are which attribute is the immutable key for matching, whether Moodle should create accounts on first sign-in, and which Entra ID groups grant course creation or site administration.

  • Matching key: Choose an attribute that does not change when a person's email alias or display name changes, and confirm how it is populated across the tenant.
  • User creation: Decide whether first sign-in creates an account or whether only pre-provisioned users may enter, and map the fields Moodle needs, such as first name, last name and email.
  • Group-based access: Map Entra ID groups to Moodle roles or cohorts, and keep the group list short enough to audit.
  • Nested and dynamic groups: Confirm whether group membership is delivered as a flat list in the token or needs a Graph lookup, since nested and dynamic groups behave differently.
  • Ownership of changes: Ask the identity team who approves new groups and how leavers are suspended in Moodle.

Confirm the matching attribute, the group claim format and the leaver process with the organization's identity team before testing begins.

Limits to confirm in your environment

Sign-in between Moodle and Entra ID depends on versions, plugin status, tenant settings and the network path in front of Moodle. Confirm each limit below in your own environment before choosing a method or writing the build plan, because a choice that works on one release can fail on another.

Moodle release and runtime

Confirm the exact Moodle release you will run, then check its PHP and database requirements against your servers. Moodle 5.1 requires 64-bit PHP 8.2 or later and PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 or later, while Moodle 5.3 requires PHP 8.3 or later and PostgreSQL 17. Also confirm that your web server document root points to the public directory from 5.1 onward.

Moodle 5.1 notes

Plugin version and support status

Check the current release, supported Moodle versions and maintenance status of each candidate plugin. The SAML2 plugin lists support for Moodle 2.7 through 5.1, so confirm it against the release you plan to run. Also confirm whether the plugin is still maintained, since a support gap on a sign-in plugin affects every user.

SAML2 plugin page

Entra ID claims and group options

Confirm which attributes, such as the user principal name, email and object identifier, your tenant can release in tokens, and whether group membership arrives as object IDs or names. Group claims can be limited by group size or by how the application is configured, so test the exact group set you need for course access before you design group-based roles.

Microsoft 365 plugin compatibility

Check that the Microsoft 365 plugin set works with the sign-in method you choose. Some plugins expect a specific OAuth 2 issuer setup or a token flow that a SAML2 setup does not provide. Confirm the plugin versions against your Moodle release in a test site before you rely on them for calendar, file or Teams features.

Reverse proxy and load balancer behavior

Confirm how the redirect URLs, host headers and HTTPS termination behave through your reverse proxy or load balancer. A wrong public URL in the Moodle configuration or identity provider registration breaks the callback, and session cookies can fail across nodes if sticky sessions are not set. Test sign-in, sign-out and session expiry through the same path your users take.

Core auth plugins

Account matching and tenant policy

Confirm how your tenant handles guest accounts, multiple tenants and changed sign-in names, since these decide whether Moodle matches an existing account or creates a duplicate. Ask your identity team which accounts are allowed to sign in and whether conditional access policies will apply to Moodle, then test those cases with real test accounts.

Questions buyers ask before choosing Entra ID sign-in for Moodle

What does Entra ID sign-in for Moodle cost, and what drives the price?

The cost depends on the written scope, not on a list price. Most of the effort sits in three places: the Entra ID app registration and claims design, Moodle configuration (account matching, field mapping, group rules) and testing against real tenant accounts. Costs rise when you need several Entra ID tenants, custom claims, group-based course enrolment, multiple Moodle sites or a test environment that mirrors production. Costs fall when the directory is clean, the attribute mapping is agreed early and the internal team can supply access quickly. Ask for a quote that separates one-time build work from any recurring support or upgrade retainer, and ask which Moodle version and plugin versions the quote assumes. DeployOpen does not publish a price list; a quote follows from the written scope.

How long does a Moodle Entra ID configuration and pilot take?

Duration follows the drivers, not a fixed figure. The main ones are how many groups and roles must map to Moodle, whether user creation from Entra ID is needed, how many environments must be built and how long your identity and security teams take to approve the app registration and test results. A pilot usually takes longer than the configuration because real users reveal account-matching edge cases, such as duplicate emails, changed usernames and accounts that exist locally before sign-in is switched on. Ask for a timeline in the written scope that names the approval steps and the test accounts each phase requires.

What must our internal team provide before the work starts?

Most delays come from access and decisions rather than from build work. Typically the internal team needs to provide:

  • Tenant administrator access, or a named administrator who can approve the app registration and consent
  • Permission to create app registrations and enterprise applications in Entra ID
  • Test accounts covering students, teachers, staff and at least one guest or external user
  • A group structure that states which Entra ID groups should map to Moodle roles or cohorts
  • A decision on which user attributes (for example, username, email or employee ID) identify a Moodle account

Agree these in writing before the build begins so the scope and timeline reflect them.

Can our own team set up Entra ID sign-in for Moodle without a partner?

Yes, a capable Moodle administrator with Entra ID tenant access can configure the core OAuth 2 option or the SAML2 plugin, provided they can test thoroughly. The work that usually needs outside help is attribute mapping across several sources, group-based access that must match your Entra ID design, safe handling of existing accounts and a documented rollback plan. Consider a partner if the identity team cannot commit reviewer time, if several Moodle sites must share one configuration or if audit evidence of the configuration is required. DeployOpen can plan, implement and document the setup inside your tenant and infrastructure, and it can run it as a fixed-scope engagement.

How do OAuth 2 and SAML2 compare for upgrades?

The core OAuth 2 authentication method ships with Moodle, so it follows the normal Moodle upgrade path, and it does not depend on a third-party plugin being updated for each release. The SAML2 Single sign on plugin (auth_saml2) is maintained by Catalyst IT and lists support for Moodle 2.7 through 5.1, so each Moodle upgrade needs a check that the plugin version supports the target release before the upgrade is scheduled. Moodle 5.1 requires 64-bit PHP 8.2 or later, and sites must be on Moodle 4.2.3 or later to upgrade to it. Moodle 5.3 requires 64-bit PHP 8.3 or later and sites must run Moodle 4.4 or later to upgrade to it. Confirm the plugin's support status for your target release with the maintainer before you commit to a path.

What happens to existing local Moodle accounts when we switch to Entra ID sign-in?

Existing accounts are not moved automatically by switching the sign-in method. The key decision is how Moodle matches an incoming Entra ID user to an existing local account, usually on a stable identifier such as username or a unique email, and what happens when no match exists. Plan for accounts with the same email but different usernames, staff who previously used a local password, and accounts that should be suspended once they leave the directory. Test the matching on a copy of the production database, keep a documented fallback for administrator accounts and decide whether local login stays available during the pilot. Confirm how your Moodle version treats the authentication method on each existing account before cutover.

Which security settings should we review before going live?

Review the app registration, the redirect URIs, the client secret or certificate lifecycle, the consent settings, and who can sign in as administrators. Check that Moodle only accepts sign-in from the tenants you intend to trust, that administrator accounts have a break-glass path that does not depend on Entra ID, and that group membership changes in Entra ID reach Moodle on a schedule you can explain to auditors. Record the decisions, because compliance reviewers often ask how sign-in is configured and who approved it. DeployOpen prepares the configuration and evidence for review; independent auditors and certification bodies issue any formal assessment.

How DeployOpen scopes and delivers Entra ID sign-in for Moodle

DeployOpen plans, builds, tests and documents Moodle sign-in with Microsoft Entra ID inside your own infrastructure, choosing between the core OAuth 2 method and the SAML2 plugin once the tenant and Moodle version are known. Engagements are fixed-scope, with the method, account rules and deliverables agreed in writing before work starts.

How we scope

  • We confirm your Entra ID tenant setup, Moodle version and hosting before recommending OAuth 2 or SAML2.
  • The written scope lists account matching rules, attribute mapping, group-based access and the Microsoft 365 plugins in use.
  • We agree which Moodle sites, environments and user populations are covered before any configuration begins.

How we build

  • We configure the chosen authentication method in a staging Moodle copy that mirrors your production hosting.
  • Attribute mapping, user creation rules and group-to-role logic are built and reviewed against a test tenant.
  • Each change is tested with sample accounts covering new users, existing users and users removed from Entra ID.

How we hand over

  • You receive configuration records, the redirect and application settings used in Entra ID, and the mapping tables.
  • Runbooks cover adding a new group, rotating client secrets or certificates, and recovering manual sign-in.
  • Test results and open decisions are documented so your identity and Moodle administrators can review them.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Retainers can cover Moodle release upgrades, so the sign-in configuration is retested after each version change.
  • Ask in your quote which Moodle versions, plugin versions and Entra ID changes the support terms include.

Sources and further reading

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.