إعداد DiscourseConnect - تسجيل الدخول الموحد الرسمي لـ Discourse (sso)

DiscourseConnect is a core Discourse feature that allows you to configure “Single Sign-On (SSO)” to completely outsource all user registration and login from Discourse to another site. Offered to our pro, business and enterprise hosting customers.

:information_source: (Feb 2021) ‘Discourse SSO’ is now ‘DiscourseConnect’. If you are running an old version of Discourse, the settings below will be named sso_... rather than discourse_connect_...

The Problem

Many sites wishing to integrate with a Discourse site want to keep all user registration in a separate site. In such a setup all login operations should be outsourced to that different site.

What if I would like SSO in conjunction with existing auth?

The intention around DiscourseConnect is to replace Discourse authentication, if you would like to add a new provider see existing plugins such as: Discourse VK Authentication (vkontakte)

Enabling DiscourseConnect

To enable DiscourseConnect you have 3 settings you need to fill out:

enable_discourse_connect : must be enabled, global switch
discourse_connect_url: the offsite URL users will be sent to when attempting to log on
discourse_connect_secret: a secret string used to hash SSO payloads. Ensures payloads are authentic.

Once enable_discourse_connect is set to true:

  • Clicking on login or avatar will, redirect you to /session/sso which in turn will redirect users to discourse_connect_url with a signed payload.
  • Users will not be allowed to “change password”. That field is removed from the user profile.
  • Users will no longer be able to use Discourse auth (username/password, google, etc)

What if you check it by mistake?

See: Log back in as admin after locking yourself out with read-only mode or an invalid SSO configuration

Implementing DiscourseConnect on your site

:warning: Discourse uses emails to map external users to Discourse users, and assumes that external emails are secure. IF YOU DO NOT VALIDATE EMAIL ADDRESSES BEFORE SENDING THEM TO DISCOURSE, YOUR SITE WILL BE EXTREMELY VULNERABLE!

Alternatively, if you insist on sending unvalidated emails BE SURE to set require_activation=true, this will force all emails to be validated by Discourse. WE STILL STRONGLY ADVISE THAT YOU DO NOT DO THIS, so if you proceed with that setting enabled, you are assuming substantial risk.

