Identity & Access

Moodle SSO Implementation: SAML2, OAuth2 & CAS

A technical look at how single sign-on actually works with Moodle — the protocols it supports, how the SAML2 flow behaves with real identity providers, and the attribute-mapping and certificate details that most SSO rollouts get wrong the first time.

SAML2, OAuth2 & CASAzure AD, Okta, Google Workspace8+ Years Building on Moodle
SAML2 SSO Flow

Why Organizations Need SSO With Moodle

Once Moodle sits alongside HR systems, email, and a dozen other SaaS tools, a separate Moodle password becomes a support burden and a security gap — password reset tickets pile up, offboarded employees keep access longer than they should, and IT has no single place to enforce MFA.

Password Sprawl

A separate Moodle credential is one more password to forget, reset, and eventually reuse unsafely elsewhere.

No Central Deprovisioning

Disabling a user in your identity provider doesn't touch their Moodle account unless SSO is actually wired up.

MFA Gaps

Multi-factor policies enforced at the IdP don't protect Moodle at all if Moodle authenticates independently.

What Moodle Actually Supports for SSO

Moodle ships several authentication plugins capable of single sign-on, each suited to a different identity setup.

SAML2 (auth_saml2)

Moodle's SAML2 authentication plugin (auth_saml2, bundled with core since Moodle 3.3+) handles the SP side of the SAML exchange, redirecting users to your identity provider and consuming the signed assertion it returns.

OAuth2 (auth_oauth2)

Moodle's OAuth2 authentication plugin ships preset configurations for Google and Microsoft, plus a generic issuer type for any OAuth2/OpenID Connect provider that exposes the right endpoints.

CAS (auth_cas)

Still common in universities running older campus identity infrastructure. Moodle's CAS plugin authenticates against a Central Authentication Service server, typically alongside LDAP for attribute lookup.

LDAP (auth_ldap) — Related, Not SSO

LDAP authenticates Moodle logins directly against a directory but doesn't provide true single sign-on across other apps. Many organizations pair it with SAML2 or OAuth2 rather than using it alone.

The auth_saml2 Login Flow, Step by Step

This is the standard service-provider-initiated flow that runs every time a user logs into Moodle through SAML2.

1

User Hits a Protected Moodle URL

The user navigates to your Moodle site (or an activity link shared from your LMS) without an active session.

2

SP Redirects to the IdP

auth_saml2 builds an AuthnRequest and redirects the browser to your identity provider's SSO endpoint — Azure AD, Okta, or whichever IdP is configured.

3

User Authenticates at the IdP

The user logs in (and satisfies MFA, conditional access, or other IdP-side policy) entirely on the identity provider's domain — Moodle never sees the password.

4

IdP Posts a Signed Assertion Back

The IdP returns a signed SAML response to Moodle's Assertion Consumer Service (ACS) URL, containing the user's attributes and authentication statement.

5

Moodle Validates & Maps Attributes

auth_saml2 verifies the signature against the IdP's certificate, then maps SAML attributes to Moodle profile fields per your configured attribute mapping.

6

Session Created or User Provisioned

If the user already exists (matched on idnumber, username, or email per your configuration), Moodle logs them in. If not, and JIT provisioning is enabled, a new account is created on the fly.

Notes on Common Enterprise IdPs

The protocol is the same across identity providers, but the setup details — and where things go wrong — differ enough to be worth calling out individually.

Azure AD / Microsoft Entra ID

Configured as a SAML2 enterprise application or via auth_oauth2's Microsoft preset. Entra ID's SAML metadata URL feeds auth_saml2's IdP metadata field directly — avoid hand-typing certificate fingerprints.

Okta

Set up as a SAML2 app integration in Okta with the ACS URL and Entity ID from Moodle's auth_saml2 settings page. Okta's attribute statements need explicit mapping to match what Moodle expects.

Google Workspace

Either a custom SAML app in the Google Admin console, or Moodle's built-in Google preset under auth_oauth2 for organizations that just need Workspace-account login without full SAML complexity.

ADFS

A common on-premises IdP for organizations not yet on Entra ID. Requires a relying party trust configured with Moodle's exact Entity ID and ACS URL, and claim rules mapping AD attributes to SAML claims.

Shibboleth

Frequent in higher education federations (InCommon, eduGAIN). auth_saml2 interoperates with Shibboleth IdPs the same way as any SAML2 IdP, provided metadata exchange is done correctly.

Just-in-Time Provisioning & Attribute Mapping

Getting SSO to authenticate a user is the easy part. Mapping who they are inside Moodle — correctly, and consistently across logins — is where most implementation time actually goes.

idnumber as the Matching Key

Mapping a stable, unique IdP attribute (an employee or student ID, not email) to Moodle's idnumber field is the most reliable way to match returning users across logins.

Email as a Secondary Signal

Email works for matching but breaks when organizations change email domains or when users have multiple email aliases at the IdP — a poor sole source of truth for identity matching.

Role Mapping via Attributes

IdP group or department attributes can drive cohort sync or role assignment through Moodle's cohort sync enrolment method, rather than manually assigning roles after every SSO login.

Just-in-Time Account Creation

auth_saml2 can create a Moodle account automatically on first successful login when no matching user exists, using mapped attributes to populate the new profile — useful for large populations you don't want to pre-provision.

Where Moodle SSO Rollouts Actually Break

Almost every SSO issue we've been called in to fix falls into one of these categories.

Clock Skew Between Servers

SAML assertions carry tight validity windows (NotBefore/NotOnOrAfter). If your Moodle server's clock drifts from the IdP's, valid assertions get rejected as expired. NTP sync on the Moodle server is non-negotiable.

Certificate Rotation Breaking Login Overnight

IdPs rotate signing certificates on a schedule. If auth_saml2 is configured with a static certificate instead of a live metadata URL, rotation silently breaks every login until someone updates it.

Attribute Name Mismatches

The exact attribute name the IdP sends (e.g. http://schemas.xmlsoap.org/claims/EmailAddress vs a bare 'email') has to match what's configured in auth_saml2's attribute mapping, or fields come through empty.

Multi-IdP Setups

Supporting more than one identity provider (say, a university federation plus a partner organization) means configuring multiple IdP entries in auth_saml2 and giving users a way to pick the right one, since Moodle doesn't auto-detect which IdP a user belongs to.

Moodle Mobile App SSO Quirks

The Moodle Mobile app opens SSO flows in an in-app browser and expects a specific redirect back into the app (moodlemobile:// custom URL scheme). IdPs or proxies that block redirects to custom schemes will strand mobile users mid-login.

Mixed Auth Methods During Rollout

Migrating from manual accounts to SSO usually means a transition period where both auth_manual and auth_saml2 are active — existing accounts need their auth method and idnumber reconciled, or SSO logins create duplicate accounts instead of matching existing ones.

Locking Down an SSO Integration Once It's Live

  • Require Signed & Encrypted Assertions: Enable assertion signing at minimum, and encryption where your IdP supports it, so intercepted responses can't be replayed or read.
  • Lock Down the ACS URL: Configure the IdP to only post assertions to your exact Assertion Consumer Service URL — not a wildcard — to prevent assertion redirection attacks.
  • Restrict auth_manual Fallback: Once SSO is live, disable or tightly restrict manual login for accounts that should only ever authenticate through the IdP, so SSO can't be bypassed with a locally-set password.
  • Monitor for Assertion Replay: Moodle logs SAML login events — reviewing them periodically for unexpected patterns (same assertion ID reused, logins from unexpected IdPs) catches misconfigurations and abuse early.

SSO Work Grounded in Real Moodle Internals

8+ Years in Moodle Core & Plugins

SSO configuration built on real experience with Moodle's authentication plugin architecture, not a generic identity-management playbook.

Tested Against Your Actual IdP

Configuration verified in staging against your real identity provider before it ever touches production logins.

Provisioning Mapped to How You Track Users

Attribute mapping built around your real idnumber, role, and cohort structure, not a generic default that half-matches your data.

Mobile App SSO Included

SSO tested in the Moodle Mobile app as well as the browser, so learners on iOS and Android aren't the ones who discover it's broken.

Got Questions About Moodle SSO?

Straight answers to what comes up most before an SSO rollout.

Natively. auth_saml2 has shipped as a core-bundled authentication plugin since Moodle 3.3, and auth_oauth2 and auth_cas are also core plugins. No paid add-on is required for standard SAML2, OAuth2, or CAS single sign-on.

Yes. Moodle supports multiple enabled authentication methods simultaneously. The common pattern during migration is running auth_saml2 alongside auth_manual, then progressively restricting manual login as accounts move over to SSO.

SAML2 is the standard for enterprise identity federation (Azure AD, Okta, ADFS, Shibboleth) and is what most institutional IdPs expect. OAuth2/OpenID Connect is lighter weight and is what auth_oauth2's built-in Google and Microsoft presets use — often simpler to set up when you just need 'login with your Google Workspace account' rather than full claims-based federation.

By whichever field you configure as the matching key in auth_saml2 or auth_oauth2 — typically idnumber, username, or email. Getting this mapping right before go-live matters, because a mismatch either fails logins for existing users or creates duplicate accounts.

Yes, this is just-in-time (JIT) provisioning. auth_saml2 can create a new Moodle account on first successful SSO login using attributes from the assertion, without an administrator pre-creating accounts.

Yes, but it requires the 'Web services' and mobile-specific SSO handling to be configured correctly — the mobile app opens the IdP login in an embedded browser and needs to redirect back into the app via a custom URL scheme. This is one of the most common things that gets missed in a first SSO rollout.

If auth_saml2 is pointed at a live IdP metadata URL rather than a manually pasted certificate, Moodle picks up the new certificate automatically. If the certificate was hardcoded, every login breaks the moment the old certificate expires — this is the single most common cause of SSO outages we see.

Ready to Wire Up SSO for Your Moodle Site?

Tell us which identity provider you're on and we'll scope the integration.

Talk to a Moodle SSO Developer