I will first explain my situation.
My first site is a Laravel running on lets say: mylaravelapp.com
Then I have installed a moodle (3.5) instance on: moodle.mylaravelapp.com
Now... What I want to achieve is to authenticate the users on both sites at the same time.
In the laravel application I have the user 'like sync' with Moodle. So, the user 'jhon' in Laravel application has an account on moodle under the same username, 'jhon'.
So, when the user gets into the laravel login form at mylaravelapp.com and complete his authentication user and pass I need to:
* Authenticate user in Laravel application (this is not the problem)
* Authenticate the user on Moodle (using the data retrieved from the Laravel application)
Then, once the user its authenticated in both sites he can go to one or another without the need of authenticate again.
After reading docs and forum topics I found the way of doing this like:
* Creating an authentication plugin and posting data from Laravel site to Moodle site. The problem faced here is that is not working for me ... ... If I directly post from the moodle site its work, if not it returns like authenticated html page but then when trying to access another page it takes me to the authentication page.
* Creating an auto submit form in a php script. I don't like this solution
First of all, sorry for my English, but is not my native language.
Second and last... I appreciate any help or tip.
Firstly, I'm not familiar with Laravel but I don't think that matters. I've done quite a bit of this sort of thing.
Personally, I would solve this by (after authenticating in Laravel) redirecting to Moodle in a new window/tab. Create a plugin in Moodle with a 'landing' script and redirect to that passing the user details. Security can be handled with a simple one time token and some web-service handshaking or you can use a "proper" authentication protocol (I find that overkill). Once you have established the user is ok, Moodle can simply call its own login scripts.
There are probably more elegant ways but the above is pretty simple.
Thank you very much for the answer Howard.
As you say, there should be more elegant ways but I will give a try to this.
So, using a plugin as you said... there is no need to do it with an Authentication plugin?
Hmm.... it's a matter of 'style'
I would possibly write the Moodle plugin as an authentication plugin. Then the authentication type for those users is (say) 'laravel'. That's a bit more work.
It could just as easily be done as a local plugin and add then as 'manual' users calling existing core functions. Up to you.
Thank you very much for the answer Howard!!! And sorry for my delay on response.
Is there a possible to authenticate the user without taking him to a new window/tab on the browser?