[feat] solution,deploy: 카카오 로그인을 인가 코드 교환으로 — 시크릿을 서버에 가둔다
콘솔에 발급된 설정이 설계와 어긋나 있었다. 클라이언트 시크릿이 켜져 있고 Redirect URI 가
프론트 경로(/auth/kakao/callback)인데, 코드는 "프론트가 액세스 토큰을 들고 온다" 는
전제였다 — 시크릿을 번들에 구울 수 없으므로 그 흐름으로는 토큰을 받을 수 없다.
- services/external/kakao_identity: access_token 검증 → **인가 코드 교환**으로 교체.
★ 우리 REST 키·시크릿으로 교환한 토큰이라 정의상 우리 앱 것이다 — 구글의 aud 대조에
해당하는 검사(KAKAO_LOGIN_APP_ID)가 구조적으로 필요 없어져 설정 칸째로 지웠다.
★ 로그인 앱과 챗봇 앱이 다르면 로그인은 되는데 채널 매칭만 조용히 안 된다 —
REST 키가 어긋나면 경고 로그를 남긴다.
★ 미인증 이메일은 신원으로 쓰지 않는다(is_email_valid·is_email_verified 둘 다). 이 값으로
auth_service 가 다른 수단 가입과의 충돌을 판정한다.
- config/config_models: KAKAO_LOGIN_APP_ID → REST_API_KEY · CLIENT_SECRET · REDIRECT_URI
- router/v1/auth: Req_KakaoLogin {access_token} → {code, redirect_uri}
- frontend: lib/kakaoIdentity(인가 URL · sessionStorage state) · KakaoSignInButton ·
pages/KakaoCallbackPage(코드는 1회용이라 ref 로 한 번만 보낸다) · routes
★ 로그인 폼에서 카카오를 구글 위에 둔다 — 이 수단으로 들어와야 6자리 코드 없이 채널이 이어진다
- compose · nginx/Dockerfile: REST 키·Redirect URI 만 프론트로 흘려보낸다. 시크릿은 안 나간다
- 어드민 키는 저장하지 않는다 — 탈퇴까지 되는 키인데 로그인에는 쓰이지 않는다
- api/generated: orval 재생성. 카카오 외에도 오래 밀려 있던 문구·agent 경로가 함께 따라왔다
테스트 8건 추가(tests/test_kakao_identity.py), 관련 85 passed
(test_auth::test_google_login_is_off_when_client_id_is_empty 는 기존 실패)
lint(react-router typegen + tsc + eslint) 통과
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ca0bea77a7
commit
3253166622
84 files changed
+1757
-259
No files matched your search
@@ -4,15 +4,18 @@
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import type {
|
||||
DataTag,
|
||||
DefinedInitialDataOptions,
|
||||
DefinedUseQueryResult,
|
||||
MutationFunction,
|
||||
QueryClient,
|
||||
QueryFunction,
|
||||
QueryKey,
|
||||
UndefinedInitialDataOptions,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from "@tanstack/react-query";
|
||||
@@ -185,3 +188,186 @@ export function useListMedia<
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* 그 사진을 REJECTED 로 내려 발행본에서 뺀다. ★ 지우지 않는다 — origin_url·source_type 이 남아 있어야 재게시 권리(docs/DECISIONS.md 1-2) 결론이 났을 때 되짚을 수 있고, 잘못 내렸을 때 되돌릴 수도 있다. 응답은 갱신된 목록이다.
|
||||
* @summary 사진 내리기
|
||||
*/
|
||||
export const hideMedia = (
|
||||
placeId: string,
|
||||
mediaId: string,
|
||||
options?: SecondParameter<typeof customFetch>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return customFetch<ResMediaList>(
|
||||
{
|
||||
url: `/v1/place/${placeId}/media/${mediaId}/hide`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
export const getHideMediaMutationOptions = <
|
||||
TError = void | HTTPValidationError,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof hideMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customFetch>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof hideMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["hideMedia"];
|
||||
const { mutation: mutationOptions, request: requestOptions } = options
|
||||
? options.mutation &&
|
||||
"mutationKey" in options.mutation &&
|
||||
options.mutation.mutationKey
|
||||
? options
|
||||
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
||||
: { mutation: { mutationKey }, request: undefined };
|
||||
|
||||
const mutationFn: MutationFunction<
|
||||
Awaited<ReturnType<typeof hideMedia>>,
|
||||
{ placeId: string; mediaId: string }
|
||||
> = (props) => {
|
||||
const { placeId, mediaId } = props ?? {};
|
||||
|
||||
return hideMedia(placeId, mediaId, requestOptions);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type HideMediaMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof hideMedia>>
|
||||
>;
|
||||
|
||||
export type HideMediaMutationError = void | HTTPValidationError;
|
||||
|
||||
/**
|
||||
* @summary 사진 내리기
|
||||
*/
|
||||
export const useHideMedia = <
|
||||
TError = void | HTTPValidationError,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof hideMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customFetch>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof hideMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getHideMediaMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* 목록 맨 앞으로 올린다. ★ 대표 사진은 별도 칸이 아니라 **목록의 첫 장**이다(site_payload.primary_media) — 칸을 따로 두면 검색 결과에 뜨는 그림과 화면 첫 장이 갈린다. 객실·메뉴 전용 사진(unit_id 가 있는 것)은 대표가 될 수 없다.
|
||||
* @summary 대표 사진 지정
|
||||
*/
|
||||
export const setPrimaryMedia = (
|
||||
placeId: string,
|
||||
mediaId: string,
|
||||
options?: SecondParameter<typeof customFetch>,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return customFetch<ResMediaList>(
|
||||
{
|
||||
url: `/v1/place/${placeId}/media/${mediaId}/primary`,
|
||||
method: "POST",
|
||||
signal,
|
||||
},
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
export const getSetPrimaryMediaMutationOptions = <
|
||||
TError = void | HTTPValidationError,
|
||||
TContext = unknown,
|
||||
>(options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof setPrimaryMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customFetch>;
|
||||
}): UseMutationOptions<
|
||||
Awaited<ReturnType<typeof setPrimaryMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
> => {
|
||||
const mutationKey = ["setPrimaryMedia"];
|
||||
const { mutation: mutationOptions, request: requestOptions } = options
|
||||
? options.mutation &&
|
||||
"mutationKey" in options.mutation &&
|
||||
options.mutation.mutationKey
|
||||
? options
|
||||
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
||||
: { mutation: { mutationKey }, request: undefined };
|
||||
|
||||
const mutationFn: MutationFunction<
|
||||
Awaited<ReturnType<typeof setPrimaryMedia>>,
|
||||
{ placeId: string; mediaId: string }
|
||||
> = (props) => {
|
||||
const { placeId, mediaId } = props ?? {};
|
||||
|
||||
return setPrimaryMedia(placeId, mediaId, requestOptions);
|
||||
};
|
||||
|
||||
return { mutationFn, ...mutationOptions };
|
||||
};
|
||||
|
||||
export type SetPrimaryMediaMutationResult = NonNullable<
|
||||
Awaited<ReturnType<typeof setPrimaryMedia>>
|
||||
>;
|
||||
|
||||
export type SetPrimaryMediaMutationError = void | HTTPValidationError;
|
||||
|
||||
/**
|
||||
* @summary 대표 사진 지정
|
||||
*/
|
||||
export const useSetPrimaryMedia = <
|
||||
TError = void | HTTPValidationError,
|
||||
TContext = unknown,
|
||||
>(
|
||||
options?: {
|
||||
mutation?: UseMutationOptions<
|
||||
Awaited<ReturnType<typeof setPrimaryMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
>;
|
||||
request?: SecondParameter<typeof customFetch>;
|
||||
},
|
||||
queryClient?: QueryClient,
|
||||
): UseMutationResult<
|
||||
Awaited<ReturnType<typeof setPrimaryMedia>>,
|
||||
TError,
|
||||
{ placeId: string; mediaId: string },
|
||||
TContext
|
||||
> => {
|
||||
const mutationOptions = getSetPrimaryMediaMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
Reference in new issue
Block a user