Following the guide DiscourseConnect - Official Single-Sign-On for Discourse (sso) I’ve enabled Discourse SSO to share login with my existing RoR application, but I get “Error ArgumentError in DiscourseSsoController#sso, wrong number of arguments (given 1, expected 0)” after being redirected to my website and having done login.
Looking at the screenshot, that error appears to be coming from your custom rails app, rather than Discourse. Is that correct? I don’t think Discourse has a
DiscourseSsoController#sso method, and the backtrace doesn’t look like Discourse either.
How have you implemented that method in your rails app? Have you imported some parts of the code from Discourse’s codebase? If so, your imports might be affected by this change: SECURITY: Attach DiscourseConnect (SSO) nonce to current session (#12… · discourse/discourse@13d2a1f · GitHub
This class is in my application, but it’s official code from DiscourseConnect - Official Single-Sign-On for Discourse (sso) that I’ve putted in my application to manage SSO
I see, so you’ve copied the contents of single_sign_on.rb? I guess we might need a documentation update here. Can you try adding a new function inside the
SingleSignOn class in your
def initialize(**kwargs) end
I think that should resolve the error you’re seeing.
Can you also confirm what version of Ruby you’re using?
Yes, I’ve copied the contents of single_sign_on.rb
I’m using Ruby 2.4.6
After adding initialize the error changed
Did you restart the server? I can’t think why an error would be raised on an
end line, so I suspect the running code does not match what’s on the filesystem?
That could well be part of the problem. Discourse code is all written for 2.7+
Excuse me my fault, I did not restart the server, having no noticed the modification was on initializer
Having Devise with CanCanCan I had to do also this: comment before_action and add skip_authorization_check:
class DiscourseSsoController < ApplicationController skip_authorization_check #before_action :authenticate_user! # ensures user must login