Discourse OpenID Connect (OIDC)

:discourse2: Summary Discourse OpenID Connect allows an OpenID Connect provider to be used as an authentication provider for Discourse.
:open_book: Install Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.

Features

The plugin aims to provide a minimal implementation of the specification. Specifically, it supports the “Authorization Code Flow”. To get started, follow the plugin installation instructions, or contact your hosting provider.

Our oauth2-basic plugin can be used for connecting to some openid-connect providers (OpenID Connect is based on OAuth2). However, this plugin should require far less manual configuration, and can make use of the JWT “ID Token” if a JSON API is not available.

Configuration is automatically performed using an OpenID Connect Discovery Document. According to the specification, this should be located at <issuer domain>/.well-known/openid-configuration, but Discourse supports any path to allow for non-compliant implementations (e.g. Azure B2C). The discovery document is cached for 10 minutes, to improve performance on high-traffic sites.

If the discovery document includes a userinfo_endpoint parameter, then the plugin will use that to collect user metadata. If not, the plugin will extract metadata from the id_token (A JWT) supplied by the token endpoint. The plugin DOES NOT verify the authenticity of the JWT signature, as this would significantly increase complexity. This decision is supported by the specification:

If the ID Token is received via direct communication between the Client and the Token Endpoint (which it is in this flow), the TLS server validation MAY be used to validate the issuer in place of checking the token signature.

For identity providers which support secret-less authorization using the “Authorization Code Flow with Proof Key for Code Exchange”, PKCE should be enabled, and the client_secret configuration can be omitted.

Configuration

Basic Configuration Options

  • openid_connect_enabled: Enable OpenID Connect authentication

  • openid_connect_discovery_document: OpenID Connect discovery document URL. Normally located at https://your.domain/.well-known/openid-configuration

  • openid_connect_client_id: OpenID Connect client ID

  • openid_connect_client_secret: OpenID Connect client secret

  • openid connect rp initiated logout: Redirect the user to end_session_endpoint after logout. Must be supported by your identity provider and included in the discovery document.

  • openid connect rp initiated logout redirect: (optional) The post_logout_redirect_uri which will be passed to the logout endpoint. If provided, it must be registered with the identity provider.

  • openid_connect_authorize_scope: The scopes sent to the authorize endpoint. This must include ‘openid’

  • openid_connect_use_pkce: Enable Proof Key for Code Exchange (PKCE) for OpenID Connect authentication.

  • openid_connect_verbose_logging: Log detailed openid-connect authentication information to /logs. Keep this disabled during normal use.

Advanced Configuration Options

  • openid_connect_token_scope: The scopes sent when requesting the token endpoint. The official specification does not require this.

  • openid_connect_error_redirects: If the callback error_reason contains the first parameter, the user will be redirected to the URL in the second parameter. Used for unusual implementations that send errors in response to user input (e.g. Azure B2C)

  • openid_connect_allow_association_change: Allow users to disconnect and reconnect their Discourse accounts from the OpenID Connect provider

  • openid_connect_groups_claim: The name of the claim in the OIDC response[1] that contains the user’s groups as an array of strings. Leave blank to disable group syncing. See Group sync below.

  • openid_connect_user_field_mappings: mappings of OIDC claims[2] which will be stored in Discourse User Fields. User fields are identified by their numeric ID, which can be found in the URL when editing them via the admin panel.

Group sync

The plugin can automatically sync group memberships from your OpenID Connect provider to Discourse groups. On each login, the plugin will read the configured claim from the OIDC token and update the user’s group memberships accordingly. To enable group sync:

  1. Configure your identity provider to return an array of groups in one of the claims. This must be an array of strings.

  2. Set openid_connect_groups_claim to the name of the claim in the OIDC token that contains the user’s groups (e.g. cognito:groups). Once set, this will start to synchronise the information to Discourse’s “Associated Groups” system.

  3. Find the Discourse Group you’d like to link up. Go to “Settings” → “Membership” → “Automatic”, and then choose the Associated Groups to link up. This dropdown list is populated by information from the identity provider, so at least one group member must have logged in for an option to appear.

