Declare the Location header on OAuth2 redirect responses in the OpenAPI spec

未關閉 適合新手
#14,155 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@HarshMN2345 已經在處理了。

開始於 2026年10月7日。

  • #1983 來自 @HarshMN2345 —— 未關閉
  • #14192 來自 @HarshMN2345 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
75/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
openapi, php
領域
api

研究方向

從 src/Appwrite/SDK/Specification/Format/OpenAPI3.php 開始,特別注意 504-512 行與 547-552 行附近的響應處理。追蹤兩個具名的 OAuth2 操作如何產生 301 響應,接著檢查 204、302 與 308 響應的處理方式。完成條件為:兩個 301 響應都宣告了指定的無內容 Location 標頭,204 響應維持不變,且該規範可通過 OpenAPI 3.0 驗證。

由索引模型根據 Issue 內容生成。

描述

product / auth product / databases product / messaging product / sites sdk / cli

Summary

The OpenAPI 3 spec describes the two OAuth2 redirect endpoints as returning an HTML body with no destination. A 301 is a redirect, and the part a client needs is the Location header. This issue covers declaring the redirect properly in the spec, using only standard OpenAPI fields.

Affected operations (the only 3xx operations in the 2.3.x spec):

  • GET /account/sessions/oauth2/{provider} (createOAuth2Session)
  • GET /account/tokens/oauth2/{provider} (createOAuth2Token)

Current

"responses": {
  "301": {
    "description": "No content",
    "content": {
      "text/html": {
        "schema": {
          "type": "string",
          "format": "binary"
        }
      }
    }
  }
}

Proposed

"responses": {
  "301": {
    "description": "Redirect to the OAuth2 provider's sign-in page.",
    "headers": {
      "Location": {
        "description": "URL of the OAuth2 provider's authorization page.",
        "schema": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  }
}
  • Drop content. The body of a redirect is not part of the API.
  • Add headers.Location (OpenAPI 3.0 Response Object headers).
  • Replace the "No content" description with one that says what the response does.

Where

src/Appwrite/SDK/Specification/Format/OpenAPI3.php:

  • Lines ~504-512 add the binary content because the route's content type is HTML.
  • Lines ~547-552 set the description to "No content" for 204/301/302/308 and drop content only for 204.

For 301, 302 and 308, drop content as for 204, and emit the Location header.

Why

sdk-generator currently has to infer that these methods are browser redirects from the response shape: a 3xx with a non-JSON binary body (Language::getMethodType). Declaring the Location header states it directly, so generators and other OpenAPI tooling can treat these operations as redirects without guessing.

Context: server SDKs currently request these URLs themselves instead of returning them for the browser to open. Since #14012 that breaks server-started OAuth2 sign-in with user_oauth2_state_invalid, because the nonce cookie never reaches the browser. That SDK fix is tracked separately. This issue only covers the spec.

Out of scope

  • sdk-generator changes. getMethodType must switch to "3xx with a Location header" in the same release as this change, otherwise SDKs stop classifying these methods as webAuth.
  • x-appwrite extensions, security schemes, and any other spec changes.

Acceptance criteria

  • Both operations' 301 responses have headers.Location with type: string, format: uri, and no content.
  • The description is no longer "No content" for 3xx responses.
  • 204 responses are unchanged.
  • The spec validates as OpenAPI 3.0.
主要語言
TypeScript
星號
57.9k
分支
5.8k
平均合併
16 小時 1 分鐘
30 天內合併 PR
768

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

appwrite/appwrite 的其他 Issue

查看 appwrite/appwrite 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。