hackmdio / hackmdio/codimd

Generic oauth2 provider not working

Open
#1,671 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
10.1k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I am trying to implement a generic oauth2 authentification for CodiMD. I am using laravel with passport. Everything seems to be fine on the laravel side, I approve the request on laravel, but then I get a proxy error. I am using docker compose with the following variables

- CMD_OAUTH2_BASEURL=http://www.example.org/
- CMD_OAUTH2_USER_PROFILE_USERNAME_ATTR=https://www.evample.org/api/user/get
- CMD_OAUTH2_USER_PROFILE_DISPLAY_NAME_ATTR=https://www.example.org/api/user/get2
- CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR=https://www.example.org/api/user/get3
- CMD_OAUTH2_CLIENT_ID=x
- CMD_OAUTH2_CLIENT_SECRET=xxxxxxxxxxxxxx
- CMD_OAUTH2_PROVIDERNAME=some name
- CMD_OAUTH2_AUTHORIZATION_URL=http://www.example.org/oauth/authorize
- CMD_OAUTH2_TOKEN_URL=http://www.example.org/oauth/token
- CMD_OAUTH2_SCOPE=

on the codimd logs I see the following

2021-04-19T17:04:52.568Z error: uncaughtException: The "url" argument must be of type string. Received type undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined
at Url.parse (url.js:154:11)
at Object.urlParse [as parse] (url.js:148:13)
at exports.OAuth2._request (/home/hackmd/app/node_modules/oauth/lib/oauth2.js:72:22)
at exports.OAuth2.get (/home/hackmd/app/node_modules/oauth/lib/oauth2.js:227:8)
at OAuth2CustomStrategy.userProfile (/home/hackmd/app/lib/auth/oauth2/strategy.js:54:18)
at loadIt (/home/hackmd/app/node_modules/passport-oauth2/lib/strategy.js:345:17)
at OAuth2CustomStrategy.OAuth2Strategy._loadUserProfile (/home/hackmd/app/node_modules/passport-oauth2/lib/strategy.js:360:25)
at /home/hackmd/app/node_modules/passport-oauth2/lib/strategy.js:168:16
at /home/hackmd/app/node_modules/oauth/lib/oauth2.js:209:7
at passBackControl (/home/hackmd/app/node_modules/oauth/lib/oauth2.js:134:9)
at IncomingMessage. (/home/hackmd/app/node_modules/oauth/lib/oauth2.js:157:7)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

The proxy between the host and the docker image is done as follows:

---
RewriteEngine On
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://localhost:3000/$1" [P,L]
ProxyPass / http://localhost:3000/ retry=5 timeout=600 Keepalive=On
ProxyPassReverse / http://localhost:3000/

---

Any thoughts? Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.