ether / etherpad-lite

Etherpad: A modern really-real-time collaborative document editor.
http://docs.etherpad.org/
Apache License 2.0
15.95k stars 2.78k forks source link

"ep_openid_connect" plugin work with v2.0.x? #6330

Open vladimirdulov opened 1 month ago

vladimirdulov commented 1 month ago

Could you advise if the suggested plugin "ep_openid_connect" is still working with v2.0.x? I get the following error in the etherpad-lite log, openid connect plugin doesn't seem to work.

[2024-04-15T15:47:24.461] [ERROR] settings - Failed to load hook function "/run/etherpad-lite/src/plugin_packages/ep_openid_connect:authenticate" for plugin "ep_openid_connect" part "main" hook set "hooks" hook "authenticate": TypeError: LRU is not a constructor
    at Object.<anonymous> (/app/code/src/plugin_packages/openid-client/lib/helpers/request.js:62:16)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Object.S (/run/etherpad-lite/node_modules/.pnpm/tsx@4.7.2/node_modules/tsx/dist/cjs/index.cjs:1:1292)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/app/code/src/plugin_packages/openid-client/lib/client.js:25:17)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Object.S (/run/etherpad-lite/node_modules/.pnpm/tsx@4.7.2/node_modules/tsx/dist/cjs/index.cjs:1:1292)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/app/code/src/plugin_packages/openid-client/lib/issuer.js:5:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)

Ethepad-lite version: 2.0.2 (it seems all 2.0.x affected)

SamTV12345 commented 1 month ago

It is fixed in ep_openid_connect v3.0.7

yacchin1205 commented 1 month ago

@SamTV12345 Thanks for the fix!

I faced the same error too, I have upgraded ep_openid_connect to 3.0.7, but I still seemed to be getting the same error.

therpad-1  | [2024-04-17T01:49:33.464] [ERROR] settings - Failed to load hook function "/opt/etherpad-lite/src/plugin_packages/ep_openid_connect:authenticate" for plugin "ep_openid_connect" part "main" hook set "hooks" hook "authenticate": TypeError: LRU is not a constructor
etherpad-1  |     at Object.<anonymous> (/opt/etherpad-lite/src/plugin_packages/openid-client/lib/helpers/request.js:62:16)
etherpad-1  |     at Module._compile (node:internal/modules/cjs/loader:1368:14)
etherpad-1  |     at Object.S (/opt/etherpad-lite/node_modules/.pnpm/tsx@4.7.2/node_modules/tsx/dist/cjs/index.cjs:1:1292)
etherpad-1  |     at Module.load (node:internal/modules/cjs/loader:1205:32)
etherpad-1  |     at Module._load (node:internal/modules/cjs/loader:1021:12)
etherpad-1  |     at Module.require (node:internal/modules/cjs/loader:1230:19)
etherpad-1  |     at require (node:internal/modules/helpers:179:18)
etherpad-1  |     at Object.<anonymous> (/opt/etherpad-lite/src/plugin_packages/openid-client/lib/client.js:25:17)
etherpad-1  |     at Module._compile (node:internal/modules/cjs/loader:1368:14)
etherpad-1  |     at Object.S (/opt/etherpad-lite/node_modules/.pnpm/tsx@4.7.2/node_modules/tsx/dist/cjs/index.cjs:1:1292)
etherpad-1  |     at Module.load (node:internal/modules/cjs/loader:1205:32)
etherpad-1  |     at Module._load (node:internal/modules/cjs/loader:1021:12)
etherpad-1  |     at Module.require (node:internal/modules/cjs/loader:1230:19)
etherpad-1  |     at require (node:internal/modules/helpers:179:18)
etherpad-1  |     at Object.<anonymous> (/opt/etherpad-lite/src/plugin_packages/openid-client/lib/issuer.js:5:19)
etherpad-1  |     at Module._compile (node:internal/modules/cjs/loader:1368:14)

I am running etherpad with docker. And I checked the installed packages and the following appears to be happening:

I found out that etherpad-lite requires lru-cache@^10.2.0 ( code ). Therefore, the version of lru-cache referenced by openid-client seems to be unexpectedly newer and is failing.

Could Etherpad's plugin mechanism of 2.0.x not work properly if there are version conflicts in the packages it depends on?

SamTV12345 commented 1 month ago

@SamTV12345 Thanks for the fix!

I faced the same error too, I have upgraded ep_openid_connect to 3.0.7, but I still seemed to be getting the same error.

therpad-1  | [2024-04-17T01:49:33.464] [ERROR] settings - Failed to load hook function "/opt/etherpad-lite/src/plugin_packages/ep_openid_connect:authenticate" for plugin "ep_openid_connect" part "main" hook set "hooks" hook "authenticate": TypeError: LRU is not a constructor
etherpad-1  |     at Object.<anonymous> (/opt/etherpad-lite/src/plugin_packages/openid-client/lib/helpers/request.js:62:16)
etherpad-1  |     at Module._compile (node:internal/modules/cjs/loader:1368:14)
etherpad-1  |     at Object.S (/opt/etherpad-lite/node_modules/.pnpm/tsx@4.7.2/node_modules/tsx/dist/cjs/index.cjs:1:1292)
etherpad-1  |     at Module.load (node:internal/modules/cjs/loader:1205:32)
etherpad-1  |     at Module._load (node:internal/modules/cjs/loader:1021:12)
etherpad-1  |     at Module.require (node:internal/modules/cjs/loader:1230:19)
etherpad-1  |     at require (node:internal/modules/helpers:179:18)
etherpad-1  |     at Object.<anonymous> (/opt/etherpad-lite/src/plugin_packages/openid-client/lib/client.js:25:17)
etherpad-1  |     at Module._compile (node:internal/modules/cjs/loader:1368:14)
etherpad-1  |     at Object.S (/opt/etherpad-lite/node_modules/.pnpm/tsx@4.7.2/node_modules/tsx/dist/cjs/index.cjs:1:1292)
etherpad-1  |     at Module.load (node:internal/modules/cjs/loader:1205:32)
etherpad-1  |     at Module._load (node:internal/modules/cjs/loader:1021:12)
etherpad-1  |     at Module.require (node:internal/modules/cjs/loader:1230:19)
etherpad-1  |     at require (node:internal/modules/helpers:179:18)
etherpad-1  |     at Object.<anonymous> (/opt/etherpad-lite/src/plugin_packages/openid-client/lib/issuer.js:5:19)
etherpad-1  |     at Module._compile (node:internal/modules/cjs/loader:1368:14)

I am running etherpad with docker. And I checked the installed packages and the following appears to be happening:

  • The version of ep_openid_connect (/opt/etherpad-lite/src/plugin_packages/ep_openid_connect/package.json) is 3.0.7 correctly.
  • The version of lru-cache in plugin_packages (/opt/etherpad-lite/src/plugin_packages/lru-cache/package.json) is 6.0.0 (ep_openid_connect depends on openid-client, which depends on lru-cache@^6.0.0.)
  • However, the version of lru-cache in node_modules (/opt/etherpad-lite/src/node_modules/lru-cache/package.json) is 10.2.0.

I found out that etherpad-lite requires lru-cache@^10.2.0 ( code ). Therefore, the version of lru-cache referenced by openid-client seems to be unexpectedly newer and is failing.

Could Etherpad's plugin mechanism of 2.0.x not work properly if there are version conflicts in the packages it depends on?

Oh that is a bummer. It's the client. I opened a pr over there that bumps the LRU cache to version 10. Then I can do a final update of the openid-client and it should work again https://github.com/panva/node-openid-client/pull/674

yacchin1205 commented 1 month ago

Oh that is a bummer. It's the client. I opened a pr over there that bumps the LRU cache to version 10. Then I can do a final update of the openid-client and it should work again panva/node-openid-client#674

Thank you for making the Pull Request on node-openid-client. (Unfortunately, the pull request was closed without being merged...)

Such version conflicts seem to occur in several other npm packages. (For example, in my plugin ep_kodama, openai-node seemed to contain such a conflict. https://github.com/yacchin1205/ep_kodama/issues/1 ) I assume npm allows for such conflicts https://stackoverflow.com/questions/42147243/how-does-npm-handle-version-conflicts . So I think that Etherpad's plugin mechanism should also allow for such conflicts so that it can accept a wide variety of plugins ☺️

SamTV12345 commented 4 weeks ago

Oh that is a bummer. It's the client. I opened a pr over there that bumps the LRU cache to version 10. Then I can do a final update of the openid-client and it should work again panva/node-openid-client#674

Thank you for making the Pull Request on node-openid-client. (Unfortunately, the pull request was closed without being merged...)

Such version conflicts seem to occur in several other npm packages. (For example, in my plugin ep_kodama, openai-node seemed to contain such a conflict. yacchin1205/ep_kodama#1 ) I assume npm allows for such conflicts https://stackoverflow.com/questions/42147243/how-does-npm-handle-version-conflicts . So I think that Etherpad's plugin mechanism should also allow for such conflicts so that it can accept a wide variety of plugins ☺️

I agree we need to find a more sophisticated way to store plugins. The question is only how. If you can think about a solution for this problem that would be great. I haven't found a solution on how to tell node that there is an alternative path in plugin_packages for that

yacchin1205 commented 3 weeks ago

I agree we need to find a more sophisticated way to store plugins. The question is only how. If you can think about a solution for this problem that would be great. I haven't found a solution on how to tell node that there is an alternative path in plugin_packages for that

Thanks for the reply. I will try to improve this behavior. I checked the code and it seems that the live-plugin-manager used by etherpad-lite also recognizes this as a known issue, and it says "Plugin dependencies can be specified only as NPM dependencies (version number) or github dependencies (owner/repo), url or other kind of dependencies are not supported". (Issue https://github.com/davideicardi/live-plugin-manager/issues/3 still exists) So I will consider including suggestions for improvements to live-plugin-manager.

TaliZorahVasNormandy commented 1 week ago

Is there any news on a fix for this error?

SamTV12345 commented 1 week ago

I just published the fix. Now I noticed that the node-live-plugin manger has some issues with other registries as I published the patched version of openid-client on jsr https://jsr.io/@etherpad/node-openid-client/publish . I'll try to come up with a solution tomorrow.

TaliZorahVasNormandy commented 1 week ago

Oh wow thank you so much!! Etherpad was the last bit of infrastructure I wanted to include in my SSO network and tuesday the first users are coming in, hugely appreciate your work!!!

yacchin1205 commented 1 week ago

(Issue davideicardi/live-plugin-manager#3 still exists) So I will consider including suggestions for improvements to live-plugin-manager.

FYI I am preparing code for improvements to live-plugin-manager. (Branch https://github.com/yacchin1205/live-plugin-manager/tree/feature/version-management ) I would like to test and submit a Pull Request in the next few days.

yacchin1205 commented 1 week ago

I have submitted a Pull Request for live-plugin-manager. If merged, using the modified live-plugin-manager and making minor fixes to etherpad-lite should resolve this issue.

yacchin1205 commented 2 days ago

The pull request for live-plugin-manager has been merged, and I will submit a pull request here when new version of the live-plugin-manager is published!

SamTV12345 commented 2 days ago

The pull request for live-plugin-manager has been merged, and I will submit a pull request here when new version of the live-plugin-manager is published!

Awesome did you ask him for a new release :) ?

yacchin1205 commented 2 days ago

Awesome did you ask him for a new release :) ?

Yes 😄 It may be released in the near future.