Moodle is a Free and Open-Source Software (FOSS) learning management system written in PHP. Drupal is also an Open-Source CMS. Our requirement is to integrate Moodle and Drupal with a single login system. For that I have followed steps mentioned below.
Changes to be done in the Drupal site:
- Install the following modules in the Drupal site.
- In Drupal there should be a user with role 'service-authentication' which is required by the Moodle site Drupal services configuration.
- Create user fields like firstname, lastname,city, country etc because Moodle requires these values. Please note the input for the Country field should be 2 characters.
Changes to be done in the Moodle side:
After installing Moodle in the same server,
- Download the plugin 'moodle-drupalservices-master'(Moodle plugin to connect to Drupal services) and rename it to 'drupalservices' and put the folder in auth directory of moodle. ie, moodle -> auth -> drupalservices.
sudo wget https://github.com/cannod/moodle-drupalservices/archive/master.zip sudo mkdir drupalservices sudo unzip master.zip -d drupalservices/ sudo mv moodle-drupalservices-master/* . sudo mv drupalservices/ moodle/auth/
This plugin checks if there is a valid Drupal session cookie and then connects to Drupal services and retrieves Drupal user info.
- Login to Moodle site with admin credentials and then go to Plugins -> Authentication -> Manage Authentication -> Drupalservices. Configure Drupalservices by specifying the Drupal site URL and Drupal fields for user data and enable the service.
- Run cron from Moodle side.
For testing single sign on
- Login to Drupal site.
- Access the Moodle site. You will be forced to enter the basic information for first time users.
- Logout from the Moodle site. You will be automatically logged out from the Drupal site also.