vinkas / discourse
PHP library to authenticate your forum using Discourse Connect
v2.1.0
2024-11-23 17:34 UTC
Requires
- php: ^8.1
- saloonphp/saloon: ^3.10
Requires (Dev)
- pestphp/pest: ^3.5
- phpstan/phpstan: ^2.0
README
PHP library to authenticate your forum using Discourse Connect
Installation
The package vinkas/discourse
can be installed using composer via packagist.
composer require vinkas/discourse
Documentation
Creating a Discourse client
$discourse = new Vinkas\Discourse\Client('discourse.example.com', true); // set true if ssl enabled
Discourse Connect
$payload = $_GET['sso'];
$signature = $_GET['sig'];
$connect = $discourse->connect('SECRET', $payload, $signature);
if (!($connect->isValid())) {
header("HTTP/1.1 403 Forbidden");
echo("Bad Discourse Connect request");
die();
}
$userParams = array(
'external_id' => 'USER_ID',
'email' => 'EMAIL_ADDRESS',
'username' => 'USERNAME', // optional
'name' => 'FULL_NAME' // optional
// for more available fields https://meta.discourse.org/t/13045
);
$url = $connect->getResponseUrl($userParams)
header('Location: ' . $url);
exit(0);
Visit https://meta.discourse.org/t/setup-discourseconnect-official-single-sign-on-for-discourse-sso/13045 for more details about Discourse Connect.