Example setup

Here we will set up the openid-connect plugin to connect to Google’s OpenID Connect provider. This replicates functionality that already exists in the core of Discourse, but it serves as an accessible example.

  1. Head to OpenID Connect  |  Sign in with Google  |  Google for Developers and follow the instructions to obtain OAuth Credentials.

  2. On the same page, follow the instructions to add a redirect URI. This should be https://<your_forum>/auth/oidc/callback (without a trailing slash)

  3. Go to your Discourse site settings and search for “openid_connect”

    • openid connect enabled: [x]

    • openid connect discovery document: https://accounts.google.com/.well-known/openid-configuration

    • openid connect client id: <client-id>

    • openid connect client secret: <client-secret>

    • openid connect authorize scope: openid email (with a space in between)

  4. You’re done. The “Login with OpenID Connect” button will now log in using Google :tada:. These same steps can be applied to other providers, with very minimal changes.

Debugging

In addition to the verbose_logging setting described above, you can access data about OIDC associations using the data-explorer plugin:

SELECT user_id, provider_name, provider_uid
FROM user_associated_accounts
WHERE provider_name = 'oidc'

Or on the rails console:

User.find_by_username("david").user_associated_accounts.where(provider_name: 'oidc')

Provider Specific Notes

Please feel free to update this if you find any provider-specific quirks relating to this integration:

Entra ID (formerly Azure AD)

Add the email scope, and make sure you’re using the version 2 endpoint configuration document. For example

https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration
Azure B2C

The discovery document URL details can be found here: Web sign in with OpenID Connect - Azure AD B2C | Microsoft Learn

To make emails work:

Yahoo
  1. Head to https://developer.yahoo.com/apps and create a new app

  2. Enter the Application Name, and set the callback domain to your forum domain (e.g. meta.discourse.org)

  3. Under API Permissions, choose Profiles: Read/Write Public and Private. This is the only way I know of to obtain the user email address

  4. Save the app

  5. In the Discourse OIDC settings, set the discovery document to

    https://login.yahoo.com/.well-known/openid-configuration
    
  6. Enter the client ID and secret from Yahoo

  7. Enable the OIDC plugin

AWS Cognito
  1. Go to Cognito and select or create a new user pool.
  2. Define an app in App clients.
  3. Leave everything to default, but change Auth Flows Configuration to only select ALLOW_REFRESH_TOKEN_AUTH.
  4. Go to app client settings and select the new app.
  5. Change the callback URL to https://yoursite.example.com/auth/oidc/callback.
  6. Only check the Authorization code grant flow among “Allowed OAuth Flows”.
  7. Check all scopes needed (I have all checked).
Okta
  1. Configure Discourse with your Okta app client ID and secret

  2. Set the discovery document URL to

    https://{your-app}.okta.com/.well-known/openid-configuration
    
  3. In Discourse, set the openid connect authorize scope to openid email

:discourse2: Hosted by us? This plugin is available on our Business and Enterprise plans. OAuth 2.0 & OpenID Connect Support | Discourse - Civilized Discussion

:spiral_notepad: Need to automate user sign-ups? See Auto-provisioning user accounts when SSO is enabled


  1. token or userinfo payload ↩︎

  2. from token or userinfo payload ↩︎

Last edited by @Moin 2026-05-25T19:17:47Z

