fly3949/flarum-ext-sso

A SSO extension for flarum.

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 13

Type:flarum-extension


README

License Latest Stable Version

A Flarum extension. A SSO extension for flarum.

!!! Attention !!!

It is NOT fully tested. Do NOT install it in production.

Installation

Use Bazaar or install manually with composer:

composer require fly3949/flarum-ext-sso

How To Use

After installation, you should generate a secret key (strong enough) and fill it into the extension setting page.

Then, in your app, redirect your user to the login url:

https://example.com/session/sso_login?
    email=example@example.com &
    id=1 &
    username=example &
    time=1591359188 &
    signature=3ec02dd23291fbed8faac4cef71b5f284c0ff955cc1d27f5e30efabe4ee40008

Here is the example code (in a Laravel app):

$email = 'example@example.com';
$id = 1;
$username = 'example';
$now = Carbon::now()->timestamp;
$secret = env('FLARUM_SSO_KEY'); // for example: VRSW1xDk1e1gsC8zIOaOiJhg6xTKrqm4o6Gt7LAS

$data = [
    'email' => $email,
    'id' => $id,
    'username' => $username,
    'time' => $now,
    'signature' => hash_hmac('sha256', $email . $id . $username . $now, $secret)
];

$query = http_build_query($data);

return redirect('https://example.com/session/sso_login?' . $query);

Updating

composer update fly3949/flarum-ext-sso

Links

Thanks To