mirror of https://github.com/flarum/flarum
Merge branch 'master' of https://github.com/pipindex/flarum into roman
commit
656bc8b425
26
readme.md
26
readme.md
|
@ -9,13 +9,31 @@
|
||||||
## SSO Mock
|
## SSO Mock
|
||||||
|
|
||||||
* Step 1: Before you try this out, make sure you paste `6cdVzOYGVW` in the api_keys of the flarum database in MySQL.
|
* Step 1: Before you try this out, make sure you paste `6cdVzOYGVW` in the api_keys of the flarum database in MySQL.
|
||||||
* Step 2: Head to [here](http://localhost:9999/admin#/extensions) and enable *Single Sign On* extension.
|
* Step 2: Create a `config.php` file in the `sso` folder with the contents given at the very bottom.
|
||||||
* Step 3: Fill in the details as shown in the image below.
|
* Step 3: Head to [here](http://localhost:9999/admin#/extensions) and enable *Single Sign On* extension.
|
||||||
* Step 3: Now, navigate to `sso` folder and run `php -S localhost:8888`
|
* Step 4: Fill in the details as shown in the image below.
|
||||||
* Step 4: Access the sample SSO website on `localhost:8888`
|
* Step 5: Now, navigate to `sso` folder and run `php -S localhost:8888`
|
||||||
|
* Step 6: Access the sample SSO website on `localhost:8888`
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
```
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
// URL to your Flarum forum
|
||||||
|
'flarum_url' => 'http://localhost:9999',
|
||||||
|
// Domain of your main site (without http://)
|
||||||
|
'root_domain' => 'localhost',
|
||||||
|
// Create a random key in the api_keys table of your Flarum forum
|
||||||
|
'flarum_api_key' => '6cdVzOYGVW',
|
||||||
|
// Random token to create passwords
|
||||||
|
'password_token' => 'NotSecureToken',
|
||||||
|
// How many days should the login be valid
|
||||||
|
'lifetime_in_days' => 14,
|
||||||
|
];
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
___
|
___
|
||||||
* Last revision on 16/09/2017
|
* Last revision on 16/09/2017
|
||||||
* @aligajani
|
* @aligajani
|
||||||
|
|
|
@ -41,10 +41,12 @@ class SSOController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirects a user back to the forum.
|
* Redirects a user back to the forum.
|
||||||
|
* @param $targetUrl
|
||||||
*/
|
*/
|
||||||
public function redirectToForum()
|
public function redirectToForum($targetUrl)
|
||||||
{
|
{
|
||||||
header('Location: ' . $this->config['flarum_url']);
|
$targetUrl = (!is_null($targetUrl)) ? $targetUrl : '';
|
||||||
|
header('Location: ' . $this->config['flarum_url'] . $targetUrl);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
require_once('SSOController.php');
|
require_once('SSOController.php');
|
||||||
|
|
||||||
$authToken = $_GET['auth_token'];
|
$authToken = $_GET['auth_token'];
|
||||||
|
$targetUrl = (isset($_GET['target_url'])) ? $_GET['target_url'] : null;
|
||||||
if (!isset($authToken) || empty($authToken) || $authToken == "") echo 'Login failed';
|
if (!isset($authToken) || empty($authToken) || $authToken == "") echo 'Login failed';
|
||||||
$decodedTestData = json_decode(base64_decode($authToken));
|
$decodedTestData = json_decode(base64_decode($authToken));
|
||||||
|
|
||||||
|
@ -12,4 +13,4 @@ $avatarUrl = $decodedTestData->avatarUrl;
|
||||||
|
|
||||||
$forum = new SSOController();
|
$forum = new SSOController();
|
||||||
$forum->login($username, $email, $avatarUrl);
|
$forum->login($username, $email, $avatarUrl);
|
||||||
$forum->redirectToForum();
|
$forum->redirectToForum($targetUrl);
|
||||||
|
|
|
@ -200,7 +200,8 @@
|
||||||
console.log(fake);
|
console.log(fake);
|
||||||
console.log(encoded);
|
console.log(encoded);
|
||||||
|
|
||||||
var authRedirect = "/auth.php?auth_token=" + encoded;
|
var targetUrl = "&target_url=/t/parent-tag";
|
||||||
|
var authRedirect = "/auth.php?auth_token=" + encoded + targetUrl;
|
||||||
$('.visit-link').attr("href", authRedirect);
|
$('.visit-link').attr("href", authRedirect);
|
||||||
|
|
||||||
$('.profile-userpic .img-responsive').attr("src", randomAvatar);
|
$('.profile-userpic .img-responsive').attr("src", randomAvatar);
|
||||||
|
|
Loading…
Reference in New Issue