Skip to content

Conversation

@liveforpresent
Copy link
Contributor

작업 내용

  • RBAC 구현

    • jwt claim에 roles 추가. ORGANIZATION(기관), ADMIN(관리자), USER(일반 사용자)로 구분.
    • controller의 각 API에 역할 기반 인증 필요 시, RolesGuard와 함께 Roles 데코레이터 사용.
    • 예를 들어 Roles(Role.ORGANIZATION)인 API의 경우, 기관 사용자만 이용 가능
  • 어드민 사용자에 대해 인증 진행하는 건 따로 논의가 없어서 코드가 이것저것 중복되는 것들이 많음.

  • 회의 후 리팩토링하면 좋을 것 같음.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements Role-Based Access Control (RBAC) by adding a new role system with three roles (USER, ORGANIZATION, ADMIN) to JWT claims. A new RolesGuard and @Roles decorator enable role-based endpoint protection. Key changes include refactoring authentication to support both user and organization entities with separate decorators, adding organizationId to articles, and standardizing cookie names across auth endpoints.

  • Added RBAC infrastructure with JWT-based role validation
  • Introduced Organization decorator parallel to existing User decorator for organization-specific endpoints
  • Extended article domain with organizationId and created organization-specific article endpoints

Reviewed Changes

Copilot reviewed 46 out of 47 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/auth/core/domain/value-object/role.ts Defines new Role enum with USER, ADMIN, ORGANIZATION
src/auth/core/infrastructure/guard/role.guard.ts Implements role-based authorization guard
src/auth/core/infrastructure/jwt/jwt-payload.ts Adds roles array to JWT payload interface
src/auth/core/infrastructure/jwt/jwt.provider.ts Updates token generation to include roles in payload
src/shared/core/presentation/role.decorator.ts Adds @roles decorator for marking required roles
src/shared/core/presentation/organization.decorator.ts Adds @organization decorator for extracting organization payload
src/shared/core/presentation/user.decorator.ts Refactors to extract from JwtPayload instead of UserPayload
src/user/command/application/create/*.ts Removes role parameter from user creation flow
src/auth/auth-user/presentation/auth-user.controller.ts Adds role guards to user auth endpoints
src/auth/auth-organization/presentation/auth-organization.controller.ts Adds role guards and standardizes cookie names
src/article/command/domain/article.ts Adds organizationId field to Article entity
src/article/command/presentation/article.command.controller.ts Adds OrganizationArticleCommandController with role-based access
src/article/query/organization/* Adds organization-specific article query functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@liveforpresent liveforpresent merged commit d34195c into develop Nov 20, 2025
2 of 3 checks passed
@liveforpresent liveforpresent deleted the feature/organization branch November 20, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants