popcodeorg / popcodeorg/popcode

Google auth can be out of sync with Firebase/Popcode auth state

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

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

bug
主要言語
JavaScript
スター
191
フォーク
143
平均マージ
4日 11時間
マージ済み PR(30日)
5

説明

The authentication method we’re using with the Google SDK maintains an internal global auth state, which is used to authenticate calls made with the Google client library. Currently there is no guarantee that the Google SDK’s auth state is consistent with Firebase or Popcode’s own state.

When logging in or out using Google OAuth, this generally will not be a problem; logging in authenticates us with the Google SDK, and we end the Google session when the user signs out. However, there are some other circumstances where they can get out of sync:

  • Loading a Popcode environment when already logged in—Google maintains a session as well but it is likely to expire more quickly than Popcode’s own session
  • Logging in using the deprecated Log In With GitHub method

As a corollary, we currently store the idToken from the Google auth response, with the intention of using it to authenticate future Google API calls. However, this token is not used for that purpose and there is no reason to store it. At a minimum, we should stop storing it, and modify business logic which assumes that the presence of an auth token is a requirement for a valid linked identity provider.

As for the overall problem, it’s currently neither here nor there because we don’t actually make any authenticated calls to a Google API. This will change with #1511 however.

I can see a number of potential solutions to the problem of keeping auth state in sync, and guaranteeing that a logged in user is able to make authenticated calls to the Google API using their linked Google credentials:

  1. Ensure that a logged in Popcode user always has an active session in the Google auth SDK.
  • This would mean logging the user out if a new tab is opened which has an active Popcode/Firebase session but no active Google auth session. This pattern is already used to keep Popcode and Firebase session state in sync.
  • We would also need to either remove the GitHub login button entirely, or refuse to let people log in using GitHub to an account that is also linked to Google.
  • In general this is not a terribly appealing option because it means we are locked in to always having the user log in with Google, and our session management is at the mercy of Google’s
  1. Build in affordances for users initiating actions that they need further authentication in order to do. For instance if the user is logged in to Popcode with a Google-linked account, but does not actually have a Google session, and they tried to create an assignment in Classroom, we would show a Google auth dialog in order to create an active session in the Google auth SDK. For consistency, we would probably want to do the same thing with workflows that use the GitHub API.
  2. Switch to the stateless authentication API in the Google SDK. This is a lower-level API that does not do any session management and just allows us to initiate an OAuth flow and get some tokens back.
  • This would be a significant effort, though, because the auth token returned from authorize() is very short-lived. The higher-level API deals with periodically refreshing the token as long as a session is active, but as far as I can tell we would need to do this ourselves using the low-level API. Refreshing a token requires an API call that includes our private app secret, so we’d need to do it with server-side code; this would probably be reasonably straightforward using Firebase Cloud Functions but it would be our first time doing such a thing.
  • The upside is that we could use getOfflineAccess() to get a long-lived refresh token, essentially putting us in the same situation as we are with GitHub where we are able to store an evergreen credential that we can use for API requests

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

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

はじめの一歩

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

調査の方向性

まず、ここで説明されている認証フローを確認します。これには、Google OAuth、Firebase/Popcode のセッション処理、非推奨の GitHub ログイン、計画されている #1511 の Google API 作業が含まれます。ファイルやテストは指定されておらず、issue では複数の設計案が提示されています。実装とテストを探す前に、まず採用する同期アプローチとその受け入れ基準を確定してください。

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

評価

技術スタック
firebase, javascript
領域
authentication, web-dev
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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