Fixing the broken slack auth plugin

Hi there guys! Just started messing around with a discourse instance and wanted to add authentication via slack. Found an existing plugin but it’s broken so I decided to try and patch it up however I am no ruby dev at all and don’t have an env to set up for local testing and whatnot. I’ve published my fixes to the plugin at https://github.com/Kukks/oauth-slack-discourse/ but the discourse builder fails on it and I’m unsure why. Can someone point me in the right direction? :slight_smile:

The code is almost identical to the linkedin auth plugin.

Do you mean it fails when running ./launcher rebuild app? Can you share the output please?

2 Likes

Thanks for replying @jomaxro.
Yup, that’s the one. Output below:

Bundle complete! 111 Gemfile dependencies, 201 gems now installed.
Gems in the group development were not installed.
Bundled gems are installed into `./vendor/bundle`

I, [2018-09-14T07:53:36.321758 #14]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
LoadError: cannot load such file -- ginjo-omniauth-slack
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
/var/www/discourse/lib/plugin_gem.rb:20:in `load'
/var/www/discourse/lib/plugin/instance.rb:507:in `gem'
/var/www/discourse/plugins/oauth-slack-discourse/plugin.rb:8:in `activate!'
/var/www/discourse/lib/plugin/instance.rb:437:in `instance_eval'
/var/www/discourse/lib/plugin/instance.rb:437:in `activate!'
lib/discourse.rb:164:in `block in activate_plugins!'
lib/discourse.rb:161:in `each'
lib/discourse.rb:161:in `activate_plugins!'
/var/www/discourse/config/application.rb:224:in `<class:Application>'
/var/www/discourse/config/application.rb:39:in `<module:Discourse>'
/var/www/discourse/config/application.rb:38:in `<top (required)>'
/var/www/discourse/Rakefile:5:in `require'
/var/www/discourse/Rakefile:5:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
I, [2018-09-14T07:53:55.035148 #14]  INFO -- : gem install ginjo-omniauth-slack -v 2.4.0 -i /var/www/discourse/plugins/oauth-slack-discourse/gems/2.5.1 --no-document --ignore-dependencies
Successfully installed ginjo-omniauth-slack-2.4.0
1 gem installed

I, [2018-09-14T07:53:55.035909 #14]  INFO -- : Terminating async processes
I, [2018-09-14T07:53:55.035983 #14]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/10/bin/postmaster -D /etc/postgresql/10/main pid: 69
2018-09-14 07:53:55.036 UTC [69] LOG:  received fast shutdown request
I, [2018-09-14T07:53:55.036708 #14]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 185
185:signal-handler (1536911635) Received SIGTERM scheduling shutdown...
2018-09-14 07:53:55.066 UTC [69] LOG:  aborting any active transactions
185:M 14 Sep 07:53:55.068 # User requested shutdown...
185:M 14 Sep 07:53:55.068 * Saving the final RDB snapshot before exiting.
2018-09-14 07:53:55.070 UTC [69] LOG:  worker process: logical replication launcher (PID 78) exited with exit code 1
2018-09-14 07:53:55.071 UTC [73] LOG:  shutting down
185:M 14 Sep 07:53:55.150 * DB saved on disk
185:M 14 Sep 07:53:55.150 # Redis is now ready to exit, bye bye...
2018-09-14 07:53:55.162 UTC [69] LOG:  database system is shut down


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 646 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
492d48f97d0280a16a181bf84f908ba5b874a7fb38bf50964c7c9de0966b2785
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

Perhaps try using https://github.com/kmrshntr/omniauth-slack instead of ginjo-omniauth-slack? From a quick review it seems that the ginjo gem is deprecated.

According to this thread, ginjo should be a more or less fork of that repo

https://github.com/kmrshntr/omniauth-slack/issues/63

So it does. Sadly I can’t help much beyond that suggestion. I’ll note that it does appear to eventually install successfully later in the logs. Perhaps one of the community developers could offer better suggestions.

2 Likes