[PR #3665] [MERGED] Subdirectory support for OIDC and SocketIO #4047

Closed
opened 2026-04-25 00:18:06 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3665
Author: @mikiher
Created: 11/29/2024
Status: Merged
Merged: 12/4/2024
Merged by: @advplyr

Base: masterHead: subdirectory-fixes-3


📝 Commits (5)

  • 843dd0b Keep original socket.io server for non-subdir clients
  • 6d8720b Subfolder support for OIDC auth
  • 8c3ba67 Fix label order
  • 9917f2d Change migration to v2.17.4
  • 33aa4f1 Merge master

📊 Changes

10 files changed (+345 additions, -88 deletions)

View changed files

📝 client/pages/config/authentication.vue (+37 -1)
📝 client/strings/en-us.json (+2 -0)
📝 server/Auth.js (+4 -4)
📝 server/Server.js (+5 -13)
📝 server/SocketAuthority.js (+82 -60)
📝 server/controllers/MiscController.js (+2 -2)
📝 server/migrations/changelog.md (+8 -7)
server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.js (+84 -0)
📝 server/objects/settings/ServerSettings.js (+5 -1)
test/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.test.js (+116 -0)

📄 Description

Brief summary

This is another PR in preparation for switching to subdirectory support in accordance with #3535

This covers two issues:

  1. SocketIO support for both new and existing clients
  2. Support for new and existing OIDC authentication setups

Which issue is fixed?

There are no existing bugs for this PR.

There should be no visible effect on existing (no-subdirectory) setups.

In-depth Description

SocketIO support

After the planned switch to subdirectory support, we will have both existing (no subdirectory) clients and new clients (either using a subdirectory or not). Since our SocketIO lives outside of the normal express middleware handlers, we need to support both subdirectory and no-subdirectory paths to access it.

This is achieved by bringing up two identical SocketIO servers that only differ in their paths. One uses the standard /socket.io path, and the other uses ${subdirectory}/socket.io (e.g. /audiobookshelf/socket.io). This way, legacy clients can still connect to the no-directory SocketIO server.

OIDC Auhentication support

OIDC authentication setups need to register a couple of authorized callback URLs in the OAuth provider. After the provider performs the authentication, it checks the callback URL it got from the server against the authorized callback URLs, and only calls back the server if it found a match.

So, in order for ABS servers to work after switching to subdirectory support, they need to remember which URLs were registered with the provider:

  • For existing OIDC setups, we use no-subdirectory URLs.
  • For new OIDC setups, we let the user choose between no-subdirectory and subdirectory URLs

This way, exising OIDC setups will continue to work without any manual setup required after the planned switch to subdirectory support.

To achieve this, we introduce a new server setting, authOpenIDSubfolderForRedirectURLs.
For existing OIDC setups it would be set to None (empty string). For new setups after the planned switch, it could be set to either None, or ${subdirectory} (e.g. /audiobookshelf). Authentication.vue was modified to enable setting it.

How have you tested this?

This was extensively tested using existing (no-subdirectory) and new (subdirectory) clients.

The server migration to add the new OIDC subfolder server setting was unit-tested as well as run on a test database with and without an existing OIDC setup.


🔄 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/advplyr/audiobookshelf/pull/3665 **Author:** [@mikiher](https://github.com/mikiher) **Created:** 11/29/2024 **Status:** ✅ Merged **Merged:** 12/4/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `subdirectory-fixes-3` --- ### 📝 Commits (5) - [`843dd0b`](https://github.com/advplyr/audiobookshelf/commit/843dd0b1b28ec1e5f36b71eee58af7306e84a4ef) Keep original socket.io server for non-subdir clients - [`6d8720b`](https://github.com/advplyr/audiobookshelf/commit/6d8720b404722ba328dfe5de95d43061dc1dffdb) Subfolder support for OIDC auth - [`8c3ba67`](https://github.com/advplyr/audiobookshelf/commit/8c3ba675836c4e5bc916dfe7d60249b02a842468) Fix label order - [`9917f2d`](https://github.com/advplyr/audiobookshelf/commit/9917f2d358c803665cc1bb5750f3f64a1b89577b) Change migration to v2.17.4 - [`33aa4f1`](https://github.com/advplyr/audiobookshelf/commit/33aa4f1952056783c1b2aeed70cda4e293d0c9ef) Merge master ### 📊 Changes **10 files changed** (+345 additions, -88 deletions) <details> <summary>View changed files</summary> 📝 `client/pages/config/authentication.vue` (+37 -1) 📝 `client/strings/en-us.json` (+2 -0) 📝 `server/Auth.js` (+4 -4) 📝 `server/Server.js` (+5 -13) 📝 `server/SocketAuthority.js` (+82 -60) 📝 `server/controllers/MiscController.js` (+2 -2) 📝 `server/migrations/changelog.md` (+8 -7) ➕ `server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.js` (+84 -0) 📝 `server/objects/settings/ServerSettings.js` (+5 -1) ➕ `test/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.test.js` (+116 -0) </details> ### 📄 Description ## Brief summary This is another PR in preparation for switching to subdirectory support in accordance with #3535 This covers two issues: 1. SocketIO support for both new and existing clients 2. Support for new and existing OIDC authentication setups ## Which issue is fixed? There are no existing bugs for this PR. There should be no visible effect on existing (no-subdirectory) setups. ## In-depth Description ### SocketIO support After the planned switch to subdirectory support, we will have both existing (no subdirectory) clients and new clients (either using a subdirectory or not). Since our SocketIO lives outside of the normal express middleware handlers, we need to support both subdirectory and no-subdirectory paths to access it. This is achieved by bringing up two identical SocketIO servers that only differ in their paths. One uses the standard `/socket.io` path, and the other uses `${subdirectory}/socket.io` (e.g. `/audiobookshelf/socket.io`). This way, legacy clients can still connect to the no-directory SocketIO server. ### OIDC Auhentication support OIDC authentication setups need to register a couple of authorized callback URLs in the OAuth provider. After the provider performs the authentication, it checks the callback URL it got from the server against the authorized callback URLs, and only calls back the server if it found a match. So, in order for ABS servers to work after switching to subdirectory support, they need to remember which URLs were registered with the provider: - For existing OIDC setups, we use no-subdirectory URLs. - For new OIDC setups, we let the user choose between no-subdirectory and subdirectory URLs This way, exising OIDC setups will continue to work without any manual setup required after the planned switch to subdirectory support. To achieve this, we introduce a new server setting, `authOpenIDSubfolderForRedirectURLs`. For existing OIDC setups it would be set to None (empty string). For new setups after the planned switch, it could be set to either None, or `${subdirectory}` (e.g. `/audiobookshelf`). `Authentication.vue` was modified to enable setting it. ## How have you tested this? This was extensively tested using existing (no-subdirectory) and new (subdirectory) clients. The server migration to add the new OIDC subfolder server setting was unit-tested as well as run on a test database with and without an existing OIDC setup. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:18:06 +02:00
adam closed this issue 2026-04-25 00:18:06 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4047