Skip to content

nikitanp/laravel-discourse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discourse API Client and SSO for the Laravel Framework

Latest Version on Packagist Total Downloads


Version Compatibility

Laravel framework 6 and higher.

Getting Started

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

Installation

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"

Configure Laravel Discourse API Library

Laravel Env

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

Discourse Env

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

Credits

Forked from: matthew-jensen/laravel-discourse-client.

SSO Helper Methods: cviebrock/discourse-php.

SSO Controller Methods: spinen/laravel-discourse-sso.