プライベートなトピックへのリンク時にSSOによる自動認証をトリガーできますか?

当社は、Discourse 向けの SSO プロバイダーとして自社アプリケーションを使用しており、自社アプリケーションから Discourse フォーラムのプライベートトピックへユーザーをリンクさせる際に問題が発生しています。具体的には、'ログイン’ボタンをクリックした場合にのみ認証がトリガーされるという現象です。

  • 当社は自社のシステムを Discourse 向けの SSO プロバイダーとして使用しています。
  • Discourse には公開ページと非公開ページが混在しているため、login_required は設定していません。
  • ユーザーが自社のシステムに認証した後、Discourse のルート URL にリンクすると、公開カテゴリが表示されますが、ログイン状態にはなりません。
  • ユーザーが自社のシステムに認証した後、Discourse の /login にリンクすると、正常にログインされ、Discourse のルート URL にリダイレクトされます。
  • ユーザーが自社のシステムに認証した後、Discourse のプライベートカテゴリ/トピックの URL にリンクすると、ログインを促すページが表示されます。ここで’ログイン’をクリックすると、自動的にログインされ、カテゴリ/トピックが表示されます。

この最後のケースが問題です。以下のいずれかの対応が望ましいと考えられます。

  • ourdiscourse.com/c/some-category?login=true にリンクし、認証チェックを実行する。ユーザーがログイン済みであればトピックを表示し、未ログインの場合は自社の SSO プロバイダーに誘導し、ログイン後にトピックへリダイレクトする。
  • ourdiscourse.com/login?redirect=c/some-category にリンクし、認証チェックを実行する。成功すればクエリ文字列で指定されたページへリダイレクトし、失敗すれば SSO プロバイダーへ誘導し、認証成功後にクエリ文字列で指定されたページへリダイレクトする。
  • ourdiscourse.com/c/some-category にリンクし、そのページが非公開の場合、Discourse が認証チェックを実行する。成功すればカテゴリへ移動し、失敗すれば SSO プロバイダーへ誘導し、その後リダイレクトする。

よろしくお願いいたします。

(以前、この件について こちら で投稿しましたが、重複投稿で申し訳ありません。新しいトピックの方が反応が得られるかもしれないと考え、再度投稿しました。)

You can create an login link on your SSO provider site with a return_path parameter in the URL. After authentication, Discourse will redirect the user to the value set for the return_path. The link should be in this form:

<a href="https://forum.example.com/session/sso?return_path=https://forum.example.com/your-discourse-endpoint">Link Text</a>
「いいね!」 5

Can’t they also have the SSO do something similar so that when they log in to the SSO they are also logged in to Discourse?

The only ways I know of auto logging in users to Discourse when the login to the SSO provider site seem a little hacky. With the use of SSO login links in the form I gave above and the sync_sso route for updating users without requiring them to login, I can’t see where it would be required.

「いいね!」 1

Thank you - this has worked perfectly.

I’m not sure if we are doing this - what would be the way to check?

EDIT: should have searched first… details here: Sync DiscourseConnect user data with the sync_sso route

「いいね!」 3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.