🔍 OAuth スキーマブロック
OAuth スキーマブロックは、OAuth 関連のエンドポイントを検証および文書化するために使用される OpenAPI 互換のスキーマとパラメーター定義を提供します。最初の実装は Google OAuth をターゲットとし、他のプロバイダーへの拡張が設計されています。
🎯 概要
OAuth スキーマブロックは次のことを目的として設計されています:
- プロバイダー間で OAuth リクエストデータを一貫して検証する
- 明示的なクエリパラメーター契約でセキュリティを確保する
- 開始とコールバックエンドポイントのための明確な API 契約を提供する
- TypeScript 統合で型安全を有効にする
- NodeBlocks フィーチャーとルートとの構成をサポートする
📋 OAuth スキーマタイプ
ベースパラメータスキーマ
OAuth フローのための再利用可能な OpenAPI パラメーター。
OAuth 開始スキーマ
OAuth 認可プロセスを開始するためのスキーマ。
🔧 利用可能な OAuth スキーマ
fpQueryParameter
Google OAuth リクエスト追跡とセキュリティ検証のためのフィンガープリントクエリパラメーター。
目的: フィンガープリントを使用して OAuth フローを特定のデバイス/ブラウザに関連付けます。
パラメーター詳細:
- Location:
query
- Name:
fp
- Required:
true
- Schema:
{ type: 'string' }
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { fpQueryParameter } = schemas;
export const googleOauthSchema = withSchema({
parameters: [fpQueryParameter]
});
purposeQueryParameter
Google OAuth フロータイプ仕様(login/signup)のための目的クエリパラメーター。
目的: バックエンド動作を指示するために OAuth フローの意図を宣言します。
パラメーター詳細:
- Location:
query
- Name:
purpose
- Required:
true
- Schema:
{ type: 'string', enum: ['oauth-login', 'oauth-signup'] }
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { purposeQueryParameter } = schemas;
export const googleOauthSchema = withSchema({
parameters: [purposeQueryParameter]
});
redirectUrlQueryParameter
Google OAuth コールバック宛先仕様のためのリダイレクト URL クエリパラメーター。
目的: OAuth フローが完了した後にユーザーエージェントをどこにリダイレクトするかをシステムに指示します。
パラメーター詳細:
- Location:
query
- Name:
redirectUrl
- Required:
true
- Schema:
{ type: 'string' }
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { redirectUrlQueryParameter } = schemas;
export const googleOauthSchema = withSchema({
parameters: [redirectUrlQueryParameter]
});
typeIdQueryParameter
Google OAuth フロー識別とルーティングのためのタイプ ID クエリパラメーター。
目的: オプションで、作成またはログインされているユーザーのアイデンティティタイプにタグ付けします(例: admin, user)。
パラメーター詳細:
- Location:
query
- Name:
typeId
- Required:
false
- Schema:
{ type: 'string' }
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { typeIdQueryParameter } = schemas;
export const googleOauthSchema = withSchema({
parameters: [typeIdQueryParameter]
});
stateQueryParameter
Google OAuth コールバック検証とセキュリティ検証のための状態クエリパラメーター。
目的: Google OAuth コールバック検証とセキュリティ検証に使用されます。
パラメーター詳細:
- Location:
query
- Name:
state
- Required:
true
- Schema:
{ type: 'string' }
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { stateQueryParameter } = schemas;
export const googleOAuthCallbackSchema = withSchema({
parameters: [stateQueryParameter]
});
googleOauthSchema
クエリパラメーターと空のリクエストボディ検証を使用した Google OAuth 開始スキーマ。
目的: Google OAuth フローを開始するための入力を検証します。
スキーマ詳細:
- Parameters:
fp
,purpose
,redirectUrl
,typeId
- Request Body:
- Content-Type:
application/json
- Schema:
{ type: 'object', maxProperties: 0 }
(ペイロードは許可されません)
- Content-Type:
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { googleOauthSchema } = schemas;
export const googleOAuthFeature = compose(googleOauthSchema, googleOAuthRoute);