Laravel framework 6 and higher.
Before going through the rest of this documentation, please take some time to read the Discourse API Documentation. Not all of the API calls are documented, but it's a good place to start. Additional help with SSO: https://meta.discourse.org
composer require nikitanp/laravel-discourse
This package auto discovered by laravel!
You can optionally publish the config file with:
php artisan vendor:publish --provider="NikitaMikhno\LaravelDiscourse\DiscourseServiceProvider" --tag="config"
Set the API Token, Forum url and SSO Token in your .env:
DISCOURSE_URL=https://forum.url
DISCOURSE_SECRET={sso secret}
DISCOURSE_TOKEN={api token}
DISCOURSE_SSO_ENABLED=true/false
Enable SSO Via UI: see: "{DISCOURSE_URL}/admin/site_settings/category/required?filter="
Via console:
cd /var/discourse
./launcher enter app
rails c
irb > SiteSetting.sso_secret = {config('discourse.secret')}
irb > SiteSetting.sso_url = {config('discourse.route')}
irb > SiteSetting.logout_redirect = {config('discourse.logout')}
irb > SiteSetting.enable_sso = true
irb > SiteSetting.enable_local_logins = false
irb > exit
exit
Forked from: matthew-jensen/laravel-discourse-client.
SSO Helper Methods: cviebrock/discourse-php.
SSO Controller Methods: spinen/laravel-discourse-sso.