How to login to multiple Moodle sites with just one time login?

How to login to multiple Moodle sites with just one time login?

by Ahmed Saad -
Number of replies: 8
i want to make SSO on multiple Moodle sites, then if i'm logedin to moodle site1 i can switch to moodle site2 without relogin
what the auth method do you recommend, my Moodle version 3.1 ??
Average of ratings: -
In reply to Ahmed Saad

Re: How to login to multiple Moodle sites with just one time login?

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

How are the users to be managed:

  1. Are they in an existing system that you want to use as the backend?
  2. Or do you want to add users to a "main" Moodle site and have the other Moodle sites authenticate with that?

For option 1 you'll need to implement an SSO service around this system, e.g. use SimpleSAMLphp (SSp) to set up a SAML Identity Provider then Moodle sites could use SAML2 for SSO, some development work may be required to interface with this system. Depending on the format passwords are stored in it may not be possible to verify any existing passwords.

For option 2 you'll need to implement an SSO server service around the "main" Moodle site. Again you could use SSp as described above and some development work would be needed to verify users against the mdl_user database table of this "main" Moodle site. You would then need to configure the remaining Moodle sites with the corresponding authentication plugin, e.g. SAML2 Single sign on.

Alternatively for option 2 you could use the local_oauth plugin to make the "main" Moodle site an OAuth 2 issuer. This plugin isn't very well supported but should work for this scenario. There are some details here.

This reply may also be helpful.

Moodle 3.1 support ended in May 2019 so you should plan to upgrade these sites to continue receiving fixes and security updates. You will need to check any plugins are compatible with the site versions in use.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: How to login to multiple Moodle sites with just one time login?

by Ahmed Saad -
Hello Leon, thanks for reply, we are trying to authenticate a single user to multiple moodle instances, we have different moodle instances with one source code, the user maybe have accounts in multiple instances then he can login to one instance and switch to others without re login.
In reply to Ahmed Saad

Re: How to login to multiple Moodle sites with just one time login?

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

Setting up an SAML2 or other SSO solution is definitely the best option for the longer term, but it’s also quite complicated to achieve.

If you want something that is already built into Moodle and works out of the box without anything needing to be set up externally, you could use MNET, which was designed for networking Moodle sites (although it’s supposed to be being deprecated at some point). I use it to allow users from Moodle A to Moodle B without having to have separate accounts.

See https://docs.moodle.org/31/en/MNet


If you were on a later version of Moodle, you could set up sign in via an existing service (eg. Microsoft, Facebook, Google) - https://docs.moodle.org/39/en/OAuth_2_authentication

In reply to Jon Bolton

Re: How to login to multiple Moodle sites with just one time login?

by Ahmed Saad -
Thanks Jon Bolton, i have setup mnet for moodle but it is stuck on this error i can't find what this error is about i have search forum following were some suggestions

1) Same time on both moodle error -- i checked time is same on both instances.
2) Also refreshed the keys on both moodle instances.
3) check url - url working also ssl enabled

but still get the below error, do you have any idea why we are getting this error as we have done all points step by step mentioned on mnet documentation.

" Ooops! Your MNET communication has failed! Here's that error message to pass on to your administrator: Connection timed out after 60001 millisecondsERROR 28:
"
In reply to Ahmed Saad

Re: How to login to multiple Moodle sites with just one time login?

by Ken Task -
Picture of Particularly helpful Moodlers

Maybe something overlooked ... 'different moodle instances with one source code'.

Maybe Ahmed could share what his config.php file looks like.

'SoS', Ken

In reply to Ahmed Saad

Re: How to login to multiple Moodle sites with just one time login?

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

Is cURL enabled on your server? 

And can you explain what you mean by “we have different moodle instances with one source code”.

In reply to Jon Bolton

Re: How to login to multiple Moodle sites with just one time login?

by Ahmed Saad -
“we have different moodle instances with one source code” means we have one source code for multiple moodle's with different data bases.

yes Jon CURL is enabled on on server.

all requirements are complete but Mnet get stuck on this error, don't know, is it deprecation issue or something else.
In reply to Ahmed Saad

Re: How to login to multiple Moodle sites with just one time login?

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
No, it’s not a depreciation issue - you said in an earlier post that you’re using 3.1 and I have MNet working successfully on 3.6 and 3.8 sites with no issues.

Have you got unique session cookie ids on all your Moodle installations? See https://docs.moodle.org/31/en/Session_handling#Cookie_prefix

And you have a daily unusual set up with one codebase serving many databases. What are the settings in your config file?