Check documentPerform check on document:
53개의 좋아요
Native SSO with Azure AD
How to setup okta authentication with discourse
Discourse Login using external API
OpenIdAuthenticator plugin fails
Sign in to Discourse using ORCID
Auto-provisioning user accounts when SSO is enabled
Discourse, Keycloak, SAML vs OAuth
OpenID Connect support in selfhosted Discourse instance
OpenID connect plugin
Tutorial for OpenID Connect / Azure AD
Keycloak SSO and logout issue
How can you connect firebase to discourse?
Azure OpenID Connect Authentication Plugin
Installing own gem in plugin
CodeBerg support
Is "partial" SSO possible?
Auto-sign-in with the OpenId Connect Plugin and AWS Cognito
SSO Login page not showing up
Official support for Microsoft Azure AD?
Enabling Okta for employees only through OpenID Connect Authentication Plugin
Availability of OpenID Connect in hosted plans
Managing group membership via authentication
Memberstack + Webflow + Discourse OpenID Connect
OpenIdAuthenticator plugin fails
OpenID Connect Plugin Refactor (OIDC Implicit Flow)
SSO with TownNews CMS
Removing Yahoo login from Core, and deprecating OpenID 2.0
./launcher rebuild app fails hard 'bundle exec rake db:migrate' possible issue with github/master repo removal of auth/oath2_authenticator
How can add 2 or more discovery documents?
Error of Discourse OpenID Connect
How to set-up Discourse with Atricore Josso CE
ADFS Authentication
Using OpenID Connect with User Flows in Azure B2C
Can I include website analytics in trust data?
SAML Plugin on Self Hosted Discourse
Anyone have a working AWS Cognito configuration w/ ouath2, openid or sso?
OAuth connection of discourse
Failed to bootstrap due to out of memory killer
How to configure the OIDC to set the Username as the email account name or a username like value returned from my auth providers?
Availability of OpenID Connect in hosted plans
OpenID Connect Plugin not creating new users with AWS Cognito
Restrict Office 365 Login to certain Group
AAD integration with Discourse
Custom Login Flow: AWS Cognito SSO (via Passwordless Signin) - Is this possible?
Azure AD Authentication and Creation of User Account
Intergrate Discourse with keycloak
IndieAuth login
Intergrate Discourse with keycloak
Can we use the default atlassian id to login to discourse
OpenID with line.biz - email in JWT , missing in userinfo
Map oidc fields to custom user fields
CSRF problem in development with 'Discourse OpenID Connect' plug-in
Azure B2C SSO to Discourse?
User (patron) getting authorization error message
How can add 2 or more discovery documents?
Memberstack + Webflow + Discourse OpenID Connect
Possible to create a Sign in with Ghost plugin for Discourse?
Account already in discourse
Having trouble setting up AWS Cognito passwordless login
Discourse ID fails to activate on my instance
OIDC users not associating with existing Discourse users
Bundling more popular plugins with Discourse core
OpenID Connect Plugin Refactor (OIDC Implicit Flow)

안녕하세요,
AWS에 설치된 Discourse에서 OpenID Connect 인증 플러그인을 사용하고 있습니다.
Discourse, Discourse Sidekiq, Redis 컨테이너를 배포했으며(Bitnami 기반입니다. 이거 때문에 제발 내보내지 마세요 ;)), 데이터베이스는 AWS RDS에서 실행되고 있습니다. KeyCloak을 사용하고 있습니다.

서비스는 정상적으로 동작합니다.

하지만 Discourse AWS 태스크를 재시작한 후 가끔 캐시에 Discovery 문서가 있다고 판단하지만 실제로는 문서가 없는 경우가 발생합니다. 이 경우 KeyCloak에서 다시 가져오려고 시도하지도 않습니다:

OIDC Log: Discovery document loaded from cache
OIDC Log: Discovery document is
---
(oidc) Request phase initiated.
(oidc) Authentication failure! openid_connect_discovery_error: OmniAuth::OpenIDConnect::DiscoveryError, Discovery document is missing

브라우저 앱에서는 "Identity provider에서 구성을 가져올 수 없습니다. 다시 시도해 주세요."라는 메시지가 표시됩니다.

어떤 조언을 주실 수 있을까요?

2개의 좋아요

안녕하세요,

discourse 사용자 아바타 소스를 openID 서비스에서 지정된 필드로 설정하는 방법이 있을까요?

수정: 우리는 keycloak를 사용하고 있습니다.

