[PR #5847] [CLOSED] Extended logic to support more than one OIDC provider for authentication #6584

Closed
opened 2026-02-05 10:36:07 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/5847
Author: @MarchoStoev
Created: 10/21/2025
Status: Closed

Base: developmentHead: multiple-oidc-providers


📝 Commits (1)

  • 7c35208 Extended logic to support more than one OIDC provider for authentication

📊 Changes

7 files changed (+115 additions, -120 deletions)

View changed files

📝 app/Access/Controllers/LoginController.php (+2 -0)
📝 app/Access/Controllers/OidcController.php (+11 -10)
📝 app/Access/Oidc/OidcService.php (+45 -39)
📝 app/Config/oidc.php (+36 -56)
📝 resources/views/auth/parts/login-form-oidc.blade.php (+17 -11)
📝 resources/views/layouts/parts/header-user-menu.blade.php (+1 -1)
📝 routes/web.php (+3 -3)

📄 Description

Hi,
I tried extending the logic in the application so it can support multiple OpenID Connect OAuth providers.
Configuration changes:

  1. Environmental variables changes
  • New variable OIDC_PROVIDERS=provider1,provider2,provider3. Those will be the names used to map OAuth variables to specific provider.
  • Other environmental variables should follow the standard naming convention with the name of the provider after the OIDC_ prefix. (Example: OIDC_PROVIDER1_CLIENT_ID=.....)
    That's for the configuration part. The mapping will be done in the oidc configuration by:
    1.1. Getting all providers from OIDC_PROVIDERS variable
    1.2. Splitting them on every ","
    1.3. Gathering the provided variables for all providers in the .env
  1. Routes changes
  • Only changes are to the oidc routes by adding /{provider} to the endpoints so the backend knows which provider's configuration to use. {provider} is the provider, specified in OIDC_PROVIDERS variable.
  1. Controller and services changes
  • All places which read the config are changed to get the configuration for the specified provider from the endpoint.
  1. Session changes
  • In the user session after a successful login I've saved a variable, named oidc_provider which stores the provider used to login, so I can know which provider to put in the logout button in the frontend.
  • All places that save in the session something about the OIDC, I've added the provider as an affix.
  1. View changes
  • Dynamically adds all buttons in the login-form-oidc.blade.php
  • Reads from session the provider to put in the logout button in header-user-menu.blade.php

Those are all the changes I've implemented. I tried my best to keep it as clean as I can. I hope it's useful to you. I'm open of course to feedback and all change suggestions will be much appreciated. Feel free to use my code however you like for the application. I feel like it will be an useful addition to the app.

Kind regards,
Mario Stoev


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/5847 **Author:** [@MarchoStoev](https://github.com/MarchoStoev) **Created:** 10/21/2025 **Status:** ❌ Closed **Base:** `development` ← **Head:** `multiple-oidc-providers` --- ### 📝 Commits (1) - [`7c35208`](https://github.com/BookStackApp/BookStack/commit/7c352089ee3618db37ac841731ca8e1e8f913b1f) Extended logic to support more than one OIDC provider for authentication ### 📊 Changes **7 files changed** (+115 additions, -120 deletions) <details> <summary>View changed files</summary> 📝 `app/Access/Controllers/LoginController.php` (+2 -0) 📝 `app/Access/Controllers/OidcController.php` (+11 -10) 📝 `app/Access/Oidc/OidcService.php` (+45 -39) 📝 `app/Config/oidc.php` (+36 -56) 📝 `resources/views/auth/parts/login-form-oidc.blade.php` (+17 -11) 📝 `resources/views/layouts/parts/header-user-menu.blade.php` (+1 -1) 📝 `routes/web.php` (+3 -3) </details> ### 📄 Description Hi, I tried extending the logic in the application so it can support multiple OpenID Connect OAuth providers. Configuration changes: 1. Environmental variables changes - New variable OIDC_PROVIDERS=provider1,provider2,provider3. Those will be the names used to map OAuth variables to specific provider. - Other environmental variables should follow the standard naming convention with the name of the provider after the OIDC_ prefix. (Example: OIDC_PROVIDER1_CLIENT_ID=.....) That's for the configuration part. The mapping will be done in the oidc configuration by: 1.1. Getting all providers from OIDC_PROVIDERS variable 1.2. Splitting them on every "," 1.3. Gathering the provided variables for all providers in the .env 2. Routes changes - Only changes are to the oidc routes by adding /{provider} to the endpoints so the backend knows which provider's configuration to use. {provider} is the provider, specified in OIDC_PROVIDERS variable. 3. Controller and services changes - All places which read the config are changed to get the configuration for the specified provider from the endpoint. 4. Session changes - In the user session after a successful login I've saved a variable, named oidc_provider which stores the provider used to login, so I can know which provider to put in the logout button in the frontend. - All places that save in the session something about the OIDC, I've added the provider as an affix. 5. View changes - Dynamically adds all buttons in the login-form-oidc.blade.php - Reads from session the provider to put in the logout button in header-user-menu.blade.php Those are all the changes I've implemented. I tried my best to keep it as clean as I can. I hope it's useful to you. I'm open of course to feedback and all change suggestions will be much appreciated. Feel free to use my code however you like for the application. I feel like it will be an useful addition to the app. Kind regards, Mario Stoev --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:36:07 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6584