tinfot/discourse-sso

Laravel Discourse SSO

0.0.3 2018-03-12 03:49 UTC

This package is not auto-updated.

Last update: 2024-11-08 07:56:27 UTC


README

License

Installation

Require this package in your composer.json and update composer.

composer require tinfot/discourse-sso:dev-master

Usage

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Tinfot\Discourse\Payload;
use Tinfot\Discourse\User;
use Tinfot\Discourse\Sso;

class DiscourseController extends Controller {
    
    public function sso(Request $request) {
        $payload = new Payload(config('discourse.secret'));
        if (!$payload->validate($request->input('sso'), $request->input('sig'))) {
            abort(404);
        }

        $auth = $request->user();

        $nonce = $payload->decode($request->input('sso'));
        $sso   = new Sso($nonce, config('discourse.secret'));
        $sso->setParameters(new User($auth->id, $auth->email, $auth->name));
        $data = $sso->build($payload);
        return redirect(config('discourse.discourse_url') . $data);
    }
}

Support

Support only through Github. Please don't mail us about issues, make a Github issue instead.