1개의 좋아요

안녕하세요,

@Tomáš_Guba 님의 요구사항과 유사한 필요 사항이 있습니다. 사용자 프로필의 커스텀 항목에서 값을 가져와 [커스텀] 사용자 필드에 사용하고 싶습니다.

제 경우, userinfo_endpoint가 포함된 discovery 문서가 있습니다.

플러그인 로드맵에 이와 유사한 기능이 예정되어 있나요?

감사합니다.

1개의 좋아요

안녕하세요, 플러그인을 SSO openID와 함께 작동하게 하는 데 성공했지만, 다른 시스템의 사용자 이름 필드나 이메일 등 다른 필드에 값이 채워지지 않습니다.

“openid connect claims” 필드에서 무언가를 설정해야 할 것 같은데, 이 필드를 직접 어떻게 설정해야 하는지 모르겠습니다. 누군가 예시를 보여줄 수 있을까요? 제 프로젝트가 어떻게 구성되어 있는지 몇 가지 스크린샷을 첨부합니다:
https://imgur.com/gallery/LWvkJUV

1개의 좋아요

비공개 게시물에 로그인할 때 원래의 라우트를 “잃지” 않는 방법이 있을까요?

비공개 페이지를 방문하여 해당 페이지의 로그인 버튼 중 하나를 클릭하면, 다시 사이트로 리디렉션될 때 카테고리 페이지로 이동하게 됩니다.

@david 님, 안녕하세요.

아래 게시글에 언급된 문제를 확인해 주시겠습니까? 저는 OAuth basic 대신 OIDC 플러그인을 사용하려고 합니다. 하지만 같은 문제에 부딪혔습니다. /authorize 요청에 매개변수를 전달할 수 없어요. 플러그인에 foo=bar 형식으로 값을 입력했습니다.

LinkedIn에서 이 기능을 정상적으로 작동시키지 못했습니다. 다른 분들도 비슷한 경험을 하셨는지 궁금합니다. ‘다음으로 로그인’ 버튼을 클릭하면 LinkedIn으로 리다이렉트되어 로그인하고, 내 애플리케이션이 LinkedIn의 이메일을 사용하도록 '허가’까지 진행한 후, "계정 인증 중 오류가 발생했습니다. 다시 시도해 주세요."라는 메시지가 표시됩니다.

https:/discourse.mysite.com/auth/failure?message=invalid_credentials&origin=https%3A%2F%2Fdiscourse.mysite.com%2F&strategy=oidc

여전히 문제가 발생하고 있습니다. 다음과 같은 오류가 나고 있습니다:

