-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/organization #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
Organizationdecorator parallel to existingUserdecorator for organization-specific endpoints - Extended article domain with
organizationIdand 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.
작업 내용
RBAC 구현
어드민 사용자에 대해 인증 진행하는 건 따로 논의가 없어서 코드가 이것저것 중복되는 것들이 많음.
회의 후 리팩토링하면 좋을 것 같음.