Schema Analyzer calls don't have the refreshed token which causes 401 error
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- api, authentication, frontend
調査の方向性
Admin.jsx から始めて、apiDocumentationParser、hydraDataProvider、Guesser コンポーネントがスキーマリクエスト用のセッショントークンをどのように取得しているかを追跡します。それらのリクエストをメインのデータ呼び出しと比較し、スキーマリクエストが更新された JWT を使用し、トークンの有効期限が切れた後も 401 を返さなくなっていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
API Platform version(s) affected: api: 3.3, admin: 3.4.6
Description
When accessing a resource from the admin, several extra calls seem to be made on top of the main call fetching the data:
These calls seem to be initiated by the Guesser Components to fetch the schema:
These calls do include a JWT but this token is not refreshed if expired. The JWT in the "main" call is correctly updated.
How to reproduce
- Clone Api Platform Demo repository
- Remove components so that the Guesser components do their job
Possible Solution
n/a
Additional Context
- Code is very close to the Demo:
// Admin.jsx
const apiDocumentationParser = (session) => async () => {
try {
return await parseHydraDocumentationWithEnums(ENTRYPOINT, {
headers: {
Authorization: `Bearer ${session?.accessToken}`,
},
});
} catch (result) {
// @ts-ignore
const { api, response, status } = result;
if (status !== 401 || !response) {
throw result;
}
return {
api,
response,
status,
};
}
};
const AdminUI = ({ children, session }) => {
const dataProvider = useRef();
const { docType } = useContext(DocContext);
dataProvider.current = hydraDataProvider({
entrypoint: ENTRYPOINT,
httpClient: (url, options = {}) => fetchHydra(url, {
...options,
headers: {
Authorization: `Bearer ${session?.accessToken}`,
},
}),
apiDocumentationParser: apiDocumentationParser(session),
});
return docType === "hydra" ? (
<HydraAdmin
requireAuth
authProvider={authProvider}
// @ts-ignore
dataProvider={dataProvider.current}
entrypoint={window.origin}
i18nProvider={i18nProvider}
layout={MyLayout}
>
{!!children && children}
</HydraAdmin>
) : (
<OpenApiAdmin
requireAuth
authProvider={authProvider}
// @ts-ignore
dataProvider={dataProvider.current}
entrypoint={window.origin}
docEntrypoint={`${window.origin}/docs.json`}
i18nProvider={i18nProvider}
layout={MyLayout}
>
{!!children && children}
</OpenApiAdmin>
);
};
const AdminWithContext = ({ session }) => {
const [docType, setDocType] = useState(
store.getItem("docType", "hydra"),
);
return (
<DocContext.Provider
value={{
docType,
setDocType,
}}>
<AdminUI session={session}>
// No Resources defined here unlike in the demo repo
</AdminUI>
</DocContext.Provider>
);
};
- parseHydraDocumentationWithEnums is based on https://github.com/api-platform/admin/issues/494#issuecomment-1427746210 doesn't seem to be the source as when using the normal
parseHydraDocumentationproblem remains. - Calls are made every time we access the resource from the admin if no ApiFilter is defined in the API
- If ApiFilter is defined in the API then calls are only made the first time we try to access the resource. If the resource is not accessed at least once before the initial token expires the problem remains
- 主要言語
- TypeScript
- スター
- 516
- フォーク
- 134
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
api-platform/admin のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
api-platform/admin#616 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 64/100
api-platform/admin#660 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
api-platform/admin#659 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
api-platform/admin#631 · コメント 6 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
api-platform/admin#626 · コメント 1 件 · リアクション 1 件 ·
api-platform/admin の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
opengovsg/FormSG#10118 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ai-driven-qa bug claude
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
linagora/twake-calendar-frontend#1434 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
iptv-org/iptv#52824 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 78/100
jaegertracing/jaeger-ui#4512 ·
メンテナーはふだん 1 日以内に返信
-
area:ide documentation enhancement platform:macos platform:vscode
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
anthropics/claude-code#97389 ·
メンテナーはふだん 1 日以内に返信