(oidc) Authentication failure! invalid_credentials: OAuth2::Error, invalid_request: A required parameter "client_secret" is missing {"error":"invalid_request","error_description":"A required parameter

이것은 omniauth 오류로 보이며, 아마도 이 문제와 관련이 있을 수 있습니다: No longer works with oauth2 gem v2.0+ · Issue #68 · decioferreira/omniauth-linkedin-oauth2 · GitHub

도움을 부탁드립니다!

다음 오류가 발생합니다:


(oidc) Authentication failure! openid_connect_discovery_error: OmniAuth::OpenIDConnect::DiscoveryError, Discovery document is missing

OIDC Log: Fetching discovery document raised error Faraday::ConnectionFailed FinalDestination: lookup failed

관리자 설정에서 플러그인 설정인 "openid connect discovery document"를 https://<auth_provider>/.well-known/openid-configuration으로 설정했으며, 실행 중인 앱 Docker 컨테이너에서 Curl 명령을 사용하거나 Rails 콘솔에서 해당 주소를 성공적으로 호출할 수 있습니다.

이 오류가 발생하는 이유가 무엇일까요? 이로 인해 올바르게 통합할 수 없습니다. 또한, 저는 인트라넷 뒤에서 회사 프록시를 사용 중입니다. 참고로, 컨테이너의 ENV에 프록시를 활성화하면 “openid connect discovery document” URL을 올바르게 호출할 수 있습니다.

1개의 좋아요

게시물 2개가 새 주제로 분리되었습니다: 여러 OIDC 소스 허용

게시글이 새 주제로 분리되었습니다: OIDC로 아바타 오버라이드

안녕하세요!

새로운 질문입니다: 이 플러그인은 세션 관리(session management)를 처리하나요? (Final: OpenID Connect Session Management 1.0).
OP가 session_state 데이터를 보내더라도, 코드의 어디에서도 쿠키 등으로 저장되는 부분이 보이지 않아서 그렇지 않다고 생각합니다.

그래서 질문이자 기능 요청입니다 :slight_smile: 가능하면 정말 좋겠습니다!

2개의 좋아요

이 플러그인을 AWS Cognito와 함께 사용할 때, 로그아웃을 위해 로그아웃 URL에 client_id 파라미터를 전달해야 합니다. 제 생각에는 로그아웃 URL에 추가적인 쿼리 파라미터를 추가할 방법이 없는 것 같은데, 맞나요? 그렇지 않다면, 이 기능을 추가할 수 있을까요?

여러분 안녕하세요 :wave:t3:

이 플러그인에 대한 작은 확장 기능(기술적으로는 테마/컴포넌트 형태)을 작성했습니다. 로그인 팝업에서 “Login via OIDC” 버튼을 숨기고, 특수한 URL에 접근하여 OIDC 로그인을 시작하는 기능입니다.

discourse-autooidc.zip (1,0 KB)

이 기능의 사용 사례는 회사의 구성원들에게 공개된 OAuth 제공자 링크(우리 경우 Authentik이지만, Authelia, Keycloak, Auth0, Okta 등에서도 작동해야 합니다)을 노출하지 않으면서도 안전하고 편리한(자동) OAuth 로그인을 제공하는 것입니다. 또한 다른 모든 사용자들이 절대 사용하거나 사용해서는 안 되는 OIDC 로그인 버튼으로 귀찮아하지 않도록 하는 것도 목적입니다.

OIDC로 로그인하려면 https://<your-discourse-base-url>/login#autooidc를 호출하기만 하면 됩니다.

3개의 좋아요

GitHub - discourse/discourse-hide-auth-method: A theme component which allows hiding a specific login method from the UI, without fully disabling it · GitHub 에도 유사한 기능을 제공하는 것이 있으니 참고해 보세요.

3개의 좋아요

Keycloak은 Back-channel logout URL을 지원합니다:

이レル름으로 로그아웃 요청이 전송될 때(end_session_endpoint를 통해) 클라이언트가 자동으로 로그아웃되도록 하는 URL입니다. 생략된 경우, 이 경우 클라이언트에 로그아웃 요청이 전송되지 않습니다.

이 플러그인이 Keycloak에서 페이로드를 받아 즉시 모든 세션에서 사용자를 로그아웃할 수 있는 엔드포인트를 노출해 주면 좋겠습니다. 그렇지 않으면 Keycloak에서 사용자를 비활성화할 때, 기본적으로 상당히 긴 maximum session age를 기다려야 합니다.

사용자 관리 페이지(예: /admin/-1/system)에서 모든 세션에서 로그아웃을 시킨 후, 페이지 상단의 로그아웃 버튼을 클릭할 수도 있습니다.

안녕하세요,

디스커버리 문서 가져오기에 실패할 때(예: 타임아웃 발생 시), 플러그인은 에러를 캐시하여 10분 동안 인증이 불가능해집니다. 에러를 캐시하지 않도록 하여 가져오기를 더 빨리 재시도할 수 있는 방법이 있을까요?

감사합니다

핑을 보내서 죄송합니다. PKCE 지원을 추가하기 위해 병합이 비교적 간단한 열린 PR이 있습니다.

@nbianca 이 저장소의 마지막 커미터로 보이는데, 한번 확인해 주실 수 있을까요? :folded_hands:

1개의 좋아요