General developer forum

pre authorising/logging in a user from an external site

 
Picture of jake williamson
pre authorising/logging in a user from an external site
 
hey out there,

sorry if this question has been asked a million times... it seems to be a common request but one that i can't get a concrete solution to!

i have a site written in asp.net where people register. during registration we create a moodle user using the moodle api running on our moodle site and store the id against the account. we would then like to be able to log the user in using this id on our moodle site. the asp.net and the moodle website are running on different domains but have access to the databases for both.

having dug through the php code i found that row is created in the 'mdl_sessions' table when user logs in. so my thinking was to create a row for the user in this table and then create the 'MoodleSession' cookie in the users browser. it appears that the value of the cookie is the session id for which i've been using the asp.net session id. then when we redirect the user to their course they're already logged in. so far so good.

however it appears that the 'sessdata' column in this table contains a base64 encoded string of session and user information and i can't figure out how to get this info in the right format in the asp.net site.

is this at all possible? am i barking up the wrong tree and going about this completely the wrong way?!

any pointers in the right direction would be greatly received ;)
 
Average of ratings: -
Picture of Darko Miletić
Re: pre authorising/logging in a user from an external site
Core developersParticularly helpful Moodlers

You want SSO between your system and Moodle. I can suggest to try with CAS . Moodle already has CAS support available. So once your systems starts working with CAS you have SSO with Moodle.

https://docs.moodle.org/34/en/CAS_server_(SSO)_authentication



 
Average of ratings: -
Picture of jake williamson
Re: pre authorising/logging in a user from an external site
 
1st class darko, that looks like it might just fit the bill ;)

i'll take a look and get back to you,

cheers,

jake
 
Average of ratings: -