feat: integrate Kakao OAuth for user authentication and enhance user repository

- Added Kakao OAuth client implementation for handling authentication flows.
- Updated user repository to support OAuth-based user creation and retrieval.
- Introduced Redis-based session management for OAuth sessions.
- Enhanced in-memory user repository to handle OAuth user data.
- Updated environment configuration files to include new OAuth settings.
- Modified API routes to support Kakao login and registration flows.
- Added Prisma schema updates for user model to accommodate OAuth fields.
- Implemented tests for the new authentication flow and user repository methods.
This commit is contained in:
2025-12-30 02:19:32 +00:00
parent f01a21f2f0
commit 0c1e27ee4a
17 changed files with 893 additions and 6 deletions
+20
View File
@@ -7,6 +7,11 @@ export interface GatewayApiConfig {
sessionTtlSeconds: number;
gameSessionTtlSeconds: number;
gameTokenSecret: string;
oauthSessionTtlSeconds: number;
kakaoRestKey: string;
kakaoAdminKey?: string;
kakaoRedirectUri: string;
publicBaseUrl: string;
}
const parseNumber = (value: string | undefined, fallback: number, label: string): number => {
@@ -27,6 +32,12 @@ export const resolveGatewayApiConfigFromEnv = (
if (!secret) {
throw new Error('GAME_TOKEN_SECRET is required for gateway token encryption.');
}
const kakaoRestKey = env.KAKAO_REST_KEY ?? '';
const kakaoRedirectUri = env.KAKAO_REDIRECT_URI ?? '';
if (!kakaoRestKey || !kakaoRedirectUri) {
throw new Error('KAKAO_REST_KEY and KAKAO_REDIRECT_URI are required.');
}
const publicBaseUrl = env.GATEWAY_PUBLIC_URL ?? kakaoRedirectUri;
const redisKeyPrefix = env.GATEWAY_REDIS_PREFIX ?? 'sammo:gateway';
return {
host: env.GATEWAY_API_HOST ?? '0.0.0.0',
@@ -41,5 +52,14 @@ export const resolveGatewayApiConfigFromEnv = (
'GAME_SESSION_TTL_SECONDS'
),
gameTokenSecret: secret,
oauthSessionTtlSeconds: parseNumber(
env.OAUTH_SESSION_TTL_SECONDS,
10 * 60,
'OAUTH_SESSION_TTL_SECONDS'
),
kakaoRestKey,
kakaoAdminKey: env.KAKAO_ADMIN_KEY,
kakaoRedirectUri,
publicBaseUrl,
};
};