ASP.NET MVC Single-Sign-On

(Paul Apostolos) #1

I implemented the official single sign on for Discourse ( Official Single-Sign-On for Discourse (sso) thanks @sam ) in ASP.NET MVC.

I posted a Gist of a simple implementation using only a controller method here:

( ASP.NET MVC Discourse SSO Example · GitHub )

Hopefully others will find this useful.


Discourse with .NET?
Active Directory SSO aka Integrated Windows Login
RuntimeError Bad signature for payload during SSO login and signup
Official Single-Sign-On for Discourse (sso)
Ldap support?
Discourse single-sign-on integration with SharePoint
(Sam Saffron) #2

Awesome, is it working well for you?

(Paul Apostolos) #3

Yeah @sam. See my PM and let me know.

One thing on the SSO…I talked about how to let the user bypass the “clicking the login button” step. That is, if they click on the forum link on our website, and they are already logged in (on our site not Discourse), they wouldn’t need to click the login button on the Discourse to trigger the SSO process.

Turns out, if I just make the link to the forum (Discourse) http://mydiscoursesite/session/sso?return_path=%2F – it works. No extra clicking…But, I’m sure you already knew that.

(Sam Saffron) #4

nice trick, yeah that works

(Admir Hodzic) #5

@paully21 Is it OK for you to I use your sample and reedit it to work woth WebAPI ?
I have an idea to make DNN module whic will provide SSO.
Project will be open source and hosted at codeplx.
Thanx in advnaced

(Paul Apostolos) #6

Go for it…That’s why I put it on GitHub. Just make sure to share back to the community.

(Admir Hodzic) #7

Can You please describe this little more ?
How to redirect users from main site to discoursesite whit automatic login.
Thanx in advanced

(Kane York) #8

To restate @paully21’s post:

If your forum is set up with the official SSO implementation, and your site is at, then on your main site, place this link:

<a href="">Forums</a>

(Admir Hodzic) #9

Thanx a lot.
I was confused about return_path param.
It is simple, I thought that I need to set some values for param inside link.

(Jon Kragh) #10

Thanks for this code sample @paully21! Works great - do you have SSO working with avatars by any chance?

I’m trying to get that to work with my MVC site and it’s not working yet.