Yukaii / zuzugo

租租狗,通通給我租起來!
https://zuzugo.vercel.app
MIT License
10 stars 4 forks source link

Bolt slack installation and prisma #94

Closed Yukaii closed 1 year ago

Yukaii commented 1 year ago

需要解決 bolt 的 prisma installation 和 NextAuth 的整合

Bolt 的 InstallerProvider

用 NextAuth 的 OAuthChecks hooks 來截取必要資訊 暴露資訊太少,在 https://github.com/panva/node-openid-client/blob/d3642296a08da05c1c2ecce8a3145b2096df20f4/types/index.d.ts#L161-L167 ,真是一層一層疊起來欸好讚幹

  token: EndpointHandler<
    UrlParams,
    {
      /**
       * Parameters extracted from the request to the `/api/auth/callback/:providerId` endpoint.
       * Contains params like `state`.
       */
      params: CallbackParamsType
      /**
       * When using this custom flow, make sure to do all the necessary security checks.
       * This object contains parameters you have to match against the request to make sure it is valid.
       */
      checks: OAuthChecks
    },
    { tokens: TokenSet }
  >

https://github.com/vercel-labs/slacker/blob/main/pages/api/auth.ts#L16

Slacker 也是在 OAuth flow response 直接處裡 installation(當然是 MVP 的方式)。如果我們要有完整 installation 資訊(包含 webhook 那些),勢必就要重新實作 @slack/oauth 裡面的 handleCallback 裡面的部分內容;OAuth response 應該是可以從 next

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
zuzugo ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 2, 2023 at 3:31PM (UTC)
trunk-io[bot] commented 1 year ago

😎 Merged successfully (details).

Yukaii commented 1 year ago

昨天搞錯了,Slack 的 OAuth 有兩種資源,一個是 app installation 的,一種是 User 的。User 的部分,NextAuth 已經幫忙處裡了,就照舊就好;Installation 的部分,就整合 bolt 來做,設定另一個 OAuth Callback endpoint,也沒問題。發生的時序會是:

  1. 使用者點擊 Install this app to your slack workspace 按鈕
  2. Installation OAuth Process (And build slack_installation record
  3. 使用者到 Channel 使用 /zuzugo slash command
  4. Prompt 使用者走 User OAuth 流程
  5. Bot 提示訊息說已經 Authorize
Yukaii commented 1 year ago

/trunk merge