[PR #1636] [MERGED] Integrate passportjs for muti-strategy authentication and SSO #3589

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

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/1636
Author: @lukeIam
Created: 3/24/2023
Status: Merged
Merged: 11/19/2023
Merged by: @advplyr

Base: masterHead: auth_passportjs


📝 Commits (10+)

  • e1ddb95 Inital passportjs integration
  • be53b31 Merge remote-tracking branch 'origin/master' into auth_passportjs
  • 08676a6 Fix: small problem with this context in Auth.js
  • 62b0940 Added passport-openidconnect implementation
  • 812395b Merge remote-tracking branch 'origin/master' into auth_passportjs
  • 7010a13 Fixes for passport local and allow empty password
  • 8d00647 Merge branch 'master' into auth_passportjs
  • 8b68543 Merge
  • 4359ca2 Fix XAccel issue
  • 95e6fef Merge remote-tracking branch 'origin/master' into auth_passportjs

📊 Changes

23 files changed (+1906 additions, -260 deletions)

View changed files

📝 client/assets/app.css (+20 -0)
📝 client/components/app/ConfigSideNav.vue (+5 -0)
📝 client/components/ui/Btn.vue (+2 -22)
📝 client/pages/config.vue (+1 -0)
client/pages/config/authentication.vue (+229 -0)
📝 client/pages/login.vue (+67 -12)
📝 client/store/index.js (+1 -1)
📝 client/strings/en-us.json (+1 -0)
📝 package-lock.json (+472 -21)
📝 package.json (+5 -0)
📝 server/Auth.js (+501 -159)
📝 server/Server.js (+63 -6)
📝 server/SocketAuthority.js (+22 -3)
📝 server/controllers/MiscController.js (+106 -5)
📝 server/controllers/SessionController.js (+10 -10)
📝 server/controllers/UserController.js (+2 -2)
server/libs/passportLocal/LICENSE (+20 -0)
server/libs/passportLocal/index.js (+20 -0)
server/libs/passportLocal/strategy.js (+119 -0)
📝 server/models/User.js (+108 -11)

...and 3 more files

📄 Description

As I wrote in the SSO issue (https://github.com/advplyr/audiobookshelf/issues/998#issuecomment-1454735891) I would suggest to integrate a well supported auth middleware instead of implementing single protocols by hand.

This PR shows a possible integration of passortjs into the server code of audiobookshelf.
Login with username + password and google oauth2 integrated and working so far. But other auth providers can be integrated really easily with a few lines of code (supported strategies).

My current implementation is not final nor ready to be merged - it is more meant as a PoC.
But if you (@advplyr and also others) decide that you want to go in this direction I'm happy to develop/contribute to a stable implementation.

I don't have a client implementation atm - I'm testing with postman...
Login via:
POST /login for username + password
GET /auth/google redirects to google login

The response returns the known json with a token but also a cookie is set containing the session.
For the further API communication either the token (Bearer header) or the cookie can be used if authentication.
Maybe the cookie simplifies the handling in the webclients of the apps.

Most of the changes where done in the Auth.js file - I tried to not touch the other code where possible.

So what do you think? Is passportjs a good idea or do you prefer to go in another direction?


🔄 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/1636 **Author:** [@lukeIam](https://github.com/lukeIam) **Created:** 3/24/2023 **Status:** ✅ Merged **Merged:** 11/19/2023 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `auth_passportjs` --- ### 📝 Commits (10+) - [`e1ddb95`](https://github.com/advplyr/audiobookshelf/commit/e1ddb95250357a4f1eb63386a71ce24ba00562e1) Inital passportjs integration - [`be53b31`](https://github.com/advplyr/audiobookshelf/commit/be53b317125e190d3c930108125fa3606a38e535) Merge remote-tracking branch 'origin/master' into auth_passportjs - [`08676a6`](https://github.com/advplyr/audiobookshelf/commit/08676a675ae2e5cc945a008b60f00bee52f249fc) Fix: small problem with this context in Auth.js - [`62b0940`](https://github.com/advplyr/audiobookshelf/commit/62b0940766c11df1e705756dc454a06b9b5117a4) Added passport-openidconnect implementation - [`812395b`](https://github.com/advplyr/audiobookshelf/commit/812395b21b090699e509c68cfd3d932b1fab9d00) Merge remote-tracking branch 'origin/master' into auth_passportjs - [`7010a13`](https://github.com/advplyr/audiobookshelf/commit/7010a13648860288b2be43a230f498499e13f0f4) Fixes for passport local and allow empty password - [`8d00647`](https://github.com/advplyr/audiobookshelf/commit/8d0064763c56e5945f9f519c2b516298824f3316) Merge branch 'master' into auth_passportjs - [`8b68543`](https://github.com/advplyr/audiobookshelf/commit/8b685436dee40c0d9cfdf55961c70ef364255329) Merge - [`4359ca2`](https://github.com/advplyr/audiobookshelf/commit/4359ca28dfb034d27c1847382554102b1305632b) Fix XAccel issue - [`95e6fef`](https://github.com/advplyr/audiobookshelf/commit/95e6fef3d1a2aa41b2547e3445832bd9450f2c48) Merge remote-tracking branch 'origin/master' into auth_passportjs ### 📊 Changes **23 files changed** (+1906 additions, -260 deletions) <details> <summary>View changed files</summary> 📝 `client/assets/app.css` (+20 -0) 📝 `client/components/app/ConfigSideNav.vue` (+5 -0) 📝 `client/components/ui/Btn.vue` (+2 -22) 📝 `client/pages/config.vue` (+1 -0) ➕ `client/pages/config/authentication.vue` (+229 -0) 📝 `client/pages/login.vue` (+67 -12) 📝 `client/store/index.js` (+1 -1) 📝 `client/strings/en-us.json` (+1 -0) 📝 `package-lock.json` (+472 -21) 📝 `package.json` (+5 -0) 📝 `server/Auth.js` (+501 -159) 📝 `server/Server.js` (+63 -6) 📝 `server/SocketAuthority.js` (+22 -3) 📝 `server/controllers/MiscController.js` (+106 -5) 📝 `server/controllers/SessionController.js` (+10 -10) 📝 `server/controllers/UserController.js` (+2 -2) ➕ `server/libs/passportLocal/LICENSE` (+20 -0) ➕ `server/libs/passportLocal/index.js` (+20 -0) ➕ `server/libs/passportLocal/strategy.js` (+119 -0) 📝 `server/models/User.js` (+108 -11) _...and 3 more files_ </details> ### 📄 Description As I wrote in the SSO issue (https://github.com/advplyr/audiobookshelf/issues/998#issuecomment-1454735891) I would suggest to integrate a well supported auth middleware instead of implementing single protocols by hand. This PR shows a possible integration of [passortjs](https://passportjs.org) into the server code of audiobookshelf. Login with username + password and google oauth2 integrated and working so far. But other auth providers can be integrated really easily with a few lines of code ([supported strategies](https://www.passportjs.org/packages/)). My current implementation is not final nor ready to be merged - it is more meant as a PoC. But if you (@advplyr and also others) decide that you want to go in this direction I'm happy to develop/contribute to a stable implementation. I don't have a client implementation atm - I'm testing with postman... Login via: `POST /login` for username + password `GET /auth/google` redirects to google login The response returns the known json with a token but also a cookie is set containing the session. For the further API communication either the token (Bearer header) or the cookie can be used if authentication. Maybe the cookie simplifies the handling in the webclients of the apps. Most of the changes where done in the `Auth.js` file - I tried to not touch the other code where possible. So what do you think? Is `passportjs` a good idea or do you prefer to go in another direction? --- <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:16:16 +02:00
adam closed this issue 2026-04-25 00:16:16 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3589