OmniAuth integration documentation


(Nathan) #1

I’m looking for any documentation about integrating new OmniAuth plugins with Discourse.

I’ve gotten to the point where, having come back from our authentication service, Discourse calls the callback for our OmniAuth strategy, which appears to function correctly but Discourse itself sends a 403 response with the words “The page you requested doesn’t exist on this discussion forum. Perhaps we can help find it, or another topic like it” in it.


(Atul Varma) #2

Hey, I just ran into this exact same problem 369 days after your original post!

I found out that the error, at least on my side, was occurring because my ::Auth::Authenticator subclass’s name method (or attribute? I’m new to Ruby) needed to return the all lowercase name of the OmniAuth strategy it registers in register_middleware.

In my case, it was returning the capitalized name of the OmniAuth strategy, so the code in Users::OmniauthCallbacksController#complete didn’t find my authenticator, which is what kicked off the 403. As soon as I made it all lowercase, everything worked.

I suspect this may be either a bug in Discourse or suboptimal API design since it seems to violate the Don’t Repeat Yourself (DRY) principle, but as I said, I’m new to Ruby and Rails and all this stuff so I have no idea.

Anyways, I hope you or someone else who stumbles across this thread finds this useful.