Customized login auth plugin

AI-generated summary

The discussion revolves around creating a customized login auth plugin for Discourse. Asoul wants to implement a plugin that disables sign-up, authenticates users against an external database, and logs them into Discourse. fefrei suggests using Discourse’s SSO support, which can handle authentication with an external application that uses its own database.

Asoul initially thinks SSO is not suitable, but fefrei clarifies that SSO can work with an external application’s database. Asoul then considers two options: building an external app with SSO or creating a Discourse plugin that connects to the database for authentication. fefrei strongly advises against the second option due to the complexity of handling edge cases, recommending instead to build a thin app for SSO, which can be seamlessly integrated with Discourse.

Hi, I’m new to discourse,

I want to create a plugin for customized login that contains below feature:

  • No signup button on homepage, and can not create new account in discourse
  • After click signin button, user will be authenticate to external database
  • After authentication, get user information and login to discourse

Is there any document or sample code for that? or these feature has already done before?

Thanks

Discourse’s SSO support does exactly this:

1 Like

Hi @fefrei

I thought this SSO plugin is for external site authentication,
not directly use discourse connect to database for authentication.

Do I misunderstand that?

Thanks

I’m not sure I understand the difference between these two options.

SSO means that Discourse will ask an external application to handle authentication, which can then use its database to handle the requests.

Yes, that’s a way to do it.

But for me there is no the “external application” now, so I’m wondering which one is simpler

  1. Build an external app connect to database, and build the SSO part
  2. Build an discourse plugin connect to database for authentication

The second option is a world of pain, because there are a ton of edge cases in using an external user database, most of which are already handled beautifully by Discourse’s SSO implementation.

Go for option one, and build a thin app to handle SSO. Remember that your users don’t have to know about SSO at all – you can style the login prompt as you wish to make this all seamless :slight_smile:

6 Likes