Skip to content

[FEAT] 로그인 #2

Description

@mimimya

📝 Issue

MSA서비스 전체의 인증, 인가를 위한 로그인

📄 설명

MSA서비스 전체의 인증, 인가를 위한 로그인을 구현합니다.

  • 각 서비스는 요청을 받기 전, 공통모듈에 정의된 LoginFilter를 통해 로그인된 사용자의 정보를 요청 헤더로부터 받아오고 SpringSecurityContext에 UserDetailsImpl형태로 uuid, email, slackId, name, roles, enabled(키클록이 전달하는 활성화된 사용자 여부) 를 저장합니다.

  • GW는 키클록과 사용자(actor)사이의 요청 헤더에 사용자 정보를 추가하는 변조를 하고 각 서비스에 요청을 전달합니다.

  • GW는 Keycloak으로부터 인증된 사용자의 ID(uuid)를 획득합니다.

  • GW는 획득한 ID를 기반으로 user-service를 조회하여 해당 사용자의 상세 정보(slackId, name, enabled 등)을 가져옵니다.

✅ 작업 내용

  1. Keycloak & API Gateway (인증 및 데이터 보강)
  • Keycloak Realm 및 Client 설정: Gateway 전용 클라이언트 생성 및 권한(Roles) 정의
  • GW OAuth2 Client 연동: spring-boot-starter-oauth2-client를 이용한 로그인/로그아웃 흐름 구현
  1. Gateway Post-Authentication Filter 구현:
  • Keycloak 토큰에서 sub(uuid) 추출
  • user-service 호출을 위한 내부 통신 로직 구현
  • 유저 상세 정보(slackId, name, enabled) 획득 및 헤더 주입(X-User-*) 로직 구현

🙋🏻 참고 자료

Spring Cloud Gateway Reference: Token Relay & Custom Filters

Keycloak Documentation: Securing Applications and Services

Spring Security: Servlet Filter Chain & SecurityContextHolder

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions