Skip to content

Commit

Permalink
🐛 Fix for Electron OpenID Authentication (#523)
Browse files Browse the repository at this point in the history
* OpenID implementation

* Fix password login and session token initialization

* Disallow multiple authentication methods simultaneously.

Note this is only disallowed at bootstrap. If the database is edited
manually, we make no attempt to detect this.

* Refactored account-db.js into separate files in accounts/

* Migrate old database version

* Fix lint errors

* Add release note

* Add unit tests for runMigrations

* Integrate secrets database into migration system

* Remove unused imports

* trying local package

* merge

* working example

* working example

* working example

* forbidden instead of 401 when session expired

* cleanup

* small fix

* moving to another pc

* features

* more features

* added multiuser configuration

* lint fixes

* adjustments and linter

* making code more readible

* added token expiration and fixes

* fix on custom token_expiration

* lint

* build fixes

* fixes

* missing file

* linter

* linter

* test fixes

* linter

* first tests

* tests

* typo fix

* remove the init code from the old PR

* minor bug when enabling openid is deleting the password user

* fix bug when disabling openid

* another fix bug when disabling openid

* added option to login without discovery url

* adjustments for keycloak

* linter

* more tests

* adjustments

* linter fix

* added environment variable

* merge fixes for using middleware

* linter fix

* linter and tests

* tests adjustments

* added environment variables

* linter

* enhancements

* removed old files

* Added token expiration as environment variable

* fixes

* typescript fix

* linter

* unwanted code

* changed master to owner

* fixed down migrations and added transactions to it

* changed to the 'in' operator

* fixed typo

* code review

* code review

* json.parse may fail

* code review and removed duplicated methods

* multiple fixes and refactories

* bunch of fixes

* removed logs

* descriptive variable names

* linter

* code review

* linter

* improved variables

* fixes and refactories

* more code review

* variable name

* code review

* linter

* wrong logic after refactor

* refactor query

* fixes

* changes from code review

* added logs to toggleAuthentication

* removed not used route

* merged master into the branch

* removed toggleAuthenticatiomethod because you have to pass thru password config before enabling openid

* changed md file

* fixes on merge

* linter

* fix on tests

* more fixes

* fix

* another fix

* Update src/app-admin.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update jest.global-setup.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* code rabbit reviews

* linter

* Update migrations/1719409568000-multiuser.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update migrations/1719409568000-multiuser.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/account-db.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/accounts/openid.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix on code suggestion

* suggestion from coderabbit

* linter

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* linter and code review

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/util/middlewares.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fixes, ai code review, linter

* reverting res.locals and fixes

* Update src/accounts/openid.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/load-config.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/account-db.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fixes and refactories

* merge fix

* fix

* merge fix

* linter

* Update src/accounts/openid.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/services/user-service.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/services/user-service.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/services/user-service.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* more code review

* linter accepted code

* typo

* code review suggestion

* change to enable backward compatibility

* removed the userId = null

* fixes from code review

* Update jest.global-setup.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* code review

* minor change

* code rabbit commit was wrong

* Fix for existing user sessions

* fixes on migration

* md

* Update migrations/1719409568000-multiuser.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* added variable loginMethod for backward compatibility and renamed the other variable to make it more clear

* small fixes

* fix for electron

* md

---------

Co-authored-by: apilat <github@tmp.pegazy.org>
Co-authored-by: Jed Fox <git@jedfox.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 16, 2024
1 parent 70f6afb commit f80eb88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/accounts/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ export function isValidRedirectUrl(url) {
const redirectUrl = new URL(url);
const serverUrl = new URL(serverHostname);

if (redirectUrl.hostname === serverUrl.hostname) {
if (
redirectUrl.hostname === serverUrl.hostname ||
redirectUrl.hostname === 'localhost'
) {
return true;
} else {
return false;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/523.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [lelemm]
---

Fixed OpenID authentication bug for Electron

0 comments on commit f80eb88

Please sign in to comment.