diff --git a/VENDOR CHANGES.md b/VENDOR CHANGES.md
index a358b43..bf34ad6 100644
--- a/VENDOR CHANGES.md
+++ b/VENDOR CHANGES.md
@@ -5,3 +5,6 @@ List here the hacks that need to be done in the 'vendor' folder.
* pixelfear/oauth2-dropbox
=> nothing to do, just saying that I actually use a personal fork of this rep where I changed the require version of League oauth2.
+
+* learningpool/oauth2-signonotron
+=> open src/Provider/signonotron.ini.dist, add your site's URL, and save the file as signonotron.ini
diff --git a/auth.php b/auth.php
index 9b06144..a7016b8 100644
--- a/auth.php
+++ b/auth.php
@@ -230,7 +230,8 @@ public function loginpage_hook() {
break;
case 'github':
case 'dropbox':
- // As Github/Dropbox doesn't provide firstname/lastname, we'll split the name at the first whitespace.
+ case 'signonotron':
+ // As Github/Dropbox/Signonotron doesn't provide firstname/lastname, we'll split the name at the first whitespace.
$githubusername = explode(' ', $userdetails->name, 2);
$newuser->firstname = $githubusername[0];
$newuser->lastname = $githubusername[1];
@@ -406,7 +407,7 @@ public function loginpage_hook() {
$content = str_replace(array("\n", "\r"), array("\\\n", "\\\r"), auth_googleoauth2_display_buttons(false));
$PAGE->requires->css('/auth/googleoauth2/style.css');
$PAGE->requires->js_init_code("buttonsCodeOauth2 = '$content';");
- $PAGE->requires->js(new moodle_url($CFG->wwwroot . "/auth/googleoauth2/script.js"));
+ $PAGE->requires->js(new moodle_url($CFG->httpswwwroot . "/auth/googleoauth2/script.js"));
}
}
}
@@ -645,6 +646,7 @@ function drawChart() {
[\'Dropbox\', ' . $providerstats->dropbox . ' ],
[\'VK\', ' . $providerstats->vk . ' ],
[\'Battle.net\', ' . $providerstats->battlenet . ' ],
+ [\'Sign-On-O-Tron\', ' . $providerstats->signonotron . ' ],
[\''.$strothermoodle.'\', ' . $providerstats->moodle . ' ]
]);
@@ -660,7 +662,8 @@ function drawChart() {
5: { color: \'#007ee5\'},
6: { color: \'#45668e\'},
7: { color: \'#00B4FF\'},
- 8: { color: \'#ee7600\'}
+ 8: { color: \'#ee7600\'},
+ 9: { color: \'#c900ad\'}
}
};
@@ -695,6 +698,7 @@ public function get_stats($periodindays = 60) {
'vk' => 0,
'battlenet' => 0,
'moodle' => 0,
+ 'signonotron' => 0,
'periodindays' => $periodindays);
// Retrieve the provider stats.
diff --git a/classes/provider/signonotron.php b/classes/provider/signonotron.php
new file mode 100644
index 0000000..16782f2
--- /dev/null
+++ b/classes/provider/signonotron.php
@@ -0,0 +1,68 @@
+.
+
+require_once($CFG->dirroot . '/auth/googleoauth2/vendor/autoload.php');
+
+class provideroauth2signonotron extends Learningpool\OAuth2\Client\Provider\Signonotron {
+
+ // THE VALUES YOU WANT TO CHANGE WHEN CREATING A NEW PROVIDER.
+ public $sskstyle = 'signonotron';
+ public $name = 'signonotron'; // It must be the same as the XXXXX in the class name provideroauth2XXXXX.
+ public $readablename = 'Sign-On-O-Tron';
+ public $scopes = array();
+
+ /**
+ * Constructor.
+ *
+ * @throws Exception
+ * @throws dml_exception
+ */
+ public function __construct() {
+ global $CFG;
+
+ parent::__construct([
+ 'clientId' => get_config('auth/googleoauth2', $this->name . 'clientid'),
+ 'clientSecret' => get_config('auth/googleoauth2', $this->name . 'clientsecret'),
+ 'redirectUri' => preg_replace('/http:/',
+ 'https:', $CFG->httpswwwroot .'/auth/googleoauth2/' . $this->name . '_redirect.php', 1),
+ 'scopes' => $this->scopes
+ ]);
+ }
+
+ /**
+ * Is the provider enabled.
+ *
+ * @return bool
+ * @throws Exception
+ * @throws dml_exception
+ */
+ public function isenabled() {
+ return (get_config('auth/googleoauth2', $this->name . 'clientid')
+ && get_config('auth/googleoauth2', $this->name . 'clientsecret'));
+ }
+
+ /**
+ * The html button.
+ *
+ * @param $authurl
+ * @param $providerdisplaystyle
+ * @return string
+ * @throws coding_exception
+ */
+ public function html_button($authurl, $providerdisplaystyle) {
+ return googleoauth2_html_button($authurl, $providerdisplaystyle, $this);
+ }
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 5e0d70e..89f1de6 100644
--- a/composer.json
+++ b/composer.json
@@ -8,6 +8,7 @@
"require": {
"league/oauth2-client": "^0.12.1",
"depotwarehouse/oauth2-bnet": "^3.0",
- "pixelfear/oauth2-dropbox": "dev-bugfix"
+ "pixelfear/oauth2-dropbox": "dev-bugfix",
+ "learningpool/oauth2-signonotron": "dev-master"
}
}
diff --git a/lang/en/auth_googleoauth2.php b/lang/en/auth_googleoauth2.php
index b29f7c6..8cbdc20 100644
--- a/lang/en/auth_googleoauth2.php
+++ b/lang/en/auth_googleoauth2.php
@@ -96,6 +96,13 @@
$string['auth_microsoftclientid_key'] = 'Microsoft v2 Application ID';
$string['auth_microsoftclientsecret'] = '';
$string['auth_microsoftclientsecret_key'] = 'Microsoft v2 Application secret';
+$string['auth_signonotronclientid'] = 'Information on how to generate the Sign-On-O-Tron Client ID/Secret can be found here. Sign-On-O-Tron only accepts HTTPS. Sign-On-O-Tron requires some additional setup, see VENDOR CHANGES.md and the readme at: googleoauth2/vendor/learningpool/oauth2-signonotron/README.md
+
Site URL: {$a->siteurl}
+
Site domain: {$a->sitedomain}
+
Valid OAuth redirect URIs: {$a->callbackurl}';
+$string['auth_signonotronclientid_key'] = 'Sign-On-O-Tron Client ID';
+$string['auth_signonotronclientsecret'] = 'See above.';
+$string['auth_signonotronclientsecret_key'] = 'Sign-On-O-Tron Client secret';
$string['microsoft_failure'] = 'Did not receive an authorization code from the Microsoft servers.';
$string['auth_googlesettings'] = 'Settings';
$string['couldnotauthenticate'] = 'The authentication failed - Please try to sign-in again.';
diff --git a/lib.php b/lib.php
index 7939c69..c790c11 100644
--- a/lib.php
+++ b/lib.php
@@ -40,7 +40,7 @@ function googleoauth2_html_button($authurl, $providerdisplaystyle, $provider) {
* @return array
*/
function provider_list() {
- return array('google', 'facebook', 'battlenet', 'github', 'linkedin', 'messenger', 'microsoft', 'vk', 'dropbox');
+ return array('google', 'facebook', 'battlenet', 'github', 'linkedin', 'messenger', 'microsoft', 'vk', 'dropbox', 'signonotron');
}
/**
diff --git a/signonotron_redirect.php b/signonotron_redirect.php
new file mode 100644
index 0000000..cdaa712
--- /dev/null
+++ b/signonotron_redirect.php
@@ -0,0 +1,19 @@
+.
+
+require('../../config.php');
+require_once($CFG->dirroot . '/auth/googleoauth2/lib.php');
+googleoauth2_provider_redirect('signonotron');
\ No newline at end of file