Login from script outside of moodle

Login from script outside of moodle

by Richard Morrow -
Number of replies: 9

Hi,

I have a web site with Moodle in a subdirectory. There are some features on the main site (outside of moodle) that I want for logged in users only. I don't want to have two seperate logins, i.e. one for moodle, one for the rest of the site.

Is there some way I can make a login page and have access to the session or cookie data so that when a user is logged into moodle, I can test this from any page of my site?

Average of ratings: -
In reply to Richard Morrow

Re: Login from script outside of moodle

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Richard - I would start by having a look at http://docs.moodle.org/en/Authentication to get an idea of the various authentication methods. Since Moodle is inside of your existing structure, I would have one authentication for that and have Moodle utilize that. After reading the documentation about the various authentication options you may have more specific questions. Let us know how we can help. Peace - Anthony

In reply to Anthony Borrow

Re: Login from script outside of moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Anthony, from what Richard is describing it is similar to our (my organization's) need to develop a single login and authentication process for a range of PHP Apps. Martin developed a script to accommodate MediaWiki some time ago, but that was just not robust enough for our need. Some organizations have developed something that may or may not work in limited scenarios, but for me, there should be a single login and authentiction process, a standardised module if you like, that could be easily adaptable to all PHP Apps. For me, this would be much better than trying to integrate lots of different PHP Apps into a single tool, less risky from a coding perspective as well. (I do not have the PHP skills to do this myself, so have no real idea as to how difficult this would actually be.)  Perhaps the tool would be a login script, then a distribution to such Apps as used or a set of adapters in each App that can meet the App's authentication processes that receive data from the login script. Alternatively, a script that builds a single authentication table in a database with each App accessing that database for their authentiction processes would allow a more consistent approach, that all App makers could use, but i am not sure that PHP is either fast enough or flexible enough to use multiple databases at the same time in this manner.

I would suggest that if this was possible and was to be done, and a set of Apps say, Moodle, Mahara, MediaWiki, WordPress, phpMyAdmin be bundled as a complete LMS\social tool,  it would be a very popular bundle very quickly.

I understand that these are all, in some ways, "competing" products, but reality suggests that "one-size fits all" approaches are doomed to failure. Keeping the options open is a better approach, for me anyway.

In reply to Colin Fraser

Re: Login from script outside of moodle

by Richard Morrow -

Thanks guys. Looking at this page, it does not sound to tricky. I can make a plugin, and have it set some session vars when it runs. I can use those vars to allow access to features on the main site while the moodle auth handles its own authentication.

Does anyone know of a basic example of the auth.php file it mentions?

http://docs.moodle.org/en/Development:Authentication_plugins

In reply to Colin Fraser

Re: Login from script outside of moodle

by Richard Morrow -

Thanks guys. Looking at this page, it does not sound to tricky. I can make a plugin, and have it set some session vars when it runs. I can use those vars to allow access to features on the main site while the moodle auth handles its own authentication.

Does anyone know of a basic example of the auth.php file it mentions?

http://docs.moodle.org/en/Development:Authentication_plugins

In reply to Colin Fraser

Re: Login from script outside of moodle

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Colin - Forgive me if this is a silly question, but how does what you are describing different from something like using LDAP or SAML for authentication? Various programs allow for LDAP or SAML authentication. I know that authentication between various systems and managing users tends to be one of the big challenges facing the web application developer community. Thanks for any clarity you can provide. Peace - Anthony

In reply to Anthony Borrow

Re: Login from script outside of moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Not a silly question, Anthony, a very pertinent one. I would suggest it is more revealing of my own lack of knowledge of networking stuff actually. tongueout Never considered using LDAP, or SAML. First, do all those Apps allows the use of LDAP? I don't know, I know Moodle does and the Network guys are always complaining that they actually can't get it to work with the logon protocols or login authenticators whatever they use. (The only one I have heard mentioned by name is IChain, and I am not sure that is even how it is spelt, and I have no idea how it is done in the Moodles I am an admin for now.)

This sort of thing seems to move into realms of networking that most of the people I have worked with do not ordinarily use, do not really understand. I suspect that this is a structural thing that my employers are going to have to make a decision about soon though.

Here it is, my employers decided to use Moodle, at the encouragement of a prominent member of the Oz Moodle community, and good for him. His company provide the Moodles, the servers and everything else, at a cost I assume, and we access them. Each school in the State, (which is nearly twice the size of Texas and about 1/20th the population,) has one Moodle, which makes about 400 odd Moodles, not all of which are being used - and few are being used extensively.

My argument is that Moodle on its own fills a purpose, but it is not all things, and we should not make it all things. We need to use other PHP Apps, which need to be on the same server as our Moodles, and thusly we need a single login to access all of them. I doubt that LDAP will meet that need, as the Moodles are not on the same servers as each school. In short, it is a bit of a nightmare, but it is getting to the point where others are recognising that Moodle on its own is going to be insufficient to meet all our needs. We need Mahara, we need Mediawiki, and I would suggest we also need WordPress. I have all these set up on my private server and I do not understand enough about PHP to develop my own  single login. But we need it - if not right now, then in a year or two.

I am also quite sceptical about the longer term economic health of the world, so delivering cheaper school support services that will last for many years without replacing the computers, the servers or the software, is going to be a high priority. As licensing will become a thing of the past, as most of the existing companies will disappear,  even Microsoft and Adobe, and Apple, and be replaced with who knows, we will need to depend on Open Source, and have people who can run fixits, make patches and so on, just to keep things going - but that is another story.

In reply to Colin Fraser

Re: Login from script outside of moodle

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Colin,

I did a cursory check and WordPress, phpMyAdmin, Mahara, MediaWiki all seem to have LDAP authentication options even if they are plugins or extensions.

I've had some chats with folks involved with the Ubuntu education sector about providing a united solution to the challenges faced by schools. From my perspective there are a few areas that need to be integrated to really assist schools:

  1. Student Information System (like OpenSIS) or SchoolTool
  2. Course Management System (CMS)
  3. possibly a Content Management System (like WordPress for cases where Moodle is not enough)
  4. Customer Relationship Software (for reaching out to donors and alums)
  5. Mahara or something for social networking, publishing of portfolios, etc.
  6. File Repository - like Nuxeo or Alfresco for organizing files

My dream is that we will begin to see open education comprised of open source software like Moodle, open content (Creative Commons licensed), and open community (volunteer labor to serve as teachers and administrators) so that we can begin to address challenges like the U.N.'s NineMillion.org project. In any case, it sinds like we share similar hopes for how open source can inspire and serve the educational needs of many people.

Peace - Anthony

In reply to Anthony Borrow

Re: Login from script outside of moodle

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Hi Anthony,

Unfortunately, the structure of our Moodles is such that LDAP is not a viable option. Ordinarily, this would be the most obvious solution, but not here, apparently.

Also, the true integration of these PHP Apps would create an unbelievably strong tool, but I suspect it would be a very difficult goal. There are not many with the required php skills, for starters, then there would be a matter of permissions, and, even though the apps are Open Source, I suspect that there would be a couple, at least, of the apps makers who would seriously object to the project, and so on. This is why I suspect the single login with a login page that rotates through the various login of each app and automatically log a person in is a far more realistic option.

If I have it right, the login would have to step through an existing array of login scripts, adapting the actual user login to each different database, all while loading a common front page. The mechanics appear simple, but the engineering would be a fairly sophisticated operation. This is all without changing the default skins to a common entity, the typefaces to common fonts, and so on and so on...  What a project!!! and I would gove it a go if I knew anything more than just <?php and ?>

Oh well...

In reply to Colin Fraser

Re: Login from script outside of moodle

by John Andrewartha -

Has anyone given Radius some thought?   It has a concept of Realms and can use most of the popular databases.  Moodle supports Radius.  I do note that it is a beast to configure.

Just a thought

John