🔍 OAuthスキーマ
OAuthスキーマは、OAuth関連エンドポイントの検証とドキュメント化に使用されるOpenAPI互換のスキーマとパラメータ定義を提供します。現在サポートされているプロバイダー: Google、Twitter、LINE。
🎯 概要
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フロータイプ指定(ログイン/サインアップ)用の目的クエリパラメータ。
目的: バックエンドの動作を指示するために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フローを開始するための入力を検証します。
スキーマ詳細:
- パラメータ:
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);
twitterOauthSchema
クエリパラメータと空のリクエストボディ検証を含むTwitter OAuth開始スキーマ。
目的: Twitter OAuthフローを開始するための入力を検証します。
スキーマ詳細:
- Parameters:
purpose、redirectUrl、typeId - Request Body:
- Content-Type:
application/json - Schema:
{ type: 'object', maxProperties: 0 }(ペイロードは許可されません)
- Content-Type:
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { twitterOauthSchema } = schemas;
export const twitterOAuthFeature = compose(twitterOauthSchema, twitterOAuthRoute);
lineOauthSchema
クエリパラメータと空のリクエストボディ検証を含むLINE OAuth開始スキーマ。
目的: LINE OAuthフローを開始するための入力を検証します。
スキーマ詳細:
- パラメータ:
fp、purpose、redirectUrl、typeId - Request Body:
- Content-Type:
application/json - Schema:
{ type: 'object', maxProperties: 0 }(ペイロードは許可されません)
- Content-Type:
クエリパラメータ:
fp: string(required) — デバイス/ブラウザ追跡用のフィンガープリント識別子purpose: 'oauth-login' | 'oauth-signup'(required) — OAuthフロー目的redirectUrl: string(required) — 完了後のクライアントリダイレクト先typeId: string(required) — サインアップフロー用のアイデンティティタイプ識別子
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { lineOauthSchema } = schemas;
export const lineOAuthFeature = compose(lineOauthSchema, lineOAuthRoute);
リクエスト例:
GET /auth/oauth/line?fp=1234567890&purpose=oauth-login&redirectUrl=https://example.com&typeId=regular
主な機能:
- すべての必須クエリパラメータを検証
- 空のリクエストボディを強制(maxProperties: 0)
- LINE OAuth開始ルートで使用
- ログインとサインアップの両方のフローをサポート