Omniauth Steam strategy issues


(James Didehvar) #1

Continuing the discussion from Brand new plugin interface:

I’ve tried to get a Steam auth plugin working based on the vkontakte plugin above. I created a working fresh install of Discourse and followed the MathJax plugin installation steps (rake plugin:install repo=https://github.com/didehvar/steam_auth & rake assets: precompile).

Upon running the compile I recieve the following error:

gem install omniauth-steam -v 1.0.3 -i /var/www/discourse/plugins/steam_auth/gems/2.0.0 --no-document --ignore-

dependencies
Successfully installed omniauth-steam-1.0.3
1 gem installed
rake aborted!
cannot load such file -- omniauth/openid
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-openid-1.0.1/lib/omniauth/strategies/steam.rb:1:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
/var/www/discourse/plugins/steam_auth/gems/2.0.0/gems/omniauth-steam-1.0.3/lib/omniauth-steam.rb:2:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
/var/www/discourse/lib/plugin/instance.rb:230:in `gem'
/var/www/discourse/plugins/steam_auth/plugin.rb:6:in `activate!'
/var/www/discourse/lib/plugin/instance.rb:155:in `instance_eval'
/var/www/discourse/lib/plugin/instance.rb:155:in `activate!'
/var/www/discourse/lib/discourse.rb:73:in `block in activate_plugins!'
/var/www/discourse/lib/discourse.rb:73:in `each'
/var/www/discourse/lib/discourse.rb:73:in `activate_plugins!'
/var/www/discourse/config/application.rb:152:in `<class:Application>'
/var/www/discourse/config/application.rb:29:in `<module:Discourse>'
/var/www/discourse/config/application.rb:28:in `<top (required)>'
/var/www/discourse/Rakefile:5:in `require'
/var/www/discourse/Rakefile:5:in `<top (required)>'

I can fix this error by editing /omniauth-openid-1.0.1/lib/omniauth/strategies/steam.rb and changing

require 'omniauth/openid'

to

require 'omniauth-openid'

Running assets: precompile now succeeds with no errors:

    Purging temp files
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
I, [2014-03-18T01:28:03.421572 #3538]  INFO -- : Writing /var/www/discourse/public/assets/common-a05553acd38733f3917d1d4c74880c95.css
I, [2014-03-18T01:28:11.036520 #3538]  INFO -- : Writing /var/www/discourse/public/assets/desktop-fa9ce8704432b82c938c955721b1066b.css
I, [2014-03-18T01:28:15.671740 #3538]  INFO -- : Writing /var/www/discourse/public/assets/mobile-fb2b90f1d1d3c6cd25e34549e7a21aee.css

After restarting Discourse using ./launcher stop app & start app respectively I simply get a white page with no source. If I remove the plugin and recompile the site works fine. I’m guessing editing a gem’s source file like that is probably a no-go and I’m certainly not a hugely experienced Rails developer so was just fixing errors.

Any ideas as to why this isn’t working? Perhaps a simple rookie mistake or a broken Omniauth strategy?

Thanks!


(Sam Saffron) #2

what does the error log say? Did you re-bootstrap?

errors are in /var/docker/shared/logs/rails/production.log


(James Didehvar) #3

Yeah I’ve tried re-bootstrapping multiple times, just tried again and has no effect.

However, I’m getting the following in the production log:

Started GET "/" for 151.228.64.136 at 2014-03-18 02:46:23 +0000
ArgumentError (Received wrong number of arguments. ["--API KEY--"]):
  lib/middleware/anonymous_cache.rb:104:in `call'
  config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
  config/initializers/silence_logger.rb:19:in `call'
  lib/middleware/unicorn_oobgc.rb:95:in `process_client'

I’ve removed the API key but that is what was showing between the brackets.

Thanks for your help so far.


(James Didehvar) #4

Following up from this I created a local Rails app to test the gem. Everything works fine. I checked the file at

/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-openid-1.0.1/lib/omniauth/strategies/steam.rb

which has the require:

require 'omniauth/openid'

I’ve changed it back to this on the server and I’m getting the same error as in the initial post:

cannot load such file -- omniauth/openid

I’m just speculating, but I that for whatever reason the strategy in the omniauth-openid gem is being used as opposed to the strategy in the omniauth-steam gem. I’m not sure how or why there is a Steam strategy in the omniauth-openid gem… According to the github repo there shouldn’t be, but the gem doc shows that there is!

Apparently the strategy was removed, but it appears the gem was never updated? Should I tell someone about this?

Is there any way to get the plugin to use the omniauth-steam gem as opposed to an ancient strategy in the omniauth-openid gem? Locally it appears to do this automatically, but with the docker container this is not the case!


(InsaneMosquito) #5

@didehvar, did you ever get a Steam auth plugin functioning?


(James Didehvar) #6

No, we decided to keep our current authentication system and simply implement single sign on for Discourse.

@def contacted me at one point asking the same question though, maybe he found a solution.


(Jonathan Feist) #7

I wish I understood Rails more because I’d probably have figured it out but it’s too hard for me and Discourse is a behemoth that makes me want to take an axe to my monitor.

Some starting resources/ideas that you may need to do this:

  • Make this as a plugin because then all you will need to do is add an environment variable STEAM_WEB_API_KEY: "the_api_key" under env: in /var/docker/containers/app.yml and some clone of the plugin under hooks: like - git clone https://gist.github.com/b88ce5ff074efaeefca2.git steam

In an ordinary Rails application, some of the main issues that crop up with getting Steam authentication to work includes:

  • Having to change the cookie serializer to :marshal instead of :json e.g. Rails.application.config.action_dispatch.cookies_serializer = :marshal

  • Making sure to skip the CSRF check (or something?) with something like skip_before_action :verify_authenticity_token, only: [:steam] in whatever controller handles the callback.

  • If you do not see the Steam link I just added "steam" to the array in login_method.js But yeah, all kinds of variations of this when I hack with Discourse.

Well I threw together a plugin based on Sam’s VK login example. Wonder if anyone can make it work. https://gist.github.com/defaye/b88ce5ff074efaeefca2

After the gem has installed I get the following error (which I suppose puts me at the point where didehvar got to):

/home/user/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- omniauth/openid (LoadError)

(@SenpaiMass) #8

Did u get the plugin to work at production level ?


(@SenpaiMass) #9

@def have u got this working ?


(Jonathan Feist) #10

Hi Alankrit. No, I’ve not got this working but I’m taking a look at it in spare time however this is not on my list of priorities at the moment.


(@SenpaiMass) #11

Cool thanks , waiting for this plugin.


(Jonathan Feist) #12

My steam authentication plugin should now work.

Be sure to test locally, but it worked on my Discourse Docker install just fine.


(@SenpaiMass) #13

Tested and works flawlessly. This is a great addition for the all the discourse based gaming communities


(Sam Saffron) #14

Be sure to post a topic in extensibility/plugins about this.


#15

Thanks - this is brilliant, seems to work perfectly!


(Jonathan Feist) #16

You’re welcome guys, will do @sam :smile: