max-mapper / max-mapper/github-oauth

pathname in baseURL is ignored for redirectURI

オープン
#18 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
71
フォーク
20
PR マージ指標
30日以内にマージされた PR はありません

説明

{
  baseUrl: 'https://example.com/basename', 
  callbackURI: '/github/callback',
}

With that config, I get the redirect URI https://example.com/github/callback, even though it should contain the /basename. I explicitly don't want to specify /basename/github/callback as the callbackURI, because that would mount the route to that pathname, which would be available at https://example.com/basename/basename/github/callback (notice the double "basename").

I think the problem lies in the usage of url.resolve:

urlObj.pathname = url.resolve(urlObj.pathname, opts.callbackURI)

url.resolve is meant to resolve relative paths, but the callbackURI starts with a slash, so the pathname is ignored. Joining them with a / (and stripping unnecessary slashes) would be preferable in that case. Since all route mountpoints are supposed to start with a slash, we can probably just always change the behaviour and drop url.resolve entirely.

I provide a PR #19 with the suggested fix.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

url.resolve を使用している urlObj.pathname の代入箇所から始め、PR #19 と比較してください。baseUrl の /basename のような pathname が、callbackURI にそれを要求したり、マウントされたルートで重複させたりせずに redirect URI に保持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
authentication
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。