Discourse will redirect clients to discourse_connect_url with a signed payload: (say discourse_connect_url is https://somesite.com/sso)

You will receive incoming traffic with the following

https://somesite.com/sso?sso=PAYLOAD&sig=SIG

The payload is a Base64 encoded string comprising of a nonce, and a return_sso_url. The payload is always a valid querystring.

For example, if the nonce is ABCD. raw_payload will be:

nonce=ABCD&return_sso_url=https%3A%2F%2Fdiscourse_site%2Fsession%2Fsso_login, this raw payload is base 64 encoded.

The endpoint being called must

  1. Validate the signature: ensure that HMAC-SHA256 of PAYLOAD (using discourse_connect_secret, as the key) is equal to the sig (sig will be hex encoded).
  2. Perform whatever authentication it has to
  3. Create a new url-encoded payload with at least nonce, email, and external_id. You can also provide some additional data, here’s a list of all keys that Discourse will understand:
    • nonce should be copied from the input payload
    • email must be a verified email address. If the email address has not been verified, set require_activation to “true”.
    • external_id is any string unique to the user that will never change, even if their email, name, etc change. The suggested value is your database’s ‘id’ row number.
    • username will become the username on Discourse if the user is new or SiteSetting.auth_overrides_username is set.
    • name will become the full name on Discourse if the user is new or SiteSetting.auth_overrides_name is set.
    • avatar_url will be downloaded and set as the user’s avatar if the user is new or SiteSetting.discourse_connect_overrides_avatar is set.
    • avatar_force_update is a boolean field. If set to true, it will force Discourse to update the user’s avatar, whether avatar_url has changed or not.
    • bio will become the contents of the user’s bio if the user is new, their bio is empty or SiteSetting.discourse_connect_overrides_bio is set.
    • Additional boolean (“true” or “false”) fields are: admin, moderator, suppress_welcome_message
  4. Base64 encode payload
  5. Calculate a HMAC-SHA256 hash of the payload using discourse_connect_secret as the key and Base64 encoded payload as text
  6. Redirect back to the return_sso_url with an sso and sig query parameter (http://discourse_site/session/sso_login?sso=payload&sig=sig)

Discourse will validate that the nonce is valid, and if valid, it will expire it right away so it can not be used again. Then, it will attempt to:

  1. Log the user on by looking up an already associated external_id in the SingleSignOnRecord model
  2. Log the user on by using the email provided (updating external_id) (unless require_activation = true)
  3. Create a new account for the user providing (email, username, name) updating external_id

Security concerns

The nonce (one time token) will expire automatically after 10 minutes. This means that as soon as the user is redirected to your site they have 10 minutes to log in / create a new account.

The protocol is safe against replay attacks as nonce may only be used once. The nonce is tied to the current browser session to protect against CSRF attacks.

Specifying group membership

If the discourse connect overrides groups option is specified, Discourse will consider the comma separated list of groups passed in groups.

Aside from groups, you may also specify group membership in your SSO payload using the add_groups and remove_groups attributes regardless of the discourse connect overrides groups option.

add_groups is a comma delimited list of group names we will ensure the user is a member of.
remove_groups is a comma delimited list of group names we will ensure the user is not a member of.

Reference implementation

Discourse contains a reference implementation of the SSO class:

A trivial implementation would be:

class DiscourseSsoController < ApplicationController
  def sso
    secret = "MY_SECRET_STRING"
    sso = DiscourseApi::SingleSignOn.parse(request.query_string, secret)
    sso.email = "user@email.com"
    sso.name = "Bill Hicks"
    sso.username = "bill@hicks.com"
    sso.external_id = "123" # unique id for each user of your application
    sso.sso_secret = secret

    redirect_to sso.to_url("http://l.discourse/session/sso_login")
  end
end

Transitioning to and from single sign on.

As long as the require_activation parameter is not set to true in the request payload, the system will trusts emails provided by the single sign on endpoint. This means that if you had an existing account in the past on Discourse with DiscourseConnect disabled, DiscourseConnect will simply re-use it and avoid creating a new account.

If you ever turn off DiscourseConnect, users will be able to reset passwords and gain access back to their accounts.

Real world example:

Given the following settings:

Discourse domain: http://discuss.example.com
DiscourseConnect url : http://www.example.com/discourse/sso
DiscourseConnect secret: d836444a9e4084d5b224a60c208dce14
Email validated: No (add require_activation=true to the payload)

User attempt to login

  • Nonce is generated: cb68251eefb5211e58c00ff1395f0c0b

  • Raw payload is generated: nonce=cb68251eefb5211e58c00ff1395f0c0b

  • Payload is Base64 encoded: bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI=

  • Payload is URL encoded: bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI%3D

  • HMAC-SHA256 is generated on the Base64 encoded Payload: 1ce1494f94484b6f6a092be9b15ccc1cdafb1f8460a3838fbb0e0883c4390471

Finally browser is redirected to:

http://www.example.com/discourse/sso?sso=bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGI%3D&sig=1ce1494f94484b6f6a092be9b15ccc1cdafb1f8460a3838fbb0e0883c4390471

On the other end

  1. Payload is validated using HMAC-SHA256, if the sig mismatches, process aborts.
  2. By reversing the steps above nonce is extracted.

User logs in:

name: sam
external_id: hello123
email: test@test.com
username: samsam
require_activation: true

Unsigned payload is generated:

nonce=cb68251eefb5211e58c00ff1395f0c0b&name=sam&username=samsam&email=test%40test.com&external_id=hello123&require_activation=true

order does not matter, values are URL encoded

Payload is Base64 encoded

bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGImbmFtZT1zYW0mdXNlcm5hbWU9c2Ftc2FtJmVtYWlsPXRlc3QlNDB0ZXN0LmNvbSZleHRlcm5hbF9pZD1oZWxsbzEyMyZyZXF1aXJlX2FjdGl2YXRpb249dHJ1ZQ==

Payload is URL encoded

bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGImbmFtZT1zYW0mdXNlcm5hbWU9c2Ftc2FtJmVtYWlsPXRlc3QlNDB0ZXN0LmNvbSZleHRlcm5hbF9pZD1oZWxsbzEyMyZyZXF1aXJlX2FjdGl2YXRpb249dHJ1ZQ%3D%3D

Base64 encoded Payload is signed

3d7e5ac755a87ae3ccf90272644ed2207984db03cf020377c8b92ff51be3abc3

Browser redirects to:

http://discuss.example.com/session/sso_login?sso=bm9uY2U9Y2I2ODI1MWVlZmI1MjExZTU4YzAwZmYxMzk1ZjBjMGImbmFtZT1zYW0mdXNlcm5hbWU9c2Ftc2FtJmVtYWlsPXRlc3QlNDB0ZXN0LmNvbSZleHRlcm5hbF9pZD1oZWxsbzEyMyZyZXF1aXJlX2FjdGl2YXRpb249dHJ1ZQ%3D%3D&sig=3d7e5ac755a87ae3ccf90272644ed2207984db03cf020377c8b92ff51be3abc3

Synchronizing DiscourseConnect records

You can use the POST admin endpoint /admin/users/sync_sso to synchronize a DiscourseConnect record, pass it the same record you would pass to the DiscourseConnect endpoint, nonce does not matter.

If you call admin/users/sync_sso from another site, you will need to include a valid admin api_key and a valid api_username in the request’s headers. See Sync DiscourseConnect user data with the sync_sso route for more details about how to structure the request.

Clearing DiscourseConnect records

If your external_id values from your DiscourseConnect provider have changed (perhaps you changed the generation algorithm, perhaps it’s a different endpoint) you can safely remove all the existing records using the rails console:

SingleSignOnRecord.destroy_all

Logging off users

You can use the POST admin endpoint /admin/users/{USER_ID}/log_out to log out any user in the system if needed.

To configure the endpoint Discourse redirects to on logout search for the logout redirect setting. If no URL has been set here you will be redirected back to the URL configured in discourse connect url.

Search users by external_id

User profile data can be accessed using the /users/by-external/{EXTERNAL_ID}.json endpoint. This will return a JSON payload that contains the user information, including the user_id which can be used with the log_out endpoint.

Existing implementations

  • The discourse_api gem can be used for SSO. Have a look at the SSO code in its examples directory to see a basic implementation.

  • Our WordPress plugin makes it easy to configure SSO between WordPress and Discourse. Details about setting it up are found on the SSO tab of the plugin’s options page.

Future work

  • We would like to gather more reference implementations for SSO on other platforms. If you have one please post to the Dev / SSO category.

Advanced Features

  • You can pass through custom user fields by prefixing the field name with custom. For example custom.user_field_1 can be used to set the value of the UserCustomField that has the name user_field_1.
  • You can pass avatar_url to override user avatar (SiteSetting.discourse_connect_overrides_avatar needs to be enabled). Avatars are cached so pass avatar_force_update=true to force them to update if the url is the same. Right now, you can’t pass an empty url to disable users’ avatar.
  • By default the welcome message will be sent to all new users created through SSO. If you wish to suppress this you can pass suppress_welcome_message=true
  • To configure your Discourse instance as a Discourse connect provider see: Using DiscourseConnect as an identity provider.

Debugging your DiscourseConnect provider

To assist in debugging DiscourseConnect you may enable the site setting verbose_discourse_connect_logging. By enabling that site setting rich diagnostics will show up in YOURSITE.com/logs. Be sure to :white_check_mark: the warnings box at the bottom of YOURSITE.com/logs.

We will log a warning to the logs with a full dump of the SSO payload:

Last edited by @MarkDoerr 2025-06-17T19:20:06Z

Check documentPerform check on document:
173 إعجابًا

مرحباً، من الصعب عليّ العثور على أي شيء، ولكن ما هو البروتوكول الذي يستخدمه هذا؟ هل نفترض أنه oauth2؟ لا تبدو المعلمات متطابقة، وأحصل على خطأ من المزود يبدو أنه يقبل معلمة sso=؟ ساعدني!

شكراً

DiscourseConnect هو تطبيق Discourse لـ SSO. لا يستخدم بروتوكولًا قياسيًا.

إذا كنت لا تمانع في النظر إلى كود PHP، فهناك مثال للتنفيذ هنا: wp-discourse/lib/sso-provider/discourse-sso.php at main · discourse/wp-discourse · GitHub.

نعم، هذا لن ينجح. إذا كان لديك موفر OAuth2 ترغب في استخدامه للمصادقة على المستخدمين، فراجع المكون الإضافي Discourse OAuth2 Basic.

إعجاب واحد (1)

شكراً @simon. هل رمز PHP هو مزود أيضًا، وليس مستهلكًا؟ رأيت أيضًا مزود OIDC قد يعمل وكذلك مزود “الوسيط” في منطقة الإضافات.

إذا كان مزود SSO غير قياسي، فمن/ما هو المقصود به إذا لم يكن متوافقًا مع الآخرين؟

شكرًا مرة أخرى!

الكود الذي ربطته هو لاستخدام ووردبريس كمزود للمصادقة لـ Discourse.

تسمح إضافة ووردبريس أيضًا باستخدام ووردبريس كعميل لـ DiscourseConnect: wp-discourse/lib/sso-client at main · discourse/wp-discourse · GitHub.

لست متأكدًا من الدافع وراء إضافة تطبيق SSO مخصص إلى Discourse. أخمن أنه كان هناك سبب تجاري لذلك.

إحدى الفوائد التي يوفرها هي أنه يسمح بدمج موقع خارجي بشكل وثيق مع Discourse. على سبيل المثال، يمكن مزامنة جميع سمات المستخدم المدرجة هنا مع Discourse أثناء عملية المصادقة: discourse/lib/discourse_connect_base.rb at 7b89fdead98606d4f47ceb0a1d240d0f6e5f589e · discourse/discourse · GitHub.

كما يسمح باستخدام المواقع التي لم يتم تكوينها لتكون مزودات OAuth2 أو OpenID Connect لمصادقة المستخدمين على Discourse.

العيب هو أنه يتطلب إضافة بعض التعليمات البرمجية المخصصة إلى موقع مزود المصادقة.

إعجاب واحد (1)

مرحباً، أنا فضولي لمعرفة المشكلات المتعلقة بعدم التحقق من عناوين البريد الإلكتروني على موقع خارجي يوفر تسجيل الدخول الموحد (SSO). هل هو فقط أنه يتيح البريد العشوائي الآلي؟ أم أن هناك اعتبارات أخرى؟ لماذا لا يُنصح بأن يتعامل Discourse مع التحقق من البريد الإلكتروني إذا كان الموقع الخارجي لا يفعل ذلك؟

شكراً لأي رؤى إضافية.

أسوأ سيناريو أعرفه يتطلب هذه الشروط:

  • لم يتم التحقق من عناوين البريد الإلكتروني على الموقع الخارجي
  • لم يتم تعيين require_activation=true في حمولة SSO
  • توجد حسابات حالية على موقع Discourse لا ترتبط بها SingleSignOnRecord (لم يسجل مالك الحساب في Discourse باستخدام SSO مطلقًا)

في هذه الحالة، يمكن لشخص ما التسجيل في الموقع الخارجي باستخدام عنوان البريد الإلكتروني الخاص بمستخدم Discourse الذي لم يسجل الدخول مطلقًا عبر SSO. سيسمح هذا للحساب غير المتحقق منه من الموقع الخارجي بالاستيلاء على حساب Discourse الذي يستخدم نفس عنوان البريد الإلكتروني. سيكون هذا مقلقًا بشكل خاص إذا كان حساب مسؤول على Discourse.

يُنصح بأن يتولى Discourse التحقق من البريد الإلكتروني إذا لم يكن الموقع الخارجي يقوم بذلك:

هناك عدد قليل من الأسباب التي تجعل من الأفضل التعامل مع التحقق من البريد الإلكتروني على الموقع الخارجي:

  • إجبار المستخدمين على تلقي البريد الإلكتروني التأكيدي من Discourse يضيف بعض الاحتكاك عند محاولة المستخدمين تسجيل الدخول إلى Discourse لأول مرة. (في الواقع، يجب أن يحدث هذا الاحتكاك في مكان ما - إما على جانب Discourse أو على جانب الموقع الخارجي.)
  • لن يقوم Discourse بمطابقة حسابات Discourse الحالية مع تسجيلات الدخول الخارجية بناءً على عنوان البريد الإلكتروني إذا تم تعيين require_activation على true في حمولة SSO. هذه مشكلة إذا قمت بتمكين DiscourseConnect بعد إنشاء بعض الحسابات على Discourse عن طريق التسجيل باسم مستخدم / كلمة مرور. إنها أيضًا مشكلة إذا احتجت في أي وقت إلى حذف إدخالات SingleSignOnRecord على Discourse. لن يقوم Discourse بإنشاء إدخالات SingleSignOnRecord جديدة تلقائيًا عندما يحاول المستخدمون تسجيل الدخول مرة أخرى إلى Discourse.
4 إعجابات

شكراً لك، @simon - هذا مفيد جداً!

مرحباً، لدي سؤال حول حقل groups في حمولة SSO.

هل سيتم أيضاً تجاوز المجموعات الآلية (مثل المسؤولين والمشرفين ومستويات الثقة)؟ أم سيتم الاحتفاظ بها؟

لا! بافتراض أن وصف هذا الإعداد صحيح، فإنه سيؤثر فقط على المجموعات اليدوية.

أتعلم… لم أر كلمة “يدوي” في الوصف. يبدو واعدًا لحالة الاستخدام الخاصة بي، سأجربه وأبلغكم بالنتائج.

إعجاب واحد (1)

عندما قرأت هذا، اعتقدت أنه كان من المفترض أن أقوم بإنشاء التوقيع مباشرة من الحمولة المشفرة بـ Base64. لم أدرك أنك بحاجة إلى إنشائه من بايتات UTF-8. هل يمكن توضيح ذلك؟

لقد كنت ألعب بـ DiscourseConnect - التوثيق رائع، شكرًا لكم.
ومع ذلك، لقد واجهت بعض العقبات التي آمل الحصول على بعض المساعدة/التوضيح بشأنها.

نريد أن يتمكن المستخدمون من تسجيل الدخول إلى ووردبريس باستخدام تسجيل دخول ديسكورس الخاص بهم (وهذا يعمل بشكل جيد :slight_smile: ) - ومع ذلك.

  • هل من الممكن إنشاء مستخدم ووردبريس عبر تسجيل ديسكورس (عندما ينشئ المستخدم حساب ديسكورس، يتم تلقائيًا إنشاء حساب/ملف تعريف ووردبريس لهم حتى يتمكنوا من تسجيل الدخول إلى ووردبريس)

  • هل من الممكن مزامنة مجموعات مستخدمي ووردبريس ومجموعات ديسكورس.
    إذا كان لدى المستخدم حساب مستخدم في كل من ووردبريس وديسكورس، فإن DiscourseConnect قادر على ربطهما - ولكنه لا يمنح حساب ووردبريس مجموعات المستخدمين لمجموعات ديسكورس بنفس الاسم، والعكس صحيح (وماذا عن إذا لم يكن للمجموعات نفس الاسم - كيف يمكنني إخبار DiscourseConnect بمنح مجموعة المستخدمين “مجموعة اختبار” عندما يكون لدى المستخدم مجموعة ديسكورس “مجموعة لاختبار الأشياء”؟

ما الذي أفتقده؟

لا أعرف الإجابة، ولكن…

كن حذرًا بشأن ذلك. إنه في مكان غير قانوني ويعتبر ممارسة سيئة على نطاق واسع (باستثناء مالكي المواقع بالطبع :smirking_face:) لأنه سيحدث دون موافقة المستخدم ومعرفته، وفي نفس الوقت سيتم نقل البيانات إلى مكان آخر.

بالتأكيد، هذا في منطقة رمادية إلى حد ما، وبشكل أساسي، على سبيل المثال، جوجل تفعل ذلك.

ولكن… لماذا؟ قصر تسجيل الدخول على Discourse SSO فقط من جانب ووردبريس وإعادة توجيه المستخدمين إلى Discourse لإنشاء الحساب وهذا كل شيء. ولكن على حد علمي، لا يمكنك مزامنة حسابات المستخدمين تلقائيًا فور إخراجها من الصندوق. ولماذا يجب عليك ذلك، لأنه مع SSO يحدث ذلك عندما يحتاجه المستخدم.

في السيناريو الخاص بنا (كمنظمة عضوية)

  • يتم استخدام ووردبريس لإدارة الاشتراكات، وشراء العناصر من متجر ووردبريس، ونستخدم مجموعات المستخدمين لإدارة ما يمكن للعضو القيام به في المنظمة
  • ديسكورس هو منتدانا/مجتمعنا عبر الإنترنت ونستخدم المجموعات للتحكم في المناطق التي يمكن للمستخدم الوصول إليها في ديسكورس)

حاليًا، يحتاج العضو الجديد إلى إعداد حساب ووردبريس (وإعداد اشتراكه وما إلى ذلك) وأيضًا إعداد حساب ديسكورس، ويتم إدارة/مزامنة مجموعات المستخدمين-مجموعات ديسكورس يدويًا.

أحاول إيجاد حل يقوم فيه المستخدم الجديد بإعداد مرة واحدة لإنشاء كلا الحسابين، ويتم مزامنة مجموعات المستخدمين-مجموعات ديسكورس تلقائيًا - أنا متأكد من أنني أستطيع حل مزامنة المجموعات باستخدام واجهات برمجة التطبيقات وما إلى ذلك. إنها إعدادات حساب المستخدم المتعدد التي أحاول حلها/تجنبها.

يبدو أن ما تفعله هو استخدام ديسكورس كموفر للمصادقة الأحادية (SSO) لووردبريس. هذا النهج موضح هنا: استخدام ديسكورس كموفر هوية (SSO، DiscourseConnect). يحتوي المكون الإضافي لووردبريس الخاص بديسكورس على خيارات لاستخدام ووردبريس كموفر للمصادقة الأحادية لديسكورس، أو لاستخدام ديسكورس كموفر هوية لووردبريس. يؤدي استخدام نفس الاسم لكلا النهجين إلى بعض الارتباك.

أود أن أميل إلى استخدام ووردبريس كموفر هوية في هذه الحالة. مع هذا النهج، سيقوم المستخدمون بإنشاء حسابات على موقع ووردبريس الخاص بك ثم تسجيل الدخول إلى ديسكورس باستخدام بيانات اعتماد ووردبريس الخاصة بهم. أحد الأشياء التي يجب الانتباه إليها في هذا النهج هو أنه يعني أن المستخدمين سيتمكنون فقط من تسجيل الدخول إلى ديسكورس عبر ووردبريس، ولن يكون من الممكن إنشاء حساب ديسكورس دون امتلاك حساب ووردبريس بالفعل. أعتقد أن هذا هو الإعداد المناسب عند دمج ديسكورس مع موقع عضوية ووردبريس.

عند استخدام ووردبريس كموفر هوية لديسكورس، هناك عدد قليل من وظائف الأدوات المساعدة المفيدة لتعيين عضويات مجموعات ديسكورس للمستخدم بناءً على نشاطه في ووردبريس. تم توضيح هذه الوظائف هنا: إدارة عضوية المجموعة في ديسكورس باستخدام WP Discourse SSO.

بالعودة إلى سؤالك الأصلي:

لقد مر وقت طويل منذ أن نظرت في كود عميل DiscourseConnect الخاص بالمكون الإضافي لووردبريس، ولكن أعتقد أن ما تطلبه هو أكثر أو أقل بالطريقة التي يتوقع بها هذا الكود العمل. إذا كان لدى المستخدم حساب ديسكورس، فكل ما يحتاجون إليه هو النقر على رابط “تسجيل الدخول عبر ديسكورس” في ووردبريس وسيتم إنشاء حساب لهم.

سيكون هذا ممكنًا تقنيًا عند استخدام ووردبريس كعميل DiscourseConnect، ولكن ما لم يتغير شيء ما، فلن تتمكن من استخدام طرق add_user_to_discourse_group و remove_user_from_discourse_group الموضحة في الوثائق التي ربطتها. ستحتاج إلى القيام بشيء مثل إعداد خطاف ويب (Webhook) لديسكورس يتم تشغيله عند إضافة مستخدم إلى مجموعة ديسكورس، ثم إضافة بعض التعليمات البرمجية في ووردبريس لمعالجة خطاف الويب هذا. لمزامنة المجموعات من ووردبريس إلى ديسكورس، ستحتاج إلى إجراء استدعاء API إلى ديسكورس لتحديث مجموعات المستخدم عند حدوث تغيير في ووردبريس. لذلك، قد يكون الشيء الذي يسهل تحقيقه نسبيًا إذا كنت تستخدم ووردبريس كموفر لـ DiscourseConnect معقدًا إلى حد ما إذا كنت تستخدم ووردبريس كعميل لـ DiscourseConnect.

إعجاب واحد (1)

باستثناء إذا تم استخدام تسجيل دخول مخصص، كما هو الحال عادةً مع WooCommerce/memberships/LLM التي تعرض هذا الزر وتفرض استخدام Discourse SSO كموفر وحيد، فهذا لا يحدث بشكل افتراضي ويتطلب بعض العمل المخصص.

هناك عدد قليل من المشاكل المحتملة، واحدة تتعلق بالتخزين المؤقت وأخرى تتعلق بإعادة توجيه تسجيل الدخول التي تضيفها بعض الإضافات. يجب على أي شخص يواجه هذه المشاكل أن يسأل عنها في فئة Support > WordPress. عادة ما يتم حلها بسهولة.

لقد نسيت تمامًا أن أبلغك: بالفعل يعمل تمامًا كما هو موصوف، وتتأثر المجموعات اليدوية فقط.

مرحباً @simon،
أعتقد أنني بحاجة ماسة إلى بعض المساعدة بشأن استجابة 404 من استكشاف إثبات المفهوم (POC) لهذه الميزة SSO. لقد كنت أعمل على هذه المشكلة ليوم كامل، لكنني ما زلت غير قادر على تحديد المشكلة. تمكنت من:

  1. تمكين discourse_connect
  2. تعيين discourse_connect_url إلى https:/ /localhost:4200/login
  3. سر discourse-connect: 20’s (1) 1111111111111111111 لتبسيط الأمر.

ثم في صفحة تسجيل الدخول الخاصة بتطبيق Angular الخاص بي، أرسلت هذا الطلب باتباع الكود:


لكنني تلقيت استجابة 404 غير موجود.

لفهمي، أثناء إرسال طلب POST إلى نقطة نهاية admin/users/sync_sso، إذا لم يكن المستخدم موجودًا في discourse، فيجب عليه إنشاء مستخدم جديد بناءً على user_id والبريد الإلكتروني، ثم يجب أن تكون النتيجة المرتجعة كائن مستخدم وليس كائنًا فارغًا مع رمز الحالة 404.
لقد تحققت أيضًا من السجل ولم يقدم أي معلومات ذات صلة لهذه الاستجابة الفاشلة.

شكراً مقدماً!