Skip to content

비밀번호 관리

Potato에서 PBKDF2-SHA256 비밀번호 해싱, 관리자 CLI/API 재설정, 셀프 서비스 토큰 기반 재설정 흐름, SQLite 또는 PostgreSQL 자격 증명 저장을 구성합니다.

v2.4.0의 새로운 기능

Potato의 인증 시스템은 100,000회 반복의 PBKDF2-SHA256과 사용자별 솔트를 사용하며, 이는 안전한 비밀번호 저장을 위해 NIST가 권장하는 것과 동일한 방식입니다. 이 페이지에서는 비밀번호가 저장되는 방식, 재설정 방법, 서버 재시작 후에도 자격 증명을 유지하는 방법을 다룹니다.

보안 구현

비밀번호는 salt$hash 형식으로 저장됩니다.

  • 사용자별로 고유한 32자 16진수 솔트
  • salt + password의 64자 SHA-256 해시
  • 타이밍 공격을 방지하기 위해 hmac.compare_digest를 통한 상수 시간 비교

user_config.jsonl 파일에 있는 기존 평문 비밀번호는 Potato가 로드할 때 고유한 솔트로 자동으로 다시 해싱됩니다. 수동 마이그레이션이 필요하지 않습니다.

기본 구성

기본적으로 Potato는 인메모리 인증을 사용합니다. 주석자는 구성에 나열되어 있어야 합니다.

yaml
authentication:
  method: in_memory
  require_password: true
 
user_config:
  users:
    - username: "annotator1"
      password: "initial-password"   # will be hashed on first load
    - username: "annotator2"
      password: "initial-password"

영구 자격 증명

인메모리 자격 증명은 재시작 시 손실됩니다. 영구 저장을 위해서는 파일 또는 데이터베이스 백엔드를 사용하십시오.

파일 기반 영속성

yaml
authentication:
  method: in_memory
  user_config_path: /shared/path/to/user_config.jsonl

Potato는 해싱된 자격 증명을 이 파일에 기록합니다. 재시작 시 이를 다시 읽어 들이므로, 세션 중에 설정하거나 변경한 비밀번호가 재시작 후에도 유지됩니다.

데이터베이스 백엔드

SQLite (추가 의존성 없음):

yaml
authentication:
  method: database
  database_url: "sqlite:///auth/users.db"

PostgreSQL (psycopg2-binary 필요):

yaml
authentication:
  method: database
  database_url: "postgresql://user:password@localhost:5432/potato_auth"

데이터베이스 테이블은 첫 시작 시 자동으로 생성됩니다.

참고: method: databaseuser_config_path는 상호 배타적입니다. 하나의 영속성 전략을 선택하십시오.

비밀번호 재설정

관리자 CLI

명령줄에서 비밀번호를 재설정합니다.

bash
# Reset a specific user's password
potato reset-password config.yaml --username annotator1
 
# Prompted for new password interactively

관리자 API

API 키로 프로그래밍 방식으로 재설정합니다.

bash
curl -X POST http://localhost:8000/admin/reset_password \
  -H "X-API-Key: $ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"username": "annotator1", "new_password": "new-secure-password"}'

셀프 서비스 토큰 재설정

Potato는 사용자가 시작하는 재설정 흐름을 지원합니다. 사용자는 /forgot-password로 이동하여 사용자 이름을 입력하고 일회용 재설정 토큰을 받습니다. 그런 다음 /reset/<token>을 방문하여 새 비밀번호를 설정합니다.

토큰은 24시간 동안 유효하며 한 번만 사용할 수 있습니다. Potato는 이메일을 보내지 않습니다. 관리자가 재설정 링크를 수동으로 배포합니다.

구성에서 활성화:

yaml
authentication:
  method: database
  database_url: "sqlite:///auth/users.db"
  allow_password_reset: true
  reset_token_ttl_hours: 24

관리자 워크플로:

bash
# Generate a reset token for a user
curl -X POST http://localhost:8000/admin/generate_reset_token \
  -H "X-API-Key: $ADMIN_API_KEY" \
  -d '{"username": "annotator1"}'
 
# Returns: {"reset_url": "https://your-server.com/reset/abc123..."}
# Share this URL with the annotator

비밀번호 없는 모드

강의실 데모, 빠른 연구, 또는 외부 인증(MTurk, Prolific)을 사용하는 작업의 경우 비밀번호를 완전히 비활성화할 수 있습니다.

yaml
authentication:
  method: in_memory
  require_password: false

주석자는 아무 사용자 이름이나 입력하여 로그인합니다. 비밀번호 입력 창이 나타나지 않습니다. 민감한 데이터나 검증된 신원이 필요한 작업에는 권장되지 않습니다.

자세한 내용은 비밀번호 없는 로그인을 참조하십시오.

전체 참조

yaml
authentication:
  method: in_memory       # in_memory | database | oauth | clerk
 
  # In-memory options
  require_password: true
  user_config_path: path/to/users.jsonl   # optional persistence
 
  # Database options (mutually exclusive with user_config_path)
  database_url: "sqlite:///auth/users.db"
 
  # Self-service reset
  allow_password_reset: true
  reset_token_ttl_hours: 24
 
user_config:
  users:
    - username: "researcher"
      password: "secure-passphrase"
      role: admin
    - username: "annotator1"
      password: "initial-pass"
      role: annotator

추가 자료

구현 세부 사항은 원본 문서를 참조하십시오.