diff --git a/.env.example b/.env.example index 89af309..f16c9eb 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,6 @@ PORT=8000 LOG_LEVEL=info RELOAD=false -API_KEYS=combooks-key-change-me,baikal-key-change-me ENGINE_VERSION=o2o-plagiarism-2.1.0-kosimcse REFERENCE_CORPUS_DIR=./data/reference TAXONOMY_DIR=./data/taxonomy diff --git a/README.md b/README.md index 177ec96..925ae69 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,6 @@ uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload # 탐지 curl -X POST http://localhost:8000/v1/plagiarism/detect \ -H "Content-Type: application/json" \ - -H "X-API-Key: combooks-key-change-me" \ -d '{ "doc_id": "test-001", "text": "검사할 본문 텍스트…", @@ -84,17 +83,15 @@ curl -X POST http://localhost:8000/v1/plagiarism/detect \ # 자서전 업로드 curl -X POST http://localhost:8000/v1/corpus \ -H "Content-Type: application/json" \ - -H "X-API-Key: combooks-key-change-me" \ -d '{"title": "김OO 자서전", "text": "본문…"}' # .txt 파일 업로드 curl -X POST http://localhost:8000/v1/corpus/file \ - -H "X-API-Key: combooks-key-change-me" \ -F "title=김OO 자서전" \ -F "file=@autobiography.txt" # 코퍼스 목록 -curl -H "X-API-Key: combooks-key-change-me" http://localhost:8000/v1/corpus +curl http://localhost:8000/v1/corpus # 분류체계 조회 (10종 태그 + 39 케이스) curl http://localhost:8000/v1/taxonomy @@ -102,21 +99,19 @@ curl http://localhost:8000/v1/taxonomy ## 엔드포인트 요약 -| Method | Path | 용도 | 인증 | -|---|---|---|---| -| GET | `/` | 검토 콘솔 (HTML) | - | -| GET | `/docs` | Swagger UI | - | -| GET | `/v1/health` | 헬스체크 + 엔진 정보 | - | -| GET | `/v1/taxonomy` | 분류체계 조회 | - | -| POST | `/v1/plagiarism/detect` | 단건 동기 탐지 | ✅ | -| POST | `/v1/plagiarism/batch` | 배치 잡 등록 (≤500건) | ✅ | -| GET | `/v1/plagiarism/batch/{job_id}` | 배치 결과 조회 | ✅ | -| GET | `/v1/corpus` | 코퍼스 목록 | ✅ | -| POST | `/v1/corpus` | JSON 업로드 | ✅ | -| POST | `/v1/corpus/file` | .txt 파일 업로드 | ✅ | -| DELETE | `/v1/corpus/{doc_id}` | 삭제 | ✅ | - -인증: `X-API-Key` 헤더에 발급된 키 (기관별 분리 발급 가능, 콤마 구분). +| Method | Path | 용도 | +|---|---|---| +| GET | `/` | 검토 콘솔 (HTML) | +| GET | `/docs` | Swagger UI | +| GET | `/v1/health` | 헬스체크 + 엔진 정보 | +| GET | `/v1/taxonomy` | 분류체계 조회 | +| POST | `/v1/plagiarism/detect` | 단건 동기 탐지 | +| POST | `/v1/plagiarism/batch` | 배치 잡 등록 (≤500건) | +| GET | `/v1/plagiarism/batch/{job_id}` | 배치 결과 조회 | +| GET | `/v1/corpus` | 코퍼스 목록 | +| POST | `/v1/corpus` | JSON 업로드 | +| POST | `/v1/corpus/file` | .txt 파일 업로드 | +| DELETE | `/v1/corpus/{doc_id}` | 삭제 | ## 응답 스키마 (탐지 결과) @@ -159,7 +154,6 @@ curl http://localhost:8000/v1/taxonomy | 변수 | 기본 | 설명 | |---|---|---| -| `API_KEYS` | `combooks-key-…,baikal-key-…` | 콤마 구분 다중 키 | | `SIMILARITY_THRESHOLD` | `0.85` | 침해 판정 임계값 (정밀도 우선) | | `AUTOBIOGRAPHY_MODE` | `true` | 자서전 특화 전처리 (공통표현+NER) | | `USE_LSH_FILTER` | `true` | MinHash+LSH 1차 필터 | diff --git a/app/api/routes.py b/app/api/routes.py index 2d6fbc3..32b9bdd 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -2,7 +2,7 @@ from __future__ import annotations from datetime import datetime, timezone -from fastapi import APIRouter, BackgroundTasks, Depends, File, Form, HTTPException, Request, UploadFile, status +from fastapi import APIRouter, BackgroundTasks, File, Form, HTTPException, Request, UploadFile, status from app.api.schemas import ( BatchCreatedResponse, @@ -17,7 +17,6 @@ from app.api.schemas import ( HealthResponse, TaxonomyResponse, ) -from app.core.auth import require_api_key from app.core.config import get_settings from app.engine.corpus import add_document, delete_document, list_documents from app.engine.detector import PlagiarismDetector @@ -79,7 +78,6 @@ async def taxonomy(request: Request) -> TaxonomyResponse: "/plagiarism/detect", response_model=DetectResponse, tags=["plagiarism"], - dependencies=[Depends(require_api_key)], ) async def detect(req: DetectRequest, request: Request) -> DetectResponse: return _detector(request).detect_request(req) @@ -90,7 +88,6 @@ async def detect(req: DetectRequest, request: Request) -> DetectResponse: response_model=BatchCreatedResponse, status_code=status.HTTP_202_ACCEPTED, tags=["plagiarism"], - dependencies=[Depends(require_api_key)], ) async def batch_create( req: BatchRequest, @@ -113,7 +110,6 @@ async def batch_create( "/plagiarism/batch/{job_id}", response_model=BatchStatusResponse, tags=["plagiarism"], - dependencies=[Depends(require_api_key)], ) async def batch_status(job_id: str, request: Request) -> BatchStatusResponse: job = _job_store(request).get(job_id) @@ -142,7 +138,6 @@ def _rebuild(request: Request) -> int: "/corpus", response_model=CorpusListResponse, tags=["corpus"], - dependencies=[Depends(require_api_key)], ) async def corpus_list(request: Request) -> CorpusListResponse: settings = get_settings() @@ -158,7 +153,6 @@ async def corpus_list(request: Request) -> CorpusListResponse: response_model=CorpusUploadResponse, status_code=status.HTTP_201_CREATED, tags=["corpus"], - dependencies=[Depends(require_api_key)], ) async def corpus_upload_json(req: CorpusUploadRequest, request: Request) -> CorpusUploadResponse: """JSON으로 자서전 1건 업로드. 인덱스 자동 재빌드.""" @@ -183,7 +177,6 @@ async def corpus_upload_json(req: CorpusUploadRequest, request: Request) -> Corp response_model=CorpusUploadResponse, status_code=status.HTTP_201_CREATED, tags=["corpus"], - dependencies=[Depends(require_api_key)], ) async def corpus_upload_file( request: Request, @@ -218,7 +211,6 @@ async def corpus_upload_file( "/corpus/{doc_id}", status_code=status.HTTP_204_NO_CONTENT, tags=["corpus"], - dependencies=[Depends(require_api_key)], ) async def corpus_delete(doc_id: str, request: Request) -> None: settings = get_settings() diff --git a/app/core/auth.py b/app/core/auth.py deleted file mode 100644 index 1a330aa..0000000 --- a/app/core/auth.py +++ /dev/null @@ -1,13 +0,0 @@ -from fastapi import Header, HTTPException, status - -from app.core.config import get_settings - - -async def require_api_key(x_api_key: str | None = Header(default=None)) -> str: - settings = get_settings() - if not x_api_key or x_api_key not in settings.api_key_set: - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail="Invalid or missing X-API-Key header", - ) - return x_api_key diff --git a/app/core/config.py b/app/core/config.py index 653cc9d..27b044b 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -13,7 +13,6 @@ class Settings(BaseSettings): log_level: str = "info" # debug / info / warning / error reload: bool = False # 개발용 자동 재시작 - api_keys: str = "combooks-key-change-me,baikal-key-change-me" engine_version: str = "o2o-plagiarism-2.0.0-pdf-v1.2" reference_corpus_dir: str = "./data/reference" taxonomy_dir: str = "./data/taxonomy" @@ -49,10 +48,6 @@ class Settings(BaseSettings): autobiography_mode: bool = True enable_entity_masking: bool = True - @property - def api_key_set(self) -> set[str]: - return {k.strip() for k in self.api_keys.split(",") if k.strip()} - @property def corpus_path(self) -> Path: return Path(self.reference_corpus_dir).resolve() diff --git a/app/static/index.html b/app/static/index.html index 6da6056..08457a6 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -358,9 +358,6 @@