doorkeeper 설치 + DB 마이그레이션 + 설정 + 인증 통합

ID: 3e9333f0-d499-46a6-a86c-de319a77d48f

높음 완료

## 작업 내용
1. Gemfile에 `gem 'doorkeeper'` 추가 및 bundle install
2. `rails generate doorkeeper:install` 실행
3. doorkeeper 마이그레이션 생성 — **UUID PK 필수** (기존 DB 패턴: pgcrypto, gen_random_uuid)
4. `rails db:migrate` 실행
5. `config/initializers/doorkeeper.rb` 설정:
- `resource_owner_authenticator`: 기존 authentication.rb의 세션 기반 인증 활용
- `admin_authenticator`: 기존 admin 권한 체크 활용
- `grant_flows`: ['authorization_code', 'client_credentials']
- `access_token_expires_in`: 2.hours
- `use_refresh_token`: true
6. `config/routes.rb`에 `use_doorkeeper` 추가 (기존 라우트와 충돌 없도록)
7. User 모델에 doorkeeper 관계 추가
8. 기존 인증(Cookie Session, OmniAuth, Magic Link)이 정상 동작하는지 확인

## 참고 파일
- `app/controllers/concerns/authentication.rb` — 기존 인증 로직
- `app/controllers/concerns/authorization.rb` — 어드민 권한
- `app/models/user.rb` — User 모델
- `app/models/session.rb` — Session 모델
- `config/initializers/omniauth.rb` — OmniAuth 설정
- `config/routes.rb` — 라우트

## 완료 기준
- doorkeeper 테이블 생성 완료 (UUID PK)
- /oauth/authorize, /oauth/token 엔드포인트 접근 가능
- 기존 웹 로그인 정상 동작
- doorkeeper initializer 설정 완료

첨부 이미지

이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)

JPEG, PNG, GIF, WebP / 최대 10MB

담당자: backend-dev
생성일: 2026년 03월 01일 00:13

활동 로그

  • 팀리드 상태 변경: 리뷰 → 완료

    2026년 03월 01일 00:26:23

  • B
    backend-dev PKCE 마이그레이션 추가 완료

    2026년 03월 01일 00:25:59

    상세 보기

    ## 변경사항
    - `db/migrate/20260301002523_enable_pkce.rb` 실행
    - `oauth_access_grants` 테이블에 `code_challenge`(string, nullable) 칼럼 추가
    - `oauth_access_grants` 테이블에 `code_challenge_method`(string, nullable) 칼럼 추가
    - UUID 관련 영향 없음 (칼럼 추가만)
    - 인증 테스트 11/11 통과 확인

  • B
    backend-dev 상태 변경: 진행 중 → 리뷰

    2026년 03월 01일 00:19:14

  • B
    backend-dev doorkeeper 설치 + DB 마이그레이션 + 설정 + 인증 통합 완료

    2026년 03월 01일 00:19:14

    상세 보기

    ## 변경한 파일

    ### 1. `Gemfile` — doorkeeper gem 추가
    - `gem "doorkeeper"` 추가 (v5.8.2 설치됨)

    ### 2. `db/migrate/20260301001535_create_doorkeeper_tables.rb` — UUID PK 마이그레이션
    - `oauth_applications` — UUID PK
    - `oauth_access_grants` — UUID PK, `resource_owner_id`(uuid → users FK), `application_id`(uuid → oauth_applications FK)
    - `oauth_access_tokens` — UUID PK, `resource_owner_id`(uuid → users FK), `application_id`(uuid → oauth_applications FK)
    - 모든 FK에 인덱스 추가

    ### 3. `config/initializers/doorkeeper.rb` — OAuth2 Provider 설정
    - `resource_owner_authenticator`: 기존 cookie 기반 세션 인증 활용 (cookies.signed[:session_id])
    - `admin_authenticator`: admin? 체크
    - `grant_flows`: authorization_code, client_credentials
    - `access_token_expires_in`: 2시간
    - `use_refresh_token`: 활성화
    - `default_scopes`: :profile
    - `optional_scopes`: :email, :diagnoses, :strengths
    - `force_pkce`: 공개 클라이언트 보안 강화
    - `force_ssl_in_redirect_uri`: production에서 강제

    ### 4. `config/routes.rb` — `use_doorkeeper` 추가
    - `/oauth/authorize`, `/oauth/token`, `/oauth/revoke`, `/oauth/introspect` 등 엔드포인트 활성화
    - `/oauth/applications` 관리 UI 라우트 포함

    ### 5. `app/models/user.rb` — doorkeeper 관계 추가
    - `has_many :access_grants` (Doorkeeper::AccessGrant)
    - `has_many :access_tokens` (Doorkeeper::AccessToken)

    ### 6. `config/locales/doorkeeper.en.yml` — doorkeeper 기본 로케일 (자동 생성)

    ## 테스트 결과
    - 기존 인증 테스트(authentication_test.rb): **11/11 통과** ✅
    - 전체 테스트: 기존 실패(payments 3건, custom_payments 7건)는 doorkeeper와 무관한 기존 버그
    - doorkeeper가 기존 인증(Cookie Session, OmniAuth, Magic Link)에 영향 없음 확인

  • B
    backend-dev 작업 시작 - doorkeeper 설치

    2026년 03월 01일 00:14:53

    상세 보기

    ## 작업 계획
    1. 기존 프로젝트 구조 파악 (인증, 모델, 라우트)
    2. Gemfile에 doorkeeper 추가 + bundle install
    3. doorkeeper:install 제너레이터 실행
    4. 마이그레이션 UUID PK로 수정
    5. db:migrate 실행
    6. initializer 설정
    7. routes 설정
    8. 기존 인증 테스트 확인

  • B
    backend-dev 티켓 클레임 완료

    2026년 03월 01일 00:14:47