Oauth2 authentication

Revision as of 03:57, 14 August 2012 by jerome mouneyrac (talk | contribs) (Pros)

Jump to: navigation, search

This document describes the functional and technical specification of Moodle Oauth2 plugin(s). Oauth2 plugin(s) will allow a user to authenticate in Moodle with a identity provider that implement Oauth2, like Google or Facebook.

What is Oauth2

OAuth is a security protocol that enables users to grant third-party access (i.e. Moodle) to their web resources (i.e Google/Facebook/...'s user data) without sharing their passwords.

See also

What are the user's benefits

  • The user can connect in Moodle with a Google/Facebook/... account.
  • Login is fast: 1 click on a Google/Facebook/... button.
  • The user does not need to remember a password for Moodle.
  • The user can link an existing Moodle account to an Oauth2 identity provider. Thus the user benefits of the above points.
  • When the user is new, the creation process is faster: in the best case, which is the case for Facebook/Google, every mandatory user fields are pre filled.

Why implementing Oauth2 which is still in Draft version

The main reason we choose Oauth2 is that massive identity providers as Google already started to deprecate Oauth1 or only use Oauth2 (Facebook). Oauth2 has also for benefit over Oauth1 to be simpler to implement for the client. However at the moment, Oauth2 is on a rocky road. The specification are still marked as Draft, and major providers as Facebook or Google implement their own version. But at the end these implementations are globally similar, and we will be able to reuse a major part of our code for each providers.

Functional specification


User authenticates for the first time in Moodle

User already has an account

The email address sent by the identity provider is known by Moodle

The email address is unknown


The administrator wants to:

  • enable the plugin(s)
  • set Oauth2 client id / Oauth2 client secret
  • allow user account creation
  • set lockable fields
  • deny email addresses
  • bypass the deny email addresses global settings (for example allow hotmail registration by Oauth2 but disallow it for manual to avoid spammer)
  • allow email addresses

Technical specification

One plugin by provider or One plugin for all providers

One plugin by provider


  • it works nice with lang file and Amos without additional code. Each providers use its own vocabulary (client id/app id) and need its own explanation on how to set it up.


One plugin for all providers


  • less click to setup for the administrator. Only enable one plugin.


  • the settings page could become bigger and messier.
  • need an additional "enable" checkbox for each providers (so the administrator can disable the plugin without losing the settings)
  • administratosr do not know which Oauth2 provider is enabled without looking into the Oauth2 plugin.