hackmdio / hackmdio/codimd

Generic oauth2 provider not working

Aperta
#1,671 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
10.1k
Fork
1.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da lib/auth/oauth2/strategy.js, nella chiamata a userProfile mostrata nello stack trace, quindi confronta il profilo OAuth2 configurato e le variabili dell’endpoint con il valore passato lì. Riproduci il flusso di Laravel Passport e determina quale URL non è definito; il lavoro è completato quando la causa e la modifica di configurazione o di codice necessaria sono confermate da una ricerca del profilo riuscita.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker-compose, javascript
Ambito
authentication, backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
28/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.