Closed cyust closed 6 years ago
Yes the authenticate api for the settings change in 3.3 so now it's consistent with all other plugins. It's way way better but also is a bit of a hassle for every auth plugin to now swap over. I don't think any of our current clients will be using this on 3.3 any time soon, so if you'd like to sponsor this work please contact us: https://www.catalyst-au.net/contact-us
Hi. I've never used Moodle before nor do I know anything about its plugin architecture or PHP for that matter. However, this plugin appears to be the solution to a very common user experience request for third-party vendors so I'm curious how hard it would be for the community to upgrade it to 3.3.
What is the effort involved in upgrading this plugin to 3.3?
Can a non-PHP developer or Moodle-domain-expert upgrade the plugin trivially?
Thank you in advance and thanks for making a great plugin.
The admin settings api for auth plugins was missed when moodle changed this api many version ago. Recently this was corrected and so all auth plugins need to be fixed. The changes are relatively straight forward but just a little tedious.
Roughly the steps are:
1) Remove the settings.html file and replace it with it's equivalent using the new api. Here is an example in another plugin:
https://github.com/catalyst/moodle-auth_saml2/blob/MOODLE_UPTO32/settings.html
https://github.com/catalyst/moodle-auth_saml2/blob/MOODLE_33PLUS/settings.php
2) Remove all the old methods: config_form, validate_form
3) Possibly write an upgrade script only if needed
It's probably a days work, if you want to have a crack at a pull request please do so. If you would like to sponsor this please contact us https://www.catalyst-au.net/content/contact-us
Hi guys, I tried to write a new settings.php that uses the new api.
By the way, I'm still getting an "exception":"invalid_parameter_exception","errorcode":"invalidparameter" error while trying to connect my test user to the moodle platform. Please find the attached settings.php, I also uploaded it in a new fork of this project.
Thank you
Alex
https://github.com/hoz1982/moodle-auth_userkey/commit/7bcdbbb660c27adfa6f915614447548523cc3181
thanks @hoz1982 can you please turn that into a pull request so it's easier for us to process?
I suspect that error you are getting is unrelated and possibly the parameter you are sending is simply invalid, we'd need much more info to debug that one.
Thank you @brendanheywood , I made a new pull request fot the settings.php file. About the error I'm getting, this is the code I'm trying to run: `<?php function getloginurl($useremail, $firstname, $lastname, $username, $ipaddress, $courseid = null, $modname = null, $activityid = null) { require_once('/var/www/html/curl.php'); $token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $domainname = 'http://xxxxxxxxxxxxxxx/moodle/'; $functionname = 'auth_userkey_request_login_url';
$param = [
'user' => [ 'firstname' => $firstname, 'lastname' => $lastname, 'username' => $username, 'email' => $useremail, 'ip' => $ipaddress ] ]; print_r($param); $serverurl = $domainname . '/webservice/rest/server.php' . '?wstoken=' . $token . '&wsfunction=' . $functionname . '&moodlewsrestformat=json'; $curl = new curl;
try { $resp = $curl->post($serverurl, $param); $resp = json_decode($resp); $loginurl = $resp->loginurl; } catch (Exception $ex) { return false; } var_dump($resp);
if (!isset($loginurl)) { return false; }
$path = ''; if (isset($courseid)) { $path = '&wantsurl=' . urlencode("$domainname/course/view.php?id=$courseid"); } if (isset($modname) && isset($activityid)) { $path = '&wantsurl=' . urlencode("$domainname/mod/$modname/view.php?id=$activityid"); }
return $loginurl . $path; } $ip = $_SERVER['REMOTE_ADDR'];
echo getloginurl('info@alexromani.it', 'xxxx', 'xxxxxx', 'xxxxxxx',$ip,'3',NULL,NULL);
?>`
I tried to echo the $param and this is the output Array ( [user] => Array ( [firstname] => test [lastname] => testkey [username] => user_testkey [email] => info@alexromani.it [ip] => xxxxxxxxxxxxx ) )
But I'm still getting the param error. Is there a way to check which of the params is not correct? maybe a way to pass just the email(wich I set as the mapping field value)? I'm working on a fix, please tell me if you see something wrong on the code. Thank you Alex
@brendanheywood problem fixed passing just the email, thank you :) By the way, I found a small issue in setting the keylifetime, I used a select to set it, but if I select '60' the key expire in a moment, else selecting '10' it lasts 10 seconds.... maybe turning it in a configtext settings will fix it
@hoz1982 I'm also getting "Invalid parameter value detected" error now. What does your $params look like now (given you said you got it to work with the email)?
{ "exception": "invalid_parameter_exception", "errorcode": "invalidparameter", "message": "Invalid parameter value detected", "debuginfo": "Missing required key in single structure: user" }
Thank you in advance.
Hi! you have to just pass the email, like this:
$param = [ 'user' => [ 'email' => $useremail ] ];
Remember to also select "email" as mapping field value in the config page of the plugin :)
Thank you, @hoz1982. I attempted what you suggested and I still got the same error message:
Missing required key in single structure: user
Which "required key" am I missing? :/
I am using Ruby. The error message makes it sound like I am not passing my $param object to the web service correctly. Essentially I am passing a JSON representation of that PHP $param array object as the body of the HTTP POST message which looks like this:
{"user":{"username":"abc@123.com","email":"abc@123.com"}}
What should the encoded data look like in my POST body? Can someone kindly generate a vanilla cURL command line command for me?
So very close and look forward to getting this to work for my client. Thank you in advance!
Hi @matthewzchanneleyes have you tried just with the email? eg {"user":{"email":"abc@123.com"}}
Yes, @hoz1982. I did try that to no avail. So intriguing.
WORKING NOW!
I solved it by encoding the HTTP POST body like so:
user[username]=abc@123.com
OR
user[email]=abc@123.com
They both work in my case and the implementation is brilliant.
@hoz1982 I greatly appreciate your efforts in upgrading to Moodle 3.4 for the community. Cheers!
This feature has just landed to MOODLE_33PLUS branch. Thanks @andrewhancox for contribution.
I downloaded the latest (version 2017051500) of the User Key Authentication plug-in and installation was successful on Moodle 3.3 with no error messages. However, the Settings page is missing from the "Authentication" Plug-in menu, so I am unable to configure & use the plugin.
See also similar comment from other user on https://github.com/catalyst/moodle-auth_userkey/issues/13.
I can provide screen shots or other details